November 22, 2026

Critical Ghostscript Vulnerability Exposes Linux Servers to Remote Command Execution

A newly disclosed security vulnerability in Ghostscript, a ubiquitous but often invisible component of the modern Linux ecosystem, is sending ripples through the cybersecurity community. The flaw, which allows a specially crafted file to escape the program’s security sandbox and execute arbitrary commands on a host server, highlights a persistent risk in the way web applications process documents and images.

Tracked as CVE-2026-125396, the vulnerability was brought to light by researchers at the security firm pwn.ai. Their investigation revealed that common server-side tasks—such as generating a thumbnail for an uploaded image, processing an email attachment, or managing a print queue—could be leveraged to gain unauthorized access to a system. While the flaw was officially patched on September 8, the complexity of how Ghostscript is integrated into other software means that many systems may remain vulnerable long after a fix is made available.

The Invisible Engine of Document Processing

Ghostscript serves as an interpreter for PostScript and Portable Document Format (PDF) files. It is the "engine under the hood" for a vast array of Linux-based services. Despite its importance, many system administrators and developers may not realize their applications are utilizing it. This is because Ghostscript is rarely called directly by an end-user application. Instead, it is invoked as a background dependency by popular image and document libraries, including ImageMagick, Pillow, libvips, and various Qt plugins.

The researchers at pwn.ai demonstrated that this indirect relationship creates a significant blind spot. An attacker does not need to upload a file with a .ps or .pdf extension to trigger the vulnerability. Because these libraries often inspect the "magic bytes" or internal structure of a file rather than its extension, a malicious file disguised as a standard .png or .jpg image can be passed to Ghostscript for rendering. Once the interpreter begins processing the file, the exploit is triggered.

This "polyglot" nature of the attack makes it particularly dangerous. A routine feature, such as a website allowing a user to upload a profile picture or a webmail service generating a preview of an attachment, becomes a potential entry point for a remote shell.

Researchers Demonstrate Ghostscript Sandbox-Escape RCE via Crafted File Uploads in Popular Apps

Technical Analysis: Breaking the Sandbox

The core of the issue lies in a "use-after-free" memory corruption bug within the portion of Ghostscript responsible for loading fonts. Use-after-free vulnerabilities occur when a program continues to use a pointer after it has been freed, allowing an attacker to manipulate memory and redirect the program’s execution flow.

In the case of CVE-2026-125396, the exploit targets the -dSAFER sandbox. This sandbox is Ghostscript’s primary line of defense, designed specifically to prevent PostScript documents from performing dangerous actions, such as accessing the local file system or running external commands. By exploiting the memory corruption bug during the font-loading process, an attacker can effectively "flip a switch" within the interpreter’s memory, disabling the security restrictions imposed by -dSAFER.

Once the sandbox is bypassed, the document—which is essentially a script—gains the ability to execute commands with the same privileges as the Ghostscript process. In most modern server configurations, this is a low-privilege service account. However, even with restricted permissions, a successful exploit allows an attacker to establish a foothold, probe the internal network, or attempt further privilege escalation.