Upload2Shell (CVE-2026-125396): Threat Overview and Detection Coverage
Written by Tim Peck · Director of Threat Research

The Vulnerability: A PostScript file with a .jpg extension
CVE-2026-125396 is a use-after-free in a font loader of Ghostscript, the PostScript and PDF interpreter that popular tools such as ImageMagick, Pillow and CUPS use to render files. pwn.ai, which identified the flaw, said a carefully crafted document can be used to turn off Ghostscript's -dSAFER sandbox from inside the interpreter and run commands as the account that renders the file.
The document clears the interpreter's path-control flag and its file-permission settings in memory, then opens a %pipe% file, which hands a command to the system shell. On a Linux print server, pwn.ai's command ran as lp, the renderer's account, and in its WordPress test it wrote a PHP file as www-data.
The file does not need a PostScript name. In pwn.ai's tests, PostScript saved as .jpg, .png or .pdf reached Ghostscript when an application built a thumbnail or preview, and it reports command execution through Roundcube, WordPress and several plugins, MediaWiki, DokuWiki and an anonymous print job to a shared CUPS queue, among others.
Artifex fixed the flaw in Ghostscript 10.08.0 on 8 September 2026, and distributions have backported it at different speeds. Debian, Ubuntu and, since 23 November, AlmaLinux ship fixed packages. Several large distributions had no fix on 24 November:
• Red Hat lists RHEL 7, 8, 9 and 10 as affected, with no fixed package yet.
• Amazon lists Amazon Linux 2 and Amazon Linux 2023 as pending a fix. Only the Amazon Linux 2027 preview is fixed, since 19 November.
• SUSE lists its enterprise releases as pending, with packages in testing. openSUSE Tumbleweed is fixed.
A container image keeps the Ghostscript it was built with, and AlmaLinux notes that a long-running service keeps the old library loaded until it restarts.
The CVE scores 8.5 under CVSS 4.0 with a local attack vector, because Ghostscript only reads files another program hands it. Equixly warns that tools ranking by attack vector may place it below network-facing bugs.
No vendor or government source we read reports exploitation in the wild to date. Sophos X-Ops reported on 23 November that proof-of-concept code is available. The code pwn.ai published proves control of native memory by swapping one arithmetic operator for another and back, and pwn.ai says it does not run a shell command or touch host files. pwn.ai has published excerpts of its command-execution chain and says the full Debian CUPS proof will come first in its series.
Three third-party GitHub repositories, all created on 22 November, publish generators that claim command execution:
- The first turns a command into a PNG that runs when Pillow loads the image.
- One builds payloads that call back over HTTP or DNS and claims to work on Ghostscript 9.26 through 10.07.1.
- The third claims the full chain on Debian and macOS, including commands as www-data behind WordPress and a reverse shell.
Until a fixed build is in place, Sophos advises keeping Ghostscript away from untrusted files. Equixly and AlmaLinux suggest the same measures: disable ImageMagick's PostScript and PDF coders in policy.xml where you don't need them, require authentication on shared CUPS queues, and check a file's real type before it is thumbnailed or converted. Red Hat gives the same policy.xml change and suggests confining renderers with SELinux or a container.
Look for Ghostscript, or the process it runs inside, starting a shell or writing a script file as a web, mail or print account.
Detections you can reliably use today
To date, the current detection stack on detections.ai focuses on the code execution or command shell behavioral analytics. The documentation of each public generator describes the same route to a command, a %pipe% file that starts /bin/sh -c under Ghostscript, which is the shell these rules watch for. For most of its vendor reports pwn.ai used a proof that read /proc/version, and an exploit that only reads files starts no process, so these rules would not see it.
In normal use Ghostscript has little reason to start a shell, apart from print setups that send output through a %pipe% to lp or lpr. Four older public rules already alert on it. They were written for CVE-2024-29510, for a Pillow EPS bug reported in October and for an ImageMagick proof of concept code.
The same June proof of concept accounts for most of the rest. We hand-picked 8 notable detections, and these are the ones we would deploy first, in kill-chain order:
Upload2Shell (CVE-2026-125396) - Ghostscript Spawns Shell, Interpreter or Recon Tool
YARA-L · Shell started · Needs process launch events in Google SecOps
A Ghostscript binary (gs, gsc, gsx, a versioned gs-10.x name, ghostscript, or the Windows gswin32 and gswin64 binaries) starting a shell, a scripting interpreter, curl, wget, nc, socat, or a recon command such as id, whoami or uname, grouped by host over an hour. It skips a shell whose command is a bare lp or lpr call with no shell metacharacters, so a payload chained after a print command still alerts.
This is our rule. It tracks Ghostscript linked into ImageMagick as a library, where no gs process exists. Print workflows that pipe Ghostscript output to a custom script will need an exclusion.
Web or Application Server Spawning a Shell
SPL · Shell started · Needs the Endpoint.Processes data model
A web or application server process starting a shell, on Linux or Windows. Version 9, dated 23 November, files the rule under Upload2Shell and lists gs and ghostscript among the Linux parents and gswin32, gswin32c, gswin64 and gswin64c among the Windows parents.
The shell lists are in Splunk's linux_shells and windows_shells macros. The parent list also covers PHP processes, so it can catch a shell started from Ghostscript running as a library inside a PHP worker, which the Ghostscript-only rules miss.
Linux Ghostscript Exploitation
SPL · Shell started · Needs the Endpoint.Processes data model from Linux
A parent process path ending in /gs or /ghostscript and a child command line containing sh -c. Splunk wrote it for CVE-2024-29510 and dates it 8 July 2026, and the shell command a %pipe% file starts would match it unchanged.
It needs full command lines. Splunk says legitimate document conversion may trigger it and suggests filtering known applications.
Pillow EPS Ghostscript RCE: Python-spawned Ghostscript or shell child
KQL · Shell started · Needs DeviceProcessEvents
Two branches over the last 7 days: Ghostscript (gs, gswin32c.exe, gswin64c.exe and their other Windows names) starting sh, bash, dash, zsh, cmd.exe, PowerShell, wscript.exe or cscript.exe; or Python starting Ghostscript with %pipe%, %handle%, %stdout or NOSAFER on the command line.
The first branch is the one that fires on Upload2Shell. The second needs a command line that asks for a pipe or turns SAFER off, and Upload2Shell needs neither, because the document turns the checks off from inside.
ImageMagick Ghostscript Delegate Path Hijack — Non-Standard gs Spawn or Shell (exploitarium)
CQL · Shell started · Needs CrowdStrike ProcessRollup2 events
Its second scenario is a parent named gs, ghostscript, gswin64c or gswin32c starting bash, sh, zsh, dash, cmd, PowerShell, wscript, cscript, mshta, python, perl or ruby. Its first scenario, ImageMagick starting Ghostscript from a non-standard path.
It has no exclusions, so print setups that pipe Ghostscript output through a shell will match. It was published in June under the detections.ai author label.
ImageMagick Ghostscript Delegate Hijack — Suspicious gs/gswin64c Execution
S1QL · Shell or download tool started · Needs SentinelOne process, file and network events
Five branches joined by OR. Two of them fire on Upload2Shell: Ghostscript starting a shell or interpreter, and Ghostscript starting curl, wget, certutil.exe, bitsadmin.exe or nc. The others flag ImageMagick starting Ghostscript without -dSAFER, any network connection from Ghostscript, and Ghostscript writing a script or executable, or any non-image file under /tmp/, /dev/shm/ or a Windows temp or user folder.
The file-write branch can match the temporary files of ordinary conversions, so expect to tune it or drop it. It was published in June under the detections.ai author label for the ImageMagick proof of concept.
Upload2Shell (CVE-2026-125396) - Ghostscript or ImageMagick Writes Web Shell, Script or Persistence File
YARA-L · Script or persistence file written · Behavior, plus indicators · Needs file creation events with the writing process in Google SecOps
Ghostscript or an ImageMagick binary (magick, convert, mogrify, montage, identify, including Debian names such as convert-im6.q16) creating or changing a server-side script such as .php, .jsp or .sh, a shared object, an SSH authorized_keys file, a cron or systemd unit, a shell profile or /etc/ld.so.preload.
Because it also watches ImageMagick, it covers part of the library case the shell rules miss. The marker branch is an indicator and stops matching once the path changes, and one public generator already writes its marker somewhere else.
Web Anomaly Followed by Server Process Execution
SPL · Upload, then a shell · Needs Splunk Enterprise Security risk events and asset identification
A web finding followed within 15 minutes by an endpoint finding on the same server, joined through the Enterprise Security asset lookup. The web findings include Splunk's new PostScript-upload rule, and the endpoint findings include the shell rule above.
It works only when the rules it names write risk events and the asset lookup maps each server's IP address to its hostname. Splunk files it under six analytic stories, among them Upload2Shell, Java4Shell, Ruby2Shell and PHP2Shell.
Threat Hunting: The upload and the exposure
On the threat hunting side, PostScript or EPS Upload with Image or PDF Extension, looks in Zeek's files.log for an HTTP upload whose content is PostScript and whose filename ends in an image or PDF extension. Splunk says the mismatch does not establish exploitation, and the sensor has to see plaintext HTTP, so we treat it as a hunt.
To find exposure, Equixly recommends checking the package on each host, gs --version inside every container image that renders files, and whether ImageMagick will pass PostScript and PDF to Ghostscript (magick -list format). Compare against your distribution's fixed build, because backports keep older version numbers. A checker that reads only the version will report every backported build as vulnerable. Scanners that match on the CVE id may flag patched Ubuntu hosts too: Ubuntu's CVE page still listed every release as needing evaluation, although Ubuntu's 21 October update fixed the bug before it had a CVE number.
The behavior to keep watching
The marker files, callback names and test commands will change and the disguised file names already vary. What any working exploit still has to do is run its command or write its file as the account that renders the document: www-data behind a web upload or webmail thumbnail, lp on a print server, or a container user in a document worker. Process creation with parent and command line, plus file creation with the writing process, is the telemetry the rules above need.
Where Ghostscript runs as a library, we expect the parent of that shell to be the process that loaded it, such as an ImageMagick command or a PHP worker. Equixly makes the related point that a host without a gs binary may still run Ghostscript. pwn.ai adds that a policy stopping a renderer from starting a shell can limit what happens even after the interpreter is compromised, and in Equixly's summary of the Plesk test an enforced AppArmor profile blocked the shell.
Next Steps: Finding other rules on detections.ai
Start from the Threat Report, Upload2Shell: Ghostscript Sandbox Escape to RCE. A Threat Report is a detections.ai summary of public reporting, scored from 1 to 10 for how usable it is in detection engineering, and its public page lists related detections.
AI Assistant can draft a detection from the Threat Report in your query language, and the draft needs testing like any rule above. On the enterprise tier, Nightwatch hunts your connected telemetry for the activity in each new report and checks your own detection library for coverage.
Then search for the behavior, for example ghostscript shell, because the four older rules that fire do not carry the new name.
Sources
Rule metrics: published rules in community groups, counted once per distinct rule. A rule mentions Upload2Shell when the word or the CVE id is in its title, description, query or CVE field. The 16 older rules are every other public rule that mentions Ghostscript or gswin64c, and we read each query in full. Search: distinct people whose detection search contained upload2shell or 125396, staff excluded. No figure identifies a member.
Research: pwn.ai, Equixly, Sophos X-Ops and AlmaLinux. Fix status: Red Hat, Amazon, SUSE and Ubuntu. Exploitation: CISA KEV. Detection logic outside detections.ai: Elastic.


