Rorix Technologies
Engineering13 min read

Upload2Shell (CVE-2026-125396): Check and Fix Ghostscript

Upload2Shell lets a fake image run commands through Ghostscript. How to check servers, Docker and Render, patch it, and harden uploads.

CyberSecurityApplicationSecurityDevSecOpsWebSecurityDockerRenderGhostscriptNodeJSBackendDevelopmentSoftwareEngineering
Upload2Shell (CVE-2026-125396): Check and Fix Ghostscript
On this page19 sections

A user uploads a profile picture called avatar.jpg. Your code never touches Ghostscript, but your image library looks inside the file, sees a page-description program, and hands it to Ghostscript. With Upload2Shell, that one file can run commands on your server.

In this post, I explain what the bug is in plain words, how to check if you are affected (with commands), how to fix it on Linux, in Docker, and on Render, how to harden file uploads, and why a fix from September became urgent news in late November.

TL;DR

  • What: Upload2Shell (CVE-2026-125396) is a use-after-free memory bug in Ghostscript, the program that processes PostScript and PDF files. A crafted file can switch off Ghostscript's -dSAFER safety sandbox and run arbitrary commands as the user that processes it.
  • Who: Every Ghostscript version before 10.08.0 unless your distribution has backported the fix. You can be affected even if you never call Ghostscript directly, because ImageMagick, Imagick, Pillow, libvips, CUPS, and PDF preview or document conversion tools can invoke it based on file contents.
  • Upstream vs. distro versions: gs --version shows the upstream version number, but Linux distributions backport security fixes into older release numbers. Always check your OS package version alongside gs --version and restart long-running processes after upgrading.
  • Fix: Update Ghostscript to 10.08.0 or your distribution's patched package, rebuild Docker images (patching the host is not enough), and on Render redeploy any native-runtime service that has not deployed successfully since November 20, 2026, 20:00 UTC.
  • Status: Proof-of-concept code is public, but no attacks in the wild had been reported as of November 23, 2026, according to the Sophos Upload2Shell advisory.

How the Attack Flows

What Upload2Shell Is, in Plain Words

Three terms appear throughout discussions of this bug:

  • PostScript is a language for describing printed pages. Because a PostScript file is really a small program, opening or rendering it means running code.
  • Ghostscript is the open-source program from Artifex that reads PostScript and PDF files and turns them into images or other formats.
  • Sandbox (-dSAFER) is Ghostscript's locked room for untrusted code, intended to stop a document from reading/writing files arbitrarily or launching external commands.

Upload2Shell is a use-after-free bug meaning Ghostscript keeps using memory after it has been freed, allowing an attacker to place controlled data there. It sits in Type 1 font handling (gs_fonts.ps / .putgstringcopy calling the privileged .forceput operator without checking operand types). Researchers at pwn.ai showed how corrupting memory across `save`/`restore` lets an attacker disable -dSAFER native file-path checks in memory even when -dSAFER is present on the Ghostscript command line. Think of it like reaching behind a hotel safe and unplugging the lock so the door still looks shut while opening for anyone.

The uploaded file does not need a .ps or .eps extension. As AlmaLinux's advisory notes, image libraries can pass a file named .jpg, .png, or .pdf to Ghostscript if its bytes are PostScript. Commands execute with the permissions of whatever process renders the file (such as www-data or a worker user), exposing environment variables, database credentials, and multi-tenant data in a multi-tenant SaaS app.

Key Facts

  • CVE ID: CVE-2026-125396
  • Severity: Scored 8.5 High (CVSS 4.0) and 7.8 High (CVSS 3.1) by VulnCheck. Even though the vector lists "local" access, pwn.ai demonstrated remote exploitation paths through a CUPS print queue on Debian 13, Roundcube email thumbnails, and WordPress uploads.
  • Affected Versions: Ghostscript before 10.08.0 (unless patched via distribution backport).
  • Fixed Upstream: Ghostscript 10.08.0 released on GitHub on September 8, 2026 (Artifex bug 709684, upstream fix commit 1484854e). Note that Ghostscript's 10.08.0 versioned release notes displayed 2026-05-19, whereas the current News.html page lists September 8, 2026.
  • Research & PoC Notes: pwn.ai published its overview and technical write-up on November 21, 2026. Note that pwn.ai's public PoC demonstrated memory control rather than a full shell, while a third-party GitHub PoC with reverse-shell payloads was reported in a Red Hat Bugzilla comment (unverified in CSA's note). Research also reached services including Google, Dropbox, and others, with only the Google path tied to this CVE and others tied to separate Ghostscript bugs.
  • Related App CVEs: CVE-2026-65640 (WordPress Core) and CVE-2026-114727 (Roundcube).

Why You May Be Affected Without Knowing It

Most applications never invoke gs directly, yet their upload, media, or document pipelines can still reach it. In pwn.ai's testing, PostScript or EPS content reached Ghostscript via:

  • Pillow (Python): Image.open() alone only identifies the file, while operations such as load(), crop(), or thumbnail() invoked Ghostscript.
  • Imagick (PHP): Imagick::readImage() routed through ImageMagick's PostScript delegate to Ghostscript.
  • libvips: Certain builds routed through its ImageMagick loader (magickload), depending on how libvips was built.
  • CUPS & Document Tools: Print queues and PDF preview, thumbnail, or document conversion tools.

By contrast, pwn.ai reported that PHP GD, OpenCV, prebuilt Sharp, Jimp, Java ImageIO, and Go's standard image decoders did not start Ghostscript in their tests. That is encouraging for a Node.js or TypeScript backend using prebuilt Sharp, but you should still audit any worker that shells out to ImageMagick, generates PDF thumbnails, or calls a Python or document service.

Am I Affected? Practical Checklist

Run these checks across servers, container images, and CI build environments. Because distributions backport fixes into older upstream version numbers, always check both gs --version and your OS package manager.

1. Check Ghostscript and OS Package Versions

gs --version
# Debian and Ubuntu (shows package versions alongside upstream version)
dpkg -l | grep -E 'ghostscript|libgs'
# RHEL, AlmaLinux, CloudLinux, Amazon Linux, SUSE
rpm -q ghostscript libgs
# Alpine
apk info -v | grep ghostscript

2. Check Inside Docker Images

For images where the default entry point might interfere, override it directly with gs (note that the target image must contain Ghostscript):

docker run --rm --entrypoint gs <image> --version

If the image includes a shell and dpkg (such as Debian/Ubuntu images), you can also inspect installed packages inside the image:

docker run --rm --entrypoint sh <image> -c 'gs --version; dpkg -l | grep -E "ghostscript|libgs" || true'

3. Check ImageMagick and Imagick

magick -list format | grep -E 'PS|EPS|PDF|XPS'
convert -list delegate | grep -i gs
magick -list policy

(On ImageMagick 6, use convert -list format and identify -list policy.)

4. Check Pillow and libvips

python3 -c "from PIL import EpsImagePlugin; print(EpsImagePlugin.has_ghostscript())"
vips -l | grep -i magick

If Ghostscript is present and below the fixed version for your distribution, treat the service as exposed.

How to Fix It

Linux Packages by Distribution

  • Ubuntu releases covered by USN-8949-1 (16.04–26.10, including Ubuntu Pro/Legacy branches): Ubuntu's USN-8949-1, published October 21, 2026, includes a Ghostscript font-operand validation issue credited to Paulos Yibelo without a CVE number. The notice publishes fixed package versions, including 10.02.1~dfsg1-0ubuntu7.10 for Ubuntu 24.04 and 9.55.0~dfsg1-0ubuntu5.15 for Ubuntu 22.04. Ubuntu's CVE-2026-125396 tracker still showed "Needs evaluation" when checked on November 25, so describe the USN package update as relevant backport evidence rather than claiming Ubuntu's CVE tracker independently confirms the CVE as fixed.
  • Debian 13 (trixie): Fixed. Debian's CVE tracker lists 10.05.1~dfsg-1+deb13u2 as the fixed version; the tracker currently shows +deb13u3 in the release package status.
  • Debian 12 (bookworm): Fixed in 10.0.0~dfsg-11+deb12u9 through DLA-4914-1, as recorded in the Debian CVE tracker.
  • AlmaLinux 8, 9, 10: Fixed packages reached production repositories on November 23, 2026: ghostscript-9.27-20.el8_10.alma.1, ghostscript-9.54.0-19.el9_8.3.alma.1, and ghostscript-10.02.1-16.el10_2.3.alma.1. See the AlmaLinux advisory.
  • Amazon Linux: The Amazon Linux CVE tracker listed Amazon Linux 2 Core and Amazon Linux 2023 as "Pending Fix", while Amazon Linux 2027 Preview was listed as fixed on November 19, 2026 (ALAS2027-2026-379). Recheck the tracker before publishing or applying this status to a later date.
  • CloudLinux: Fixed packages are available through the stable AlmaLinux repositories for CloudLinux OS 8, 9.9, and 10. The fixed builds match AlmaLinux: 9.27-20.el8_10.alma.1, 9.54.0-19.el9_8.3.alma.1, and 10.02.1-16.el10_2.3.alma.1. CloudLinux OS 9.8 requires separate handling, and CloudLinux OS 7 ELS/7 Hybrid builds were still in preparation in the November 23 update. On CageFS systems, run cagefsctl --force-update after updating so users inside CageFS do not keep using the old Ghostscript copy. See the CloudLinux status update and CloudLinux guidance.
  • SUSE/openSUSE, Red Hat Enterprise Linux and Azure Linux: I could not confirm a current, CVE-specific fixed package status from the primary vendor advisories reviewed for this revision. Do not label these distributions fixed or vulnerable based only on a related Ghostscript update, a testing build, or an unverified third-party report. Check each vendor's live security tracker and package changelog for CVE-2026-125396.

Install the vendor-fixed package for your exact OS release, then restart long-running processes such as PHP-FPM and queue workers so processes with libgs already loaded do not keep running old code. Do not use an upstream version comparison alone to judge a backported package:

# Debian and Ubuntu
sudo apt-get update && sudo apt-get install --only-upgrade ghostscript
# AlmaLinux and dnf-based systems
sudo dnf clean metadata && sudo dnf upgrade 'ghostscript*' libgs
sudo dnf needs-restarting -s || true

Docker Images

Updating the host does not update Ghostscript inside existing container images or running containers - a document worker can keep running vulnerable code after the host package is upgraded. Pull a fresh base image, rebuild without cache, redeploy, and verify the new image:

docker build --pull --no-cache -t myapp .

If your base image does not yet include the patched package, add apt-get update && apt-get install --only-upgrade -y ghostscript (or the dnf / apk equivalent) to your Dockerfile, redeploy, confirm no stale containers remain, and run your version check against the built image.

Managed Platforms: Render and Others

  • Render: Render published its Upload2Shell advisory on November 23, 2026 ("Redeploy services that process untrusted files with Ghostscript or ImageMagick"). Render's native runtimes (covering Node.js/Bun, Python, Ruby, Go, Rust, and Elixir on Debian 12 bookworm) include ghostscript, imagemagick, and libvips. Render does not state the exact Ghostscript package version string in its advisory, and there is no deadline - only the November 20, 2026, 20:00 UTC deploy cutoff:
    1. Native runtime using Render's Ghostscript: If a service has deployed successfully at least once since November 20, 2026, 20:00 UTC, Render notes you are set; otherwise trigger a manual deploy of the latest commit. Check infrequently deployed background workers and cron jobs first.
    2. Docker services: Render does not patch your image; rebuild with a fixed Ghostscript and redeploy.
    3. Custom/vendored Ghostscript: Update that copy to 10.08.0 or later and redeploy.
  • Other Platforms: Heroku's October 22, 2026 stack update changelog moved heroku-22, heroku-24, and heroku-26 to Ubuntu builds matching USN-8949-1 (noting default buildpack apps do not need a redeploy, while container stack apps must rebuild). Check vendor advisories for Fly.io, Vercel, Railway, AWS, or GCP where applicable.

Application Updates

Update affected applications as well WordPress 7.0.4 (August 12, 2026, with backports such as 6.9.7) for CVE-2026-65640 and Roundcube 1.6.20 and 1.7.5 (October 19, 2026) for CVE-2026-114727 while still patching Ghostscript itself.

Hardening File Uploads

Patching Ghostscript resolves this vulnerability; these controls reduce risk from future parser flaws:

  1. Check real file types (magic bytes) before processing: Inspect actual file headers such as \x89PNG for PNG vs. %! for PostScript before thumbnailing or rendering. Checking after thumbnail generation lets the renderer parse untrusted input first.
  2. Restrict allowed formats: Pass explicit format allowlists where supported, such as Image.open(f, formats=["PNG", "JPEG", "WEBP"]) in Pillow.
  3. Disable unneeded Ghostscript delegates/coders in ImageMagick: If you do not need PostScript, EPS, or PDF processing via ImageMagick, add restrictions inside <policymap> in policy.xml (such as the pattern list tested by CloudLinux), restart PHP-FPM and workers, and verify with magick -list policy:

    <policymap>
      <policy domain="delegate" rights="none" pattern="gs" />
      <policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,EPSF,EPSI,EPI,EPT,PDF,EPDF,XPS,PCL,AI}" />
    </policymap>

    This breaks PDF/PS thumbnails if relied upon and does not stop direct Ghostscript invocations, so treat it as a stopgap alongside upgrading Ghostscript (since -dSAFER alone is not a complete defense).

  4. Isolate the renderer: Process untrusted files in a separate worker or container running as a non-root user with no access to secrets or the primary database, no outbound network access, a read-only filesystem except a temporary directory, strict CPU/memory/time limits, and AppArmor, SELinux, or seccomp (AppArmor blocked the shell in a pwn.ai Plesk test).
  5. Lock down print queues: Require authentication on shared CUPS queues.

The Patch Lag: Why a September Fix Became November News

  • July 27: pwn.ai finds the bug.
  • August 12: WordPress 7.0.4 addresses its path.
  • September 8: Ghostscript 10.08.0 ships with release notes stating only that it addresses a number of potential security issues.
  • Late September / October 21: Debian 13 and Ubuntu publish package updates; Ubuntu's USN-8949-1 includes the font-operand issue without assigning it a CVE number.
  • November 9: CVE-2026-125396 is published.
  • November 21: Full write-up and proof of concept are published.

Between the September 8 release and the November 9 CVE publication a span highlighted on oss-security by Alan Coopersmith and Jan Schaumann scanners had no CVE ID to match, and some advisory trackers still lagged even after patches shipped. Track component versions and maintain an SBOM per image so you can search exposure in minutes, rescan images when new CVEs land, and treat security releases in file parsers as urgent even when changelogs are brief.

Developer Checklist

  • Patch: Upgrade Ghostscript to 10.08.0 or your Linux distribution's fixed package, and restart long-running workers/daemons that hold libgs in memory.
  • Rebuild: Pull fresh base images and rebuild container images without cache (docker build --pull --no-cache) rather than relying on host updates alone.
  • Redeploy: Redeploy affected containers and platform services, including Render native runtimes not deployed since November 20, 2026, 20:00 UTC (especially background workers and cron jobs).
  • Verify: Confirm patched package/binary versions in every image and runtime (docker run --rm --entrypoint gs <image> --version plus OS package checks), and verify upload magic-byte checks and worker isolation.

    Key takeaways
  • You can run Ghostscript without knowing it. Uploads, thumbnails, PDF previews and print jobs are the paths.
  • It is fixed upstream in 10.08.0. Distros backport fixes into older version numbers, so check package versions, not just gs --version.
  • Hosts, containers and platform runtimes are patched separately. On Render, a redeploy after November 20, 2026, 20:00 UTC is the fix for native runtimes.
  • No attacks have been reported yet, but public exploit code means the window is closing.

References

Use the vendor advisory or security tracker for the exact package build installed on your system. Package versions can differ from upstream Ghostscript versions when vendors backport security fixes.

Work with Rorix

Need engineers who stay?

Dedicated developers at $3,500 per developer per month, working your backlog on 2-week sprints with a named technical lead.

Upload2Shell (CVE-2026-125396): Check and Fix Ghostscript