Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-58380

CVE-2026-58380: GIMP Buffer Overflow Vulnerability

CVE-2026-58380 is a buffer overflow flaw in GIMP's PNM file parser that enables memory corruption and potential code execution. This article covers the technical details, affected versions, impact, and mitigation.

Published:

CVE-2026-58380 Overview

CVE-2026-58380 is an off-by-one memory corruption flaw in the GNU Image Manipulation Program (GIMP) PNM file format parser. The pnmscanner_gettoken() function writes a null terminator one byte past the end of a stack-allocated buffer when parsing a specially crafted PNM image. This boundary error [CWE-193] corrupts adjacent stack memory and can lead to denial of service or arbitrary code execution in the context of the local user. Exploitation requires the victim to open a malicious PNM file, aligning with the local attack vector and required user interaction described in the CVSS metrics.

Critical Impact

A malicious PNM image can corrupt stack memory in GIMP, resulting in application crash or arbitrary code execution under the user's privileges.

Affected Products

  • GNU Image Manipulation Program (GIMP) - PNM file format parser
  • Linux distributions shipping the affected GIMP package (see Red Hat advisory)
  • Applications embedding the vulnerable GIMP PNM parsing routines

Discovery Timeline

  • 2026-07-06 - CVE-2026-58380 published to the National Vulnerability Database (NVD)
  • 2026-07-06 - Last updated in NVD database

Technical Details for CVE-2026-58380

Vulnerability Analysis

The flaw resides in pnmscanner_gettoken(), the tokenizer used by GIMP's PNM (Portable Any Map) file format parser. The function reads whitespace-delimited tokens from a PNM header into a fixed-size stack buffer. Its loop boundary check permits one additional write beyond the allocated buffer size when appending the terminating null byte.

The result is a one-byte stack overflow classified as an off-by-one error [CWE-193]. The overwritten byte sits adjacent to saved registers, canaries, or return addresses depending on compiler layout. On systems without stack protection, the corruption can be steered toward arbitrary code execution. On hardened builds, the most likely outcome is a SIGABRT from canary validation, producing a denial of service.

See the GNOME GIMP Commit 83699817 and GNOME GIMP Issue #16206 for the upstream fix and reproduction details.

Root Cause

The loop condition in pnmscanner_gettoken() treats the buffer capacity as inclusive rather than exclusive. When the token length equals the buffer size, the routine still writes '\0' at buffer[size], one byte past the final valid index.

Attack Vector

An attacker crafts a PNM file whose header token reaches or exceeds the tokenizer's buffer capacity. The victim opens the file in GIMP or in another application that invokes the vulnerable parsing routine. The parser writes the trailing null byte outside the buffer, corrupting adjacent stack data during image load.

The vulnerability requires local file access and user interaction, matching the CVSS vector components for this issue. There are no public exploits and no evidence of exploitation in the wild. The EPSS probability sits at 0.122%.

Detection Methods for CVE-2026-58380

Indicators of Compromise

  • Unexpected GIMP process crashes with SIGSEGV or SIGABRT shortly after opening PNM, PBM, PGM, or PPM files
  • Core dumps referencing pnmscanner_gettoken in the crashing call stack
  • PNM files sourced from untrusted email attachments, downloads, or shared drives immediately preceding a GIMP crash

Detection Strategies

  • Inspect PNM headers for tokens that approach or exceed typical field lengths, which is atypical for legitimate images
  • Monitor endpoint telemetry for GIMP child processes spawning shells or unexpected binaries after image load
  • Correlate file open events for .pnm, .pbm, .pgm, and .ppm extensions with subsequent process crashes

Monitoring Recommendations

  • Enable and retain core dump collection on Linux workstations running GIMP to capture off-by-one crash artifacts
  • Log GIMP version inventory across the fleet and flag hosts running unpatched builds referenced in the Red Hat CVE-2026-58380 advisory
  • Alert on GIMP process creations that deviate from baseline parent-child relationships

How to Mitigate CVE-2026-58380

Immediate Actions Required

  • Apply the upstream GIMP patch referenced in GNOME GIMP Commit 83699817 or the distribution package that includes it
  • Update GIMP through vendor package managers on all endpoints where users open image files
  • Restrict opening PNM files from untrusted sources until patched builds are deployed

Patch Information

The upstream fix corrects the loop boundary in pnmscanner_gettoken() so the null terminator is written within the buffer. Track distribution-specific package updates through the Red Hat Bug Report #2496135 and vendor advisories for downstream availability.

Workarounds

  • Disable or remove the PNM plug-in from GIMP's plug-in directory until the patched version is installed
  • Instruct users to avoid opening .pnm, .pbm, .pgm, and .ppm files received from untrusted sources
  • Apply file-type filtering at email and web gateways to quarantine PNM attachments during the remediation window
bash
# Remove the PNM plug-in as a temporary mitigation (paths vary by distribution)
sudo mv /usr/lib64/gimp/2.0/plug-ins/file-pnm /root/file-pnm.disabled

# Verify installed GIMP version against the fixed release
gimp --version

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.