# Upload2Shell: patch Ghostscript for CVE-2026-125396

> CVE-2026-125396 is a -dSAFER sandbox escape in Ghostscript before 10.08.0: a crafted PostScript or PDF file can run commands as the process that renders it. Researchers showed it through WordPress, Roundcube, CUPS, wikis and document systems. Upgrade to 10.08.0 or your distribution's fixed package, and keep untrusted files away from it.

Published 2026-11-22 by the CodeBeast Team · https://codebeast.ai/blog/ghostscript-upload2shell-vulnerability

A use-after-free in Ghostscript, tracked as CVE-2026-125396 and nicknamed [Upload2Shell](https://pwn.ai/upload2shell), lets a crafted PostScript or PDF file break out of the `-dSAFER` sandbox and run commands as whatever process renders it. Ghostscript sits behind ImageMagick, PDF thumbnailers, print servers and document pipelines, so the attack surface is any feature that turns an untrusted file into an image. The fix shipped upstream in [Ghostscript 10.08.0](https://ghostscript.com/releases/index.html) on 8 September 2026, and the CVE was published on 9 November, so most servers that have not taken a Ghostscript update since September are exposed.

## What the bug is

The researchers describe a use-after-free in Ghostscript's Type 1 font loader that lets a crafted document escape `-dSAFER`, change the interpreter's native path controls and run attacker-chosen commands. Debian's [security tracker](https://security-tracker.debian.org/tracker/CVE-2026-125396) gives the mechanism in more detail: in Ghostscript before 10.08.0, a crafted file triggers a type error in the `.putgstringcopy` procedure, a custom error handler regains access to the privileged `.forceput` operator, and a use-after-free across `save`/`restore` leads to arbitrary code execution.

`-dSAFER` is the mode every integration relies on to make it safe to render files you did not write. An escape from it turns "generate a thumbnail" into remote code execution.

## Who is exposed

The Upload2Shell page lists working paths through real applications. The preconditions vary a lot, and several need no login:

| Application | Path to Ghostscript |
|---|---|
| Debian 13 CUPS | Unauthenticated IPP Print-Job to a shared queue, reported as command execution as `lp` |
| Roundcube 1.7.2 | An attachment from an external sender is rendered when the recipient views the message (needs an ImageMagick delegate) |
| WordPress core | A user with `upload_files` (Author and above by default) on a site with Imagick and Ghostscript |
| Forminator 1.55.1 | A signed-out public PDF form that stores files in the Media Library |
| Essential Addons for Elementor Lite 6.7.0 | A signed-out Login/Register widget with an upload field |
| MediaWiki with PdfHandler | Anonymous PDF upload, where the site allows it |
| DokuWiki | Anonymous upload, with an optional ImageMagick backend |
| Mayan EDMS 4.11.5 | A configured mailbox that imports external attachments |
| ResourceSpace 11.0 | Authenticated upload or a valid upload-share link |

The researchers tested Ghostscript 10.05.0, 10.05.1 and 9.54.0 (the last as shipped in a Plesk stack), and report a Google production path that Google mitigated on 10 November.

The common thread is not the application. It is a server that hands a user-supplied file to ImageMagick, Imagick, a PDF previewer or a print filter, which in turn calls `gs`. Many teams have that path without knowing it, through a PHP `Imagick` call, a Python worker that makes PDF previews, or a container image that pulled in `ghostscript` as an ImageMagick dependency.

## Fixed versions

| Component | Fixed in |
|---|---|
| Ghostscript upstream | 10.08.0 (8 September 2026) |
| Debian 13 (trixie) | `10.05.1~dfsg-1+deb13u3` per the tracker's status table |
| Debian 12 (bookworm) | `10.0.0~dfsg-11+deb12u9` (security) |
| Debian forky and sid | `10.08.0~dfsg-2` |
| WordPress | 7.0.4, released 12 August 2026 as a security release |
| Roundcube | The release containing the fix for CVE-2026-114727, which restricts unsafe attachment image types before ImageMagick conversion |

Two caveats. Debian's tracker shows `+deb13u2` in one table and `+deb13u3` in another for trixie; take `u3` or later. For Ubuntu, the researchers point to [USN-8949-1](https://ubuntu.com/security/notices/USN-8949-1) (21 October 2026), but that notice lists CVE-2026-101258, CVE-2026-103226 and a font operand validation issue without a CVE number, not CVE-2026-125396 by name. Install its packages anyway (for example `10.06.0~dfsg-3ubuntu1.2` on 26.04 LTS and `10.02.1~dfsg1-0ubuntu7.10` on 24.04 LTS), then check Ubuntu's CVE page for this specific ID before closing the ticket.

The researchers say the WordPress fix is tracked separately as CVE-2026-65640 for 7.0.0 to 7.0.3 and 6.9.0 to 6.9.6. WordPress's own release listing confirms 7.0.4 as a security release but does not name the issue, so check the release post for the branch version you run. Patching WordPress or Roundcube narrows one path to Ghostscript; it does not patch Ghostscript. Do both.

## What to do

**1. Find every Ghostscript on hosts and in images.**

On a host (Debian/Ubuntu, then RHEL/Fedora), and inside a container image:

```sh
gs --version
dpkg -l | grep -E 'ghostscript|libgs'
rpm -qa | grep -i ghostscript
docker run --rm --entrypoint sh your-image -c 'gs --version 2>/dev/null || echo "no gs"'
```

Do not stop at `gs`. ImageMagick and some PDF libraries link `libgs` directly, so check for `libgs10` or `libgs9` packages too. Images built from `php:*`, `wordpress:*` or any base with `imagemagick` installed are worth checking first.

**2. Upgrade.** Take 10.08.0 or your distribution's fixed package, rebuild images that bundle Ghostscript, and redeploy. A patched host does nothing for a container image built in August.

**3. Cut the path for untrusted files.** If your application never needs to render PostScript, EPS, PDF or XPS uploads, tell ImageMagick so in `policy.xml`:

```xml
<policymap>
  <policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,PDF,XPS}" />
</policymap>
```

Check that it took effect with `magick -list policy` (or `convert -list policy` on ImageMagick 6). This blocks the most common delegate path while you patch and is a sensible default afterwards. If you do need PDF previews, run the conversion in a separate, unprivileged worker with no network access and no credentials in its environment.

**4. Close the print and mail paths.** Stop sharing CUPS queues on untrusted networks, and confirm IPP (port 631) is not reachable from the internet. For webmail, make sure attachment previews are patched or disabled.

**5. Look for signs of use.** The researchers made a public teaser on 25 September and the CVE has been public since 9 November. Review web server and application logs for unexpected PDF, PS or EPS uploads, unexpected child processes of `gs`, PHP-FPM or CUPS, and outbound connections from document-processing workers.

If you are working through several advisories this month, our [phpAfterShell](/blog/phpaftershell-php-session-vulnerability) and [nginx2root](/blog/nginx2root-nginx-vulnerabilities) posts cover the other common pieces of a PHP and WordPress stack.

## Open questions

- **Severity.** The Upload2Shell page gives no CVSS score. Several paths are unauthenticated remote code execution, so treat it as critical for internet-facing upload, mail and print services.
- **Plugin and application fixes.** Fixed versions for Forminator, Essential Addons, Mayan EDMS, ResourceSpace and the wiki integrations are not listed on the researchers' page. Updating Ghostscript is the fix that covers all of them.
- **The root cause description.** The researchers describe a Type 1 font loader bug and Debian describes a `.putgstringcopy` and `.forceput` chain. Both say the fix is in 10.08.0, which is what matters for patching.

## Sources

- [Upload2Shell (CVE-2026-125396) research page](https://pwn.ai/upload2shell) (updated 18 November 2026)
- [Ghostscript releases](https://ghostscript.com/releases/index.html)
- [Debian security tracker: CVE-2026-125396](https://security-tracker.debian.org/tracker/CVE-2026-125396)
- [Ubuntu security notice USN-8949-1](https://ubuntu.com/security/notices/USN-8949-1)
- [WordPress security releases](https://wordpress.org/news/category/security/)

## FAQ

### Which Ghostscript version fixes CVE-2026-125396?

Upstream Ghostscript 10.08.0, released on 8 September 2026, fixes it. On Debian, use `10.0.0~dfsg-11+deb12u9` on bookworm or `10.05.1~dfsg-1+deb13u3` on trixie. On other distributions, install the latest security update for the ghostscript and libgs packages and confirm the CVE is listed as fixed.

### Am I affected if I don't use Ghostscript directly?

Possibly. ImageMagick, PHP's Imagick extension, PDF thumbnailers and CUPS print filters all call Ghostscript to render PostScript and PDF. If your server turns user uploads, email attachments or print jobs into images or previews, check whether Ghostscript is installed underneath.

### Does updating WordPress fix Upload2Shell?

Updating WordPress to 7.0.4 or the fixed branch removes one path to Ghostscript, but it does not patch Ghostscript itself. Plugins with their own upload handling, and anything else on the server that renders files, can still reach the vulnerable code. Update Ghostscript as well.

### How can I block Upload2Shell before patching?

Disable the PS, EPS, PDF and XPS coders in ImageMagick's `policy.xml`, stop sharing CUPS queues on untrusted networks, and turn off attachment previews in webmail. These reduce exposure but are not a fix, so upgrade Ghostscript as soon as you can.
