Upload2Shell — CVE-2026–125396 Understandings
A use-after-free flaw in Ghostscript's font-loading helper allowed a crafted file to recover a privileged internal operator and escape the -dSAFER sandbox. An attacker could then run commands as the account that renders the file.
Cybersecurity
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Ghostscript is the interpreter that most Linux servers use, usually without anyone noticing, to read PDF and PostScript files and turn them into images or previews. It sits underneath tools such as ImageMagick, Pillow, libvips, CUPS (printing), WordPress thumbnails and webmail previews. When a job portal builds a small preview of an uploaded resume, it is Ghostscript that does the rendering behind the scenes.
The catch is that PostScript is a programming language, so opening a PostScript file means running a program. To make that safe, Ghostscript runs it inside a sandbox called -dSAFER, whose contract is: you may draw, but you may not touch files or run commands. The normal flow looks like this:
Upload → App / Library → Ghostscript (-dSAFER sandbox) → Preview
Upload2Shell (CVE-2026-125396) is a use-after-free in Ghostscript that breaks that contract. The attacker never talks to Ghostscript directly: they upload a file that looks like an ordinary JPG, and the application hands it to the interpreter on their behalf.

Quick facts from the write-up
| Item | Value |
|---|---|
| Found by | Paulos Yibelo and the pwn.ai team (with AI help) |
| Fixed in | Ghostscript 10.08.0 (released 8 September 2026) |
| Details and proof-of-concept public | 21 November 2026 |
| Severity | CVSS 4.0 8.5 (High) |
| Exploited in the wild | No attacks reported so far |

Setup
The write-up does not describe a lab build, accounts or tooling versions beyond the Ghostscript release itself. The preconditions it does state are about the target, not the researcher:
- The application accepts files from someone else (resume, photo, PDF).
- It makes a thumbnail, preview or resize of that file.
- The Ghostscript copy it uses is older than 10.08.0.
Several of the routes pwn.ai demonstrated needed no login at all, so no account is required for those paths.
Finding it
The starting point is the hotel analogy the author uses throughout: you check out, the receptionist forgets to cancel your key card, the room is given to a new guest, and your old card still opens the door. In memory terms, the room is the allocation, the pointer is the old key card. Ghostscript gives the room back (frees it) but the attacker's card still works, so they can read and change whatever now lives there.

The bug lives in the part of Ghostscript's font loading that is written in PostScript itself. One helper, .putgstringcopy, uses a very powerful internal operator called .forceput to write into protected areas. The helper never checked what it was handed. That missing check is what turns a type error into a sandbox escape.
Exploitation
The chain has five stages, as the write-up lays them out:
1. Crafted Type 1 font → helper hits a type error2. File's own error handler takes over → recovers the privileged .forceput3. Use-after-free → attacker keeps a pointer to memory that gets freed4. Memory read/write → -dSAFER path checks switched off5. Command runs on the server
Step 1: deliver a disguised file
The file can be named .jpg, .png or .pdf. Libraries look at the bytes, not the name, so a file called resume.jpg that is really PostScript still reaches the interpreter. The overall flow is:
Disguised file (resume.jpg, really PostScript) ↓App or library checks the content and passes it to Ghostscript ↓Crafted Type 1 font → type error → .forceput recovered ↓Use-after-free → memory read/write ↓-dSAFER disabled → command runs as the service account
Step 2: trigger the type error in the font helper
The crafted Type 1 font makes .putgstringcopy hit a type error, because the helper never validated its operand.
Step 3: recover the privileged operator
The file's own error handler takes over after the type error and recovers the privileged .forceput, which the sandbox was supposed to keep out of reach.
Step 4: turn it into a use-after-free
The attacker keeps a pointer to memory that Ghostscript then frees, giving them read and write access to whatever is later placed there.
Step 5: switch off the sandbox and run a command
With memory read/write in hand, the -dSAFER path checks are switched off and a command runs on the server. It runs as the account that renders the file, for example lp for printing or the web server user. That is not instant root, but it is a solid foothold.
Three properties make the technique dangerous:
- Disguise: the file can be named
.jpg,.pngor.pdf, and libraries look at the bytes rather than the name. - Indirect reach: the attacker never talks to Ghostscript directly; the application does it for them.
- Zero or low access: several paths needed no login.
The write-up lists the routes pwn.ai demonstrated in a diagram rather than in text.

MITRE ATT&CK mapping given in the write-up: T1190 Exploit Public-Facing Application, T1566.001 Spearphishing Attachment (Roundcube route), T1036.008 Masquerade File Type, T1059.004 Unix Shell.
One upload is not automatically a shell. It depends on which libraries the application uses, and the public proof-of-concept only shows the core memory trick and fails on 10.08.0.
Root cause
The mistake is a missing type check. .putgstringcopy is a PostScript-level helper that writes through .forceput into protected areas, and it never checked what it was handed. A crafted Type 1 font drives it into a type error; the file's own error handler then recovers the privileged .forceput, and from there the attacker keeps a pointer to freed memory. The use-after-free gives read and write access, which is enough to switch off the -dSAFER path checks and run a command.
The -dSAFER sandbox did not stop it: the chain switches off its path checks.
Impact
Anything running Ghostscript before 10.08.0 that processes files from someone else is affected.

An attacker who can get a file in front of the interpreter can execute a command on the server as the account that renders the file. That account is typically lp for printing or the web server user, so the result is not instant root but a solid foothold. Several of the demonstrated routes needed no login, and the attacker never needs to reach Ghostscript directly: the application makes the call for them.
Two hedges matter. First, whether one upload becomes a shell depends on which libraries the application uses. Second, the public proof-of-concept only shows the core memory trick and fails on 10.08.0. No attacks in the wild had been reported at the time of writing.
There is also a version trap: distributions often backport fixes, so an old-looking number such as 9.55 can already be patched. Check the distribution's advisory, not just gs --version. WordPress closed its own upload path in 7.0.4 (CVE-2026-65640), but that is a different point in the same chain, and the Ghostscript fix is still needed.
Fix
The upstream fix is the commit titled "validate operands to .putgstringcopy". It checks the operand types first, so the error path can no longer reach the privileged write. It shipped in Ghostscript 10.08.0, released 8 September 2026.
Remediation steps from the write-up:
- Update Ghostscript to 10.08.0 or the distribution's patched build:
# Debian / Ubuntusudo apt update && sudo apt upgrade ghostscript# AlmaLinux / RHEL-familysudo dnf clean metadata && sudo dnf upgrade 'ghostscript*' libgs
- Restart services that already loaded the old library (
sudo dnf needs-restartinglists them). - Check containers and bundled copies. Patching the host does not patch a Ghostscript inside a Docker image or an application bundle; rebuild those images.
- Update WordPress to 7.0.4 or later as well.
If patching today is not possible, there is no setting that removes the bug, because -dSAFER is the very thing being bypassed. You can only reduce how easily a file reaches Ghostscript:
- ImageMagick: block PostScript-type coders in
policy.xml:
<policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,EPSI,EPT,PDF,XPS}" />
- CUPS: do not share print queues with untrusted networks, and require authentication.
- Web apps: check the file's real type before thumbnailing, and turn off previews for document types you do not need.
- Hardening: in one pwn.ai test, an AppArmor profile stopped the hijacked interpreter from starting a shell.
These measures only narrow the exposure. Patching is the real fix.

Detection notes for blue teamers
The write-up lists these signals to watch for:
gsspawningsh,bash,curlorwget. The chainphp-fpm/apache → convert/magick → gs → shshould never happen.- Ghostscript crashes (segfaults) right after an upload.
- Uploads where the extension says
.jpgbutfilesays PostScript. - Anonymous print jobs from unknown IPs.
A Wazuh/auditd rule on execve where the parent process is gs is described as a quick win.
Conclusion
The dangerous code is often not the code you wrote, but the quiet helper three layers below your application. A single forgotten type check turned a trusted sandbox into an open door. Patch Ghostscript, check your containers, and treat every uploaded file as untrusted, even when it says .jpg.
What happened, in plain words
Imagine you check out of a hotel, but the receptionist forgets to cancel your key card. The next day your old room is given to a new guest, and your old card still opens the door. You walk in and start rearranging their things.
That is the idea behind Upload2Shell (CVE-2026-125396): a use-after-free bug in Ghostscript, a tool hiding on millions of Linux servers that most people have never heard of. The attacker does not need to break into your server directly. They upload a file that looks like a normal JPG, and your own application hands it to Ghostscript, which runs it.
A few words before we go further, because the rest of this article leans on them.
- Ghostscript is a free program that reads PDF and PostScript files and turns them into images or previews. It is a library: a piece of software that other programs load and call, rather than something you start yourself.
- PostScript is a programming language for describing pages. A PDF is close to it in spirit. The important consequence: a PostScript file is not just data to look at, it is a program to run.
- A use-after-free is a memory bug. When a program needs memory it asks the operating system for a block, uses it, and gives it back. If the program keeps a reference (a pointer, which is just the address of that block) after giving the block back, and later reads or writes through that reference, it is touching memory that may now belong to something else. Like the old key card.
- A sandbox is a set of restrictions around a program so that, even if it is fed something malicious, it cannot do much harm. Ghostscript's sandbox is called
-dSAFER. - A CVE is a public catalogue number for a known security flaw, so that everyone can refer to the same bug unambiguously.
Quick facts
| Item | Value |
|---|---|
| Found by | Paulos Yibelo and the pwn.ai team (with AI help) |
| Fixed in | Ghostscript 10.08.0 (released 8 September 2026) |
| Details and proof-of-concept public | 21 November 2026 |
| Severity | CVSS 4.0 8.5 (High) |
| Exploited in the wild | No attacks reported so far |

CVSS is a scoring system for how serious a flaw is; 8.5 out of 10 is rated High. Proof-of-concept (PoC) means demonstration code that shows the bug working, published so defenders and other researchers can check it.
1. What Is Ghostscript, and Why Is It on My Server?
Ghostscript reads PDF and PostScript files and turns them into images or previews. You almost never call it yourself. It sits quietly underneath tools like ImageMagick, Pillow, libvips, CUPS (printing), WordPress thumbnails and webmail previews.
Those names are worth a sentence each, because they are the reason the bug reaches so many places:
- ImageMagick is a very common command-line tool and library for converting and resizing images. Many web applications use it to make thumbnails.
- Pillow is an image library for Python, and libvips is a separate image processing library used by other programs.
- CUPS is the standard printing system on Linux and other Unix-like systems. It accepts print jobs, and a print job can be a PDF.
- WordPress is site-building software that runs a large share of the web and can generate thumbnails for uploaded media.
- Webmail previews are the little previews of attachments your webmail application shows you.
Example: you upload your resume to a job portal. The site makes a small preview of it. Behind the scenes, it hands your file to Ghostscript.
Here is the catch: PostScript is a programming language. Opening one means running a program. To keep that safe, Ghostscript uses a sandbox called -dSAFER, which says: "You may draw, but you may not touch files or run commands."
Upload → App / Library → Ghostscript (-dSAFER sandbox) → Preview
Read that diagram left to right. A file arrives by upload. The application or library receives it and decides it needs a preview. It calls Ghostscript, which runs the file inside the -dSAFER sandbox. The result is a preview image shown back to the user. The attacker's file travels the same path as a legitimate one; nothing in this chain is unusual.

2. What Is the Bug?
Part of Ghostscript's font loading is written in PostScript itself. A font is the file that describes the shapes of letters; a Type 1 font is one of the older font formats, and Ghostscript can load fonts supplied inside a document. One helper, .putgstringcopy, uses a very powerful internal operator called .forceput to write into protected areas. The problem: the helper never checked what it was handed.
Two ideas to unpack there. An operator is a built-in command of the PostScript language. .forceput is one that writes a value into a storage location even if that location is protected, which is exactly the kind of power the sandbox is meant to keep away from untrusted files. A type check is the simple guard that asks "is this value the kind of thing I expect?" before using it. The helper skipped that question.
1. Crafted Type 1 font → helper hits a type error2. File's own error handler takes over → recovers the privileged .forceput3. Use-after-free → attacker keeps a pointer to memory that gets freed4. Memory read/write → -dSAFER path checks switched off5. Command runs on the server
Line by line:
- Crafted Type 1 font → helper hits a type error. The attacker builds a font file designed to hand
.putgstringcopya value of the wrong kind. Because the helper never validated it, the operation fails with a type error, which is the language's way of saying "that is not a valid input for this operation". - File's own error handler takes over → recovers the privileged
.forceput. PostScript lets a program install its own error handler, a routine that runs when something goes wrong. The attacker's handler runs after the type error and, from that position, gets hold of the privileged.forceputoperator that the sandbox was supposed to keep out of reach. - Use-after-free → attacker keeps a pointer to memory that gets freed. With
.forceputin hand, the attacker arranges for a block of memory to be released while still holding a reference to it. That is the hotel key card. - Memory read/write →
-dSAFERpath checks switched off. Holding a working reference into freed memory, the attacker can read and change whatever is later placed there. That is enough to reach and disable the checks that implement the sandbox. - Command runs on the server. With the sandbox out of the way, the attacker's file causes a command to execute on the machine.
Back to the hotel: the memory is the room, the pointer is the old key card. Ghostscript gives the room back (frees it) but the attacker's card still works, so they can read and change whatever now lives there.

The fix (upstream commit "validate operands to .putgstringcopy") simply checks the operand types first, so the error path can no longer reach the privileged write. An operand is a value an operator works on; validating operands means confirming each one is the right type before doing anything with it. Upstream means the original authors of Ghostscript, as opposed to a Linux distribution that repackages it.
3. Attack Techniques
Disguised file (resume.jpg, really PostScript) ↓App or library checks the content and passes it to Ghostscript ↓Crafted Type 1 font → type error → .forceput recovered ↓Use-after-free → memory read/write ↓-dSAFER disabled → command runs as the service account
This is the same five stages as before, now with the delivery step on top. A file named resume.jpg is really PostScript. The application or library inspects the content and, recognising it as something Ghostscript can handle, passes it on. From there the crafted font triggers the type error, the privileged operator is recovered, the use-after-free gives memory access, the sandbox is disabled, and a command runs as the service account, which is the unprivileged user the server software runs under.
Three tricks make this dangerous:
- Disguise: the file can be named
.jpg,.pngor.pdf. Libraries look at the bytes, not the name. The bytes are the actual content of the file; the extension is only a label at the end of the filename, and labels can say anything. - Indirect reach: the attacker never talks to Ghostscript directly. Your app does it for them. This matters because you cannot firewall off a program that your own software calls on purpose.
- Zero or low access: several paths needed no login. In other words, some of the demonstrated routes worked for someone with no account at all.
Routes pwn.ai demonstrated:

The write-up presents these routes as a diagram rather than in text, so the picture is where they are shown.
The command runs as the account that renders the file (for example lp for printing or the web server user), so it is not instant root, but it is a solid foothold. Root is the all-powerful administrator account on Unix-like systems; a foothold is a first position on the machine from which an attacker can try to go further.
MITRE ATT&CK mapping: T1190 Exploit Public-Facing Application · T1566.001 Spearphishing Attachment (Roundcube route) · T1036.008 Masquerade File Type · T1059.004 Unix Shell
MITRE ATT&CK is a public catalogue of attacker techniques, each with an ID, used by defenders to describe and compare attacks. T1190 means attacking an application that is reachable from the internet. T1566.001 means a malicious attachment in a phishing email; the Roundcube route refers to the webmail product of that name, where an attachment preview could carry the file. T1036.008 means making a file look like a different type than it is. T1059.004 means running a Unix shell, the command interpreter on Linux.
Is one upload always a shell? Not necessarily. It depends on which libraries your app uses. Also, the public proof-of-concept only shows the core memory trick and fails on 10.08.0. Don't panic, but don't ignore it either.
A shell here means a command interpreter running on the server, the thing an attacker wants because it lets them type commands. The point of the note is that the published demonstration stops at the memory trick; it does not walk all the way to a shell on its own, and it does not work against the fixed version.
4. Who Is Affected?
Anything running Ghostscript before 10.08.0 that processes files from someone else.

⚠️Version trap: distros oftenbackportfixes, so an old-looking number like 9.55 can already be patched. Check your distro's advisory, not just
gs --version.
A distro (distribution) is the packaged form of Linux you install, such as Debian, Ubuntu or AlmaLinux. To backport a fix means to take the corrected code from a newer release and apply it to the older version the distribution ships, so the version number stays old while the flaw is gone. An advisory is the distribution's official notice saying which versions are fixed. gs --version is the command that prints the Ghostscript version number, and on its own it can mislead you.
WordPress closed its own upload path in 7.0.4 (CVE-2026-65640), but that is a different point in the same chain. You still need the Ghostscript fix. In other words, WordPress plugged the hole on its side of the pipe; the pipe itself still leads to a vulnerable Ghostscript.
5. Remediation
1. Update Ghostscript to 10.08.0 or your distro's patched build:
# Debian / Ubuntusudo apt update && sudo apt upgrade ghostscript# AlmaLinux / RHEL-familysudo dnf clean metadata && sudo dnf upgrade 'ghostscript*' libgs
Line by line:
# Debian / Ubuntuis a comment, ignored by the machine, marking the commands for Debian-family systems.sudoruns the command with administrator rights, which package installation needs.apt updaterefreshes the list of available package versions from the repositories, so the next command knows what is current.&&means "and then, only if the previous command succeeded".apt upgrade ghostscriptinstalls the newest available version of the Ghostscript package.# AlmaLinux / RHEL-familymarks the commands for the Red Hat family of distributions.dnf clean metadatathrows away cached package information, so nothing stale is used.dnf upgrade 'ghostscript*' libgsupgrades every package whose name starts withghostscript, pluslibgs, which is the shared library containing the same code. The quotes stop the shell from expanding the*itself, leaving the pattern fordnfto interpret.
2. Restart services that already loaded the old library (sudo dnf needs-restarting lists them). A running program keeps the copy of a library it loaded at start, so replacing the file on disk does not change the running process. needs-restarting reports which services are in that position.
3. Check containers and bundled copies. Patching the host does not patch a Ghostscript inside a Docker image or an app bundle. Rebuild those images. A container is a packaged, isolated environment holding its own copy of the software it needs, so it does not see the host's updated files. A Docker image is the template a container is built from; rebuilding it is how you get the new version inside.
4. Update WordPress to 7.0.4 or later as well.
6. Mitigation (If You Can't Patch Today)
There is no setting that removes the bug, because -dSAFER is the very thing being bypassed. All you can do is reduce how easily a file reaches Ghostscript:
- ImageMagick: block PostScript-type coders in
policy.xml:
<policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,EPSI,EPT,PDF,XPS}" />
This is one line of ImageMagick's configuration file. domain="coder" says the rule is about the modules that read and write particular file formats. rights="none" says those modules may not be used at all. pattern="{PS,PS2,PS3,EPS,EPSI,EPT,PDF,XPS}" lists the formats being blocked: the PostScript family (PS, PS2, PS3, EPS, EPSI, EPT), PDF, and XPS, a Microsoft page-description format. The effect is that ImageMagick refuses to hand these formats to Ghostscript, so a disguised upload cannot travel that route.
- CUPS: don't share print queues with untrusted networks, and require authentication. A print queue is a named destination on a print server that accepts jobs; if anyone on the network can send to it, anyone can send a file to the interpreter.
- Web apps: check the file's real type before thumbnailing, and turn off previews for document types you don't need. Checking the real type means inspecting the content, not trusting the extension.
- Hardening: in one pwn.ai test, an AppArmor profile stopped the hijacked interpreter from starting a shell. Hardening means adding restrictions that reduce what a compromised program can do. AppArmor is a Linux feature that confines a program to a listed set of allowed actions; here the profile prevented the hijacked Ghostscript from launching a shell.
These only narrow the exposure. Patching is the real fix.

For Blue Teamers: What to Watch
A blue team is the defensive side of security, the people who monitor and protect systems. Logs are the records programs and the operating system keep of what happened.
gsspawningsh,bash,curlorwget. The chainphp-fpm/apache → convert/magick → gs → shshould never happen.gsis the Ghostscript program,shandbashare shells, andcurlandwgetare tools for downloading things. Spawning means starting another program as a child process.php-fpmandapacheare web server software,convertandmagickare ImageMagick's commands. In normal operation Ghostscript draws a preview and exits; it has no reason to start a shell or download anything.- Ghostscript crashes (segfaults) right after an upload. A segfault is the operating system killing a program because it touched memory it was not allowed to, which is exactly what a memory bug can cause.
- Uploads where the extension says
.jpgbutfilesays PostScript.fileis a standard command that reports what a file really is by looking at its content. - Anonymous print jobs from unknown IPs. An IP address identifies a machine on a network; an anonymous job is one sent without credentials.
A Wazuh/auditd rule on execve where the parent process is gs is a quick win. Wazuh is an open-source monitoring platform and auditd is the Linux auditing service. execve is the system call the operating system uses whenever a program starts another program, so watching it records every process launch. The parent process is the one doing the launching. A rule that alerts when the parent is gs catches the moment Ghostscript tries to start something, which it should never do.
30-Second Self-Check
- Does any site or app of yours accept files from strangers (resume, photo, PDF)?
- Does it make a thumbnail, preview or resize?
- Do you know which copy of Ghostscript it uses?
If you answered yes, yes, no, check it today. The third question is the one people fail: the copy inside a container or an application bundle is easy to forget.
Conclusion
Upload2Shell shows that the dangerous code is often not the one you wrote, but the quiet helper three layers below your app. A single forgotten type check turned a trusted sandbox into an open door.
Patch Ghostscript, check your containers, and treat every uploaded file as untrusted, even when it says .jpg.
Glossary
- Advisory: a vendor's or distribution's official notice describing a flaw and which versions fix it.
- AppArmor: a Linux feature that restricts a program to a listed set of allowed actions.
- auditd: the Linux service that records security-relevant events such as program launches.
- Backport: applying a fix from a newer release to an older version, so the version number stays old while the flaw is gone.
- Blue team: the defensive side of security, responsible for monitoring and protecting systems.
- Bytes: the actual content of a file, as opposed to its name or extension.
- Container: a packaged, isolated environment with its own copy of the software it runs.
- CUPS: the standard printing system on Linux and other Unix-like systems.
- CVE: a public catalogue number for a known security flaw.
- CVSS: a scoring system for the severity of a flaw, from 0 to 10.
- Distro (distribution): a packaged form of Linux, such as Debian, Ubuntu or AlmaLinux.
- Docker image: the template a container is built from.
- Error handler: a routine a program installs to run when an operation fails.
- execve: the system call the operating system uses whenever one program starts another.
- Foothold: a first position on a machine from which an attacker can try to go further.
- Font: a file describing the shapes of letters; a Type 1 font is one of the older formats.
- Ghostscript: a program and library that reads PDF and PostScript and turns them into images or previews.
- Hardening: adding restrictions that reduce what a compromised program can do.
- ImageMagick: a common tool and library for converting and resizing images.
- libvips: an image processing library used by other programs.
- Library: software that other programs load and call, rather than something you start yourself.
- Logs: records that programs and the operating system keep of what happened.
- MITRE ATT&CK: a public catalogue of attacker techniques, each with an ID.
- Operand: a value that an operator works on.
- Operator: a built-in command of a programming language;
.forceputis a privileged PostScript operator that writes into protected storage. - Parent process: the process that starts another process.
- Pillow: an image processing library for Python.
- Pointer: the address of a block of memory, used by a program to refer to it.
- Proof-of-concept (PoC): demonstration code showing a flaw working.
- PostScript: a programming language for describing pages, which means a PostScript file is a program to run.
- Print queue: a named destination on a print server that accepts print jobs.
- Root: the all-powerful administrator account on Linux.
- Sandbox: restrictions around a program so that malicious input cannot do much harm; Ghostscript's is
-dSAFER. - Segfault: the operating system killing a program because it touched memory it was not allowed to.
- Service account: the unprivileged user that server software runs under.
- Shell: a command interpreter, the thing an attacker wants on a server because it lets them type commands.
- Spawning: starting another program as a child process.
- Type check: a guard that confirms a value is the kind of thing expected before using it.
- Upstream: the original authors of a piece of software, as opposed to a distribution that repackages it.
- Use-after-free: a memory bug where a program keeps a reference to memory it has already released, and later reads or writes through it.
- Wazuh: an open-source monitoring platform.
- WordPress: site-building software that runs a large share of the web and can generate thumbnails for uploads.