Upload2Shell (CVE-2026-125396) - Ghostscript Spawns Shell, Interpreter or Recon Tool
Detects a Ghostscript process (gs, gsc, gsx, gswin32c/gswin64c) launching a shell, a scripting interpreter, a network tool or a recon command. Upload2Shell (CVE-2026-125396, Ghostscript before 10.08.0) is a use-after-free in the Type 1 font loader (.putgstringcopy / .forceput). A crafted PostScript, EPS or PDF file uses it to clear the native path_control_active flag and the PermitFileWriting/LockFilePermissions controls, which turns off -dSAFER from inside the interpreter. It then opens a %pipe% file, which Ghostscript runs through popen(), so a /bin/sh -c child appears as the rendering account. pwn.ai demonstrated command execution as www-data (WordPress, Roundcube, MediaWiki, DokuWiki), lp (Debian 13 CUPS via an anonymous IPP Print-Job) and application container users. The file doesn't need a PostScript extension: a .jpg/.png whose bytes are PostScript reaches gs through ImageMagick or Pillow. Legitimate %pipe% printing is excluded only when the shell command is a bare lp/lpr call with no shell metacharacters (; | & ` $ ( ) < >), so a payload chained after a legitimate-looking lpr still alerts. Data source: Linux process telemetry (auditd execve, Sysmon for Linux, EDR) or Windows process creation normalized to UDM PROCESS_LAUNCH. This rule doesn't cover deployments where Ghostscript is linked into ImageMagick as a library and no gs process exists; use the companion file-write rule for those. Validated with regex unit tests: 7 parent-path cases, 10 child-path cases and 10 exclusion cases (including chained-payload bypass attempts), all passing.
YARA-L
