Back to overview

    Upload2Shell: when an image upload runs code – the Ghostscript flaw that is almost everywhere

    Almost nobody installs Ghostscript deliberately – it sits as a library in the upload, preview and print functions of almost every server application. That is exactly what makes Upload2Shell (CVE-2026-125396) dangerous: a PostScript document disguised as an image defeats the -dSAFER sandbox and runs commands. NVD rates it “local” – the pwn.ai discoverers show it remotely via an opened email, a print queue and a web form. Why an image upload is enough, why the OS update is not, and what remains when you never know all the paths.

    Published by NEOSEC
    GhostscriptUpload2ShellCVE-2026-125396Use-after-freeImageMagickLieferketteDatei-UploadRCEPatch-GapXIEMNIS2pwn.ai
    Share

    As of 24 November 2026.

    Few administrators deliberately installed Ghostscript. It is simply there – as a library that runs along when an image preview is generated, a PDF is converted, a file is printed. That very invisibility is what makes Upload2Shell (CVE-2026-125396) so awkward: a flaw in a tool embedded in almost every server application without ever appearing on the inventory.

    The discoverers at pwn.ai (with AI assistance, specifically GPT 5.6) found a use-after-free in Ghostscript’s Type 1 font loader. A crafted PostScript or PDF document uses it to defeat the -dSAFER sandbox – the protection meant to stop untrusted PostScript from reading files or executing commands – and makes Ghostscript run commands as the rendering process. Artifex fixed it on 8 September with Ghostscript 10.08.0; the technical details have been public since 21 November.

    Why an image upload is enough

    The clever part of the research is not the exploit but the path to it. Almost any application with a file upload can pass a file to Ghostscript without that being visible in the code. A PostScript file disguised as .png or .jpg is handled by its content, not its extension – and a routine function such as preview, thumbnail or crop suffices to hand it to the interpreter.

    The chain typically runs like this:

    Upload (disguised .jpg)
      → application calls ImageMagick / Pillow / libvips
      → library recognises PostScript by content
      → delegates to Ghostscript (-dSAFER)
      → font-loader use-after-free
      → sandbox disabled in memory
      → command runs as www-data / lp
    

    Anyone searching their own code for gs calls finds nothing – Ghostscript often runs as a library in the same process. The list of paths pwn.ai confirmed reads like a cross-section of the server landscape: WordPress Core (with its own CVE-2026-65640), CUPS on Debian 13, Roundcube, Plesk Obsidian, Mayan EDMS, MediaWiki, DokuWiki, ResourceSpace – plus countless more via Pillow and Imagick such as Gradio, InvokeAI, ComfyUI, Frappe/ERPNext, Home Assistant and Paperless-ngx. Even Google and Dropbox were reachable through their production pipelines.

    The local attack vector is misleading

    NVD rates the flaw CVSS 4.0 8.5 (High) with a local attack vector. That sounds like “only with access to the machine”. The researchers’ reality is different – three examples, all remote and unauthenticated:

    ServiceTriggerCommand runs as
    RoundcubeExternal email with a disguised PostScript attachment; the recipient only opens the message, no click on the attachmentwww-data
    CUPS (Debian 13)Anonymous IPP print job to an open network queuelp
    WordPress pluginSigned-out visitor uses a public upload field (Forminator, Essential Addons)www-data

    The local vector describes only the Ghostscript invocation itself. The attack surface is every application in front of it. For prioritisation that is the decisive point – and another example of why a score label does not capture the situation (see our assessment of Java4Shell). In our NEOSEC assessment we therefore rate the flaw operationally above the local vector.

    The recurring theme: the sandbox does not hold

    Upload2Shell is no slip but a long-known pattern. Back in 2019 Tavis Ormandy showed a -dSAFER bypass and noted that the concept of caging the PostScript interpreter with a switch does not work reliably enough. In mid-2024 Ghostscript flaws were actively exploited. The cause is structural: PostScript is a full programming language, and Ghostscript executes it. -dSAFER is not a kernel-backed syscall filter like seccomp but a set of checks inside the interpreter – and a memory bug in the interpreter can defeat exactly those checks. The maintainer puts it plainly in the fix: “it isn’t easy to undo 30 years’ worth of assumptions in the code.”

    In practice that means: relying on the sandbox alone was never enough. And: not rendering untrusted PostScript in the first place is the cleanest solution – only hardly anyone knows where exactly their applications do just that.

    What to do

    1. Update Ghostscript – everywhere. To 10.08.0 or the distribution backport. Crucially: including in container images and application bundles. A host update does not replace a separate Ghostscript shipped inside an image. This is the same “forgotten in the bundle” problem as with GitLab’s bundled Ruby.
    2. Find the indirect paths. Do not search for gs but for what happens after an upload: preview, thumbnail, metadata, document import, print conversion. Which services use ImageMagick, Pillow, libvips or CUPS?
    3. Reduce the attack surface. In ImageMagick’s policy.xml disable the PS/EPS/PDF coders where not needed; authenticate CUPS network queues; check file type by content and move the check before thumbnail generation.
    4. Apply application fixes. WordPress 7.0.4/6.9.7, current versions of Roundcube, Plesk, Mayan, MediaWiki, DokuWiki.
    5. Contain render accounts. The account rendering runs under (www-data, lp) should not be able to start a shell or have free egress.

    Detection – because you never know all the paths

    The honest position: you will not find every indirect Ghostscript path in your environment, let alone at service providers and in third-party container images. What remains is watching behaviour – regardless of which application the attack came through. In XIEM:

    • Process telemetry: a web or mail worker, a gs process, suddenly starting a shell, printf or a network tool – render processes never do that. Wazuh rule on atypical child processes of www-data, lp and other render accounts.
    • FIM: new files in /var/tmp, /tmp and in upload/scratch directories written by the render account; freshly placed PHP or script files in web roots.
    • Egress: a render or web worker opening outbound connections to destinations outside its known upstreams.

    The RCE path shown in the PoC uses Ghostscript’s %pipe% mechanism to issue a command – exactly what produces the conspicuous child process a behavioural rule catches.

    Context

    Upload2Shell is instructive for the Mittelstand for two reasons. First, supply-chain depth: the flaw sits several layers below the application a pentest examines – a test that stops at the upload handler does not see it. Second, the AI dimension: the same tooling that let pwn.ai find the bug in hours is available to attackers too, and since 21 November the full PoC is public – the patch gap from Surveil or else is already running.

    For entities subject to NIS2, Ghostscript thus belongs in vulnerability and supply-chain management under Article 21 – especially where nobody knew it was in use at all.

    Sources

    Affected products