Skip to content

Upload2Shell CVE-2026-125396: How to Patch Ghostscript

By Bikram Bhujel

Ghostscript is one of those programs most people have never knowingly installed, yet it's on almost every Linux server that makes a thumbnail, previews a PDF or runs a print queue. That's why Upload2Shell, CVE-2026-125396, is getting so much attention this week. A crafted file uploaded to a WordPress form, attached to an email or sent to a shared printer can end up running commands on your server.

The researchers' own page is famously hard to read (the Hacker News thread mostly complained about the layout), so here's the short version: what's affected, how to check your Ghostscript version on the host and inside containers, how to update, and two hardening steps I'd apply even after patching.

Linux terminal running gs --version to check whether Ghostscript is patched against the Upload2Shell CVE-2026-125396 flaw

Quick answer

Upload2Shell (CVE-2026-125396) is a use-after-free in Ghostscript's Type 1 font loader that lets a crafted document escape the -dSAFER sandbox and run commands as the rendering user, often www-data. It's reachable through WordPress uploads, Roundcube thumbnails, shared CUPS printers and any app that converts PDFs or images with ImageMagick. Upstream fixed it in Ghostscript 10.08.0; Debian 13 and Ubuntu ship backported fixes. Update the package, rebuild Docker images that contain Ghostscript, restart the services, and block PostScript/PDF in ImageMagick's policy if you don't need it.

What Upload2Shell is

Ghostscript interprets PostScript and PDF. PostScript is a full programming language, so Ghostscript runs it inside a sandbox mode called -dSAFER that is supposed to block file and command access. According to pwn.ai's Upload2Shell page, a use-after-free in the Type 1 font loader lets a crafted document cross that boundary, change native path controls and execute commands as whatever user is rendering the file.

The nasty part is how the file gets to Ghostscript. Nobody types gs on a web server. It's called for you by ImageMagick when it converts a PDF, by WordPress when it builds a preview, by a print filter, or by a mail client making an attachment thumbnail. pwn.ai notes that files named .png or .jpg can still reach Ghostscript through image conversion, because ImageMagick looks at the content, not the extension.

Where it was confirmed

pwn.ai reported working command execution in these setups (their case studies and proofs weren't published yet when I wrote this):

ApplicationWho can send the fileRan as
Debian 13 CUPSAnyone who can send an IPP job to a shared queuelp
Roundcube 1.7.2External email sender, when the message is viewedwww-data
Forminator, Essential Addons for ElementorSigned-out visitor using a public upload formwww-data
WordPress coreUsers with upload_files (Author and up by default)www-data
MediaWiki, DokuWikiAnonymous uploads, where the wiki allows themwww-data
Mayan EDMS, ResourceSpace, Plesk (Roundcube)Email or upload into the document pipelineapp or worker user

The CVE was published on 9 November and the write-up followed on 17 November, but the fix itself is older. Artifex released Ghostscript 10.08.0 on 8 September, Debian shipped a fixed Debian 13 build in October, and Ubuntu published USN-8949-1 on 21 October. If you've been patching regularly, you may already be covered. Containers are a different story.

Step 1: Find Ghostscript on the host

gs --version
# Debian / Ubuntu: which package build you actually have
dpkg -l | grep -E 'ghostscript|libgs'
apt changelog libgs10 2>/dev/null | grep -i -E 'CVE-2026-125396|709684' | head
# RHEL family
rpm -q ghostscript && rpm -q --changelog ghostscript | grep -i CVE-2026-125396

Upstream builds are fixed from 10.08.0. Distribution builds keep older version numbers with the fix backported. On Debian 13 the fixed security build is 10.05.1~dfsg-1+deb13u3 or later. For Ubuntu, check that your package is at or above the version listed in USN-8949-1 for your release.

Patch status still varies by vendor. As of 21 November, some distributions (Amazon Linux among them, according to reports) still listed the fix as pending, so check your vendor's tracker rather than assuming.

Step 2: Find Ghostscript inside your containers

This is where most homelabs and small hosting setups are exposed. Updating the host does nothing for a container that ships its own Ghostscript.

for c in $(docker ps -q); do
  v=$(docker exec "$c" sh -c 'gs --version 2>/dev/null')
  [ -n "$v" ] && echo "$(docker inspect -f '{{.Name}}' "$c"): Ghostscript $v"
done

Typical hits are WordPress images with Imagick, Nextcloud with preview providers, document managers like Paperless or Mayan, and mail stacks with webmail. For each one, pull the maintainer's newer image or rebuild your own Dockerfile so it picks up the patched package.

Step 3: Update and restart

# Debian / Ubuntu
sudo apt update && sudo apt install --only-upgrade ghostscript 'libgs*'
# RHEL family
sudo dnf upgrade ghostscript

# restart whatever renders files
sudo systemctl restart cups php*-fpm apache2 2>/dev/null

# containers
docker compose pull && docker compose up -d

PHP-FPM and Apache workers that loaded Imagick keep the old library in memory until they restart, so don't skip that line. Also update WordPress itself to the latest release in your branch: WordPress shipped its own related fix, CVE-2026-65640, and pwn.ai lists 7.0.0 to 7.0.3 and 6.9.0 to 6.9.6 as affected. Roundcube hardened its image resizing under CVE-2026-114727.

Step 4: Hardening I'd keep even after patching

Ghostscript has a long history of sandbox escapes. One commenter on Hacker News put it simply: PostScript is its own programming language, and running untrusted code is risky. So reduce how often untrusted files reach it at all.

Block PostScript and PDF in ImageMagick if you don't need them

Find the policy file with convert -list policy (or magick -list policy on ImageMagick 7), usually /etc/ImageMagick-6/policy.xml. Inside <policymap>, add:

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

Then restart PHP-FPM or your web server. The catch: PDF thumbnails stop working. On a simple blog that's fine; on a document management system it isn't, so decide per server.

Stop sharing printers you don't need to share

The CUPS route needed a shared print queue. If the box isn't a print server for other machines, turn sharing off:

sudo cupsctl --no-share-printers
sudo systemctl restart cups

How to roll back

Package updates for this are plain security fixes, so rolling back isn't something I'd plan for. If a PDF workflow breaks after you edit ImageMagick's policy.xml, remove the line you added and restart the web server. If a container misbehaves after the update, set its previous image tag in the compose file and run docker compose up -d, but treat that as a few hours of breathing room, not a place to stay.

A few things I learned

  • "I don't use Ghostscript" is usually wrong. ImageMagick, WordPress, CUPS and webmail call it for you.
  • The fix shipped months before the CVE. Regular patching already covered many hosts; old container images didn't get it.
  • File extensions don't protect you. A file called photo.jpg can still be handed to Ghostscript.
  • Least privilege limits the damage. Commands ran as www-data or lp, not root, which is exactly why services shouldn't run as root.

If you run WordPress, my post on WordPress CVE-2026-119977 is worth a read too. For containers, Docker says healthy but traffic still fails covers another trap I fell into, and Homelab Intelligence shows how my own stack is laid out. If you'd like someone to audit your servers for this kind of thing, see my server security services.

Frequently asked questions

What is Upload2Shell CVE-2026-125396?

Upload2Shell is a use-after-free in Ghostscript's Type 1 font loader. A crafted document can escape Ghostscript's -dSAFER sandbox and run commands as the user rendering the file. It can be reached through file uploads, email thumbnails, PDF previews and shared CUPS printers. It is fixed in Ghostscript 10.08.0 and in patched distribution packages.

Which Ghostscript version fixes Upload2Shell?

Upstream Ghostscript 10.08.0, released on 8 September 2026, fixes it. Distributions backport the fix into older version numbers: Debian 13's fixed build is 10.05.1~dfsg-1+deb13u3, and Ubuntu shipped fixes in USN-8949-1. Check your package changelog for CVE-2026-125396 rather than relying on the version number alone.

Is WordPress affected by Upload2Shell?

Yes, when the server has Imagick and Ghostscript installed. Users with the upload_files capability, Authors and above by default, could reach the vulnerable renderer, and some plugins with public upload forms exposed it to anonymous visitors. Update Ghostscript, update WordPress to the latest release in your branch, and update upload form plugins.

Do I need to update Docker containers for Upload2Shell?

Yes. A container with its own Ghostscript is not fixed by updating the host. Check each container with docker exec and gs --version, then pull the maintainer's updated image or rebuild your own image so it installs the patched Ghostscript package, and recreate the container.

How can I block Ghostscript in ImageMagick?

Edit ImageMagick's policy.xml, usually in /etc/ImageMagick-6, and add a coder policy with rights none for PS, PS2, PS3, EPS, PDF and XPS. Restart PHP-FPM or the web server afterwards. This stops ImageMagick handing those formats to Ghostscript, but PDF thumbnails will stop working.

Comments

Questions and corrections are welcome. I read every comment before it appears, and remove spam and promotional links.