criticalZero-Day

Ghostscript JPEG 2000 Heap Buffer Overflow (CVE-2026-39919)

First seen Sep 16, 2026 · Updated Sep 16, 2026 · CVSS 9.8

ghostscriptrceheap-overflowpdf-parsingjpeg2000memory-corruptionagent-relevant

A critical heap-based buffer overflow exists in Ghostscript's JPEG 2000 output adapter, exploitable via a crafted PDF containing mismatched image component subsampling factors. Successful exploitation can lead to remote code execution on any system that processes untrusted PDFs through Ghostscript, including document conversion pipelines and rendering services.

Technical Analysis

The vulnerability resides in base/sjpx_openjpeg.c, where the non-samescale sub-byte-depth output path miscalculates row buffer allocation size for packed sub-byte output but writes a full byte per output column, causing a heap overflow that corrupts chunk-allocator metadata. This corruption can be leveraged for arbitrary code execution by an attacker who supplies a malicious PDF with crafted JPEG 2000 image components. Ghostscript is widely embedded in PDF rendering, conversion, and printing toolchains (e.g., ImageMagick, CUPS, LibreOffice, various document processing microservices), making the attack surface broad and often indirect. Because many AI agent frameworks and RAG pipelines automatically ingest, render, or convert PDF documents (e.g., for document QA, summarization, or knowledge extraction) using Ghostscript-backed libraries, a malicious PDF submitted to an agent's document ingestion pipeline could trigger RCE on the host running the agent, potentially exposing API keys, credentials, or enabling lateral movement within the agent's execution environment.

Affected Systems

Ghostscript versions prior to 10.08.0; any application or service that invokes Ghostscript for PDF rendering, conversion, or thumbnail generation, including ImageMagick, GraphicsMagick, CUPS printing systems, LibreOffice, poppler-based tools with Ghostscript fallback, and custom document-processing pipelines used in RAG/agent ingestion workflows

Indicators of Compromise

  • No known public IOCs at this time (vulnerability disclosure stage)
  • Malicious PDF files containing JPEG 2000 images with mismatched component subsampling factors
  • Anomalous crashes or memory corruption in gs process logs
  • Unexpected child processes spawned from ghostscript/gs binary

Remediation Steps

  1. 1

    Upgrade Ghostscript

    Update Ghostscript to version 10.08.0 or later, which contains the fix for the JPEG 2000 buffer overflow, across all systems and dependent packages (ImageMagick, CUPS, LibreOffice, etc.).

  2. 2

    Sandbox PDF Processing

    Isolate Ghostscript-based PDF rendering and conversion tasks in sandboxed or containerized environments with minimal privileges to limit blast radius if exploitation occurs.

  3. 3

    Input Validation and Filtering

    Implement pre-processing checks to detect and reject malformed or anomalous JPEG 2000 image structures within PDFs before they reach Ghostscript.

  4. 4

    Audit Agent Ingestion Pipelines

    Review AI agent and RAG document ingestion workflows to identify any use of Ghostscript-dependent PDF processing, and apply patches or sandboxing before those pipelines accept untrusted external documents.

  5. 5

    Monitor for Exploitation Indicators

    Deploy monitoring for crashes, unexpected memory usage spikes, or abnormal process behavior in services invoking Ghostscript to detect exploitation attempts.

CVE / Advisory IDs

CVE-2026-39919

Industries Most Exposed

TechnologyPrinting and PublishingLegalFinancial ServicesHealthcareGovernmentSoftware DevelopmentDocument Management Services

Sources

Respond to this threat

Pro subscribers get a full AI-generated incident-response playbook for this threat — detection, containment, eradication, and recovery steps — plus an unlimited AI Threat Advisor for questions about your environment.