kagancapar/CVE-2026-5201

GitHub: kagancapar/CVE-2026-5201

针对 gdk-pixbuf JPEG 加载器堆溢出漏洞(CVE-2026-5201)的完整概念验证仓库,包含漏洞根因分析、复现代码和代码执行利用演示。

Stars: 10 | Forks: 4

# CVE-2026-5201 **gdk-pixbuf JPEG 加载器中的堆缓冲区溢出** 你好,我是 [Kağan Çapar](https://github.com/kagancapar)。我在 gdk-pixbuf 的 JPEG 图像加载器中发现了一个堆缓冲区溢出漏洞,该漏洞几乎影响所有的 Linux 桌面环境。该漏洞被分配了 **CVE-2026-5201**,并已被 [Red Hat](https://access.redhat.com/security/cve/CVE-2026-5201) 确认,CVSS 评分为 **7.5(重要)**。 本仓库包含我的完整分析、我从头编写的复现程序,以及在 Ubuntu 24.04 LTS 实时系统上的崩溃证据。 | | | |---|---| | **CVE** | [CVE-2026-5201](https://www.cve.org/CVERecord?id=CVE-2026-5201) | | **CWE** | [CWE-122](https://cwe.mitre.org/data/definitions/122.html) — 堆缓冲区溢出 (Heap-based Buffer Overflow) | | **CVSS v3** | **7.5** (AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H) | | **受影响版本** | gdk-pixbuf (修复前的所有版本) | | **供应商** | GNOME | | **修复** | [gdk-pixbuf@6cce931](https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/commit/6cce9311e70b969cbcc6e3e1e74ae1756ed02d5b) | | **追踪** | [GNOME #304](https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/304) | | **Bugzilla** | [Red Hat #2453291](https://bugzilla.redhat.com/show_bug.cgi?id=2453291) | ## 概述 我在 gdk-pixbuf 的 JPEG 图像加载器 (`io-jpeg.c`) 中发现了一个堆缓冲区溢出漏洞。直接文件加载路径 (`gdk_pixbuf__jpeg_image_load`) 在分配像素缓冲区之前未验证颜色分量的数量。一个精心构造的 122 字节 JPEG 文件,其在 SOF 头中声明了 9 个分量,但在 SOS 中仅扫描 3 个,这会导致 gdk-pixbuf 为 3 个通道分配缓冲区,而 libjpeg 每个像素写入 9 个通道 —— 从而导致高达约 49 KB 的攻击者可控数据的堆溢出。 增量加载器路径已经具备此确切验证,但直接加载路径中缺少该验证。 ## 影响 - **拒绝服务**:任何使用 `gdk_pixbuf_new_from_file()` 的应用程序都会 100% 崩溃 - **堆破坏**:GObject vtable 指针 (`g_class`) 被像素数据覆盖 - **代码执行**:通过 vtable 劫持在 32 位 Linux 上已演示 - **受影响系统**:所有 Linux 桌面 — Ubuntu, Fedora, Debian, Arch, RHEL 7–10 ## 受影响的 Red Hat 产品 | 产品 | 组件 | 状态 | |---------|-----------|--------| | Red Hat Enterprise Linux 10 | gdk-pixbuf2 | 受影响 | | Red Hat Enterprise Linux 10 | loupe | 受影响 | | Red Hat Enterprise Linux 10 | snapshot | 受影响 | | Red Hat Enterprise Linux 9 | gdk-pixbuf2 | 受影响 | | Red Hat Enterprise Linux 8 | gdk-pixbuf2 | 受影响 | | Red Hat Enterprise Linux 7 | gdk-pixbuf2 | 受影响 | ## 根本原因 在 `gdk-pixbuf/io-jpeg.c` 中,函数 `gdk_pixbuf__jpeg_image_load()` 存在以下问题: **1. 分配空间不足** ([第 633 行](https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/gdk-pixbuf/io-jpeg.c#L633)): ``` pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, cinfo->out_color_components == 4 ? TRUE : FALSE, 8, cinfo->output_width, cinfo->output_height); ``` **2. 写入数据过大** ([第 696 行](https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/gdk-pixbuf/io-jpeg.c#L696)): ``` jpeg_read_scanlines(cinfo, lines, cinfo->rec_outbuf_height); // writes output_components (9) bytes per pixel into a 3-byte buffer ``` **3. 缺失验证** — 增量加载器已在 [第 1142 行](https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/gdk-pixbuf/io-jpeg.c#L1142) 检查 `output_components`,但该检查在直接加载路径中不存在。 ## 复现 ### 生成复现文件 ``` python3 reproducer/craft_cve_2026_5201.py ``` 这将创建一个 122 字节的 JPEG 文件,其中 SOF10 头中包含 9 个分量,而 SOS 中仅扫描 3 个。 ### 触发崩溃 ``` # Compile gcc -o crash_test reproducer/crash_test.c \ $(pkg-config --cflags --libs gdk-pixbuf-2.0) -fsanitize=address -g # Run ./crash_test cve_2026_5201.jpg ``` ### 预期输出 (AddressSanitizer) ``` ==PID==ERROR: AddressSanitizer: SEGV on unknown address 0x52b000020006 ==PID==The signal is caused by a WRITE memory access. #0 libjpeg.so.8 (null_convert) #1 libjpeg.so.8 (sep_upsample) #2 libjpeg.so.8 (process_data_context_main) #3 libjpeg.so.8 jpeg_read_scanlines #4 libgdk_pixbuf-2.0.so.0 (JPEG loader) #5 libgdk_pixbuf-2.0.so.0 gdk_pixbuf_new_from_file ``` ### GDB 输出 (无 ASAN) ``` Program received signal SIGSEGV, Segmentation fault. g_type_check_instance_is_fundamentally_a () → g_object_unref() → gdk_pixbuf_new_from_file() rax = 0x808080808080ffff ← corrupted GObject vtable pointer ``` ## 修复 该修复添加了增量加载器中已存在的相同 `output_components` 验证: ``` jpeg_start_decompress(cinfo); if (cinfo->output_components != 3 && cinfo->output_components != 4 && !(cinfo->output_components == 1 && cinfo->out_color_space == JCS_GRAYSCALE)) { g_set_error(error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, "Unsupported number of color components (%d)", cinfo->output_components); goto out; } ``` 已在 [gdk-pixbuf@6cce931](https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/commit/6cce9311e70b969cbcc6e3e1e74ae1756ed02d5b) 中应用。 ## 测试环境 | | | |---|---| | 操作系统 | Ubuntu 24.04.1 LTS | | gdk-pixbuf | 2.42.10+dfsg-3ubuntu3.2 | | libjpeg | libjpeg-turbo 2.1.5 (libjpeg.so.8.2.2) | | GCC | 13.3.0 | ## 参考资料 - https://www.cve.org/CVERecord?id=CVE-2026-5201 - https://nvd.nist.gov/vuln/detail/CVE-2026-5201 - https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/304 - https://access.redhat.com/security/cve/CVE-2026-5201 - https://bugzilla.redhat.com/show_bug.cgi?id=2453291 ## 历史先例 [CVE-2017-2862](https://nvd.nist.gov/vuln/detail/CVE-2017-2862) (Cisco Talos TALOS-2017-0366) — CVSS 8.8 — gdk-pixbuf 中相同的 `null_convert` 缓冲区不匹配漏洞类别,被归类为远程代码执行。 ## 致谢 **Kağan Çapar** — [GitHub](https://github.com/kagancapar) · [LinkedIn](https://linkedin.com/in/kagancapar) · [X](https://x.com/kagancapar) *已在 [CVE-2026-5201 公告](https://access.redhat.com/security/cve/CVE-2026-5201) 中被 Red Hat 致谢。*
标签:CVE-2026-5201, CVSS 7.5, CWE-122, Exploit, gdk-pixbuf, GNOME, JPEG加载器, libjpeg, PoC, Red Hat, Ubuntu 24.04, XXE攻击, 内存破坏, 图像处理库, 堆溢出, 客户端加密, 拒绝服务, 暴力破解, 漏洞分析, 路径探测, 逆向工具, 配置错误, 零日漏洞