Upload2Shell (CVE-2026-125396) - Ghostscript or ImageMagick Writes Web Shell, Script or Persistence File
Detects Ghostscript or ImageMagick (magick, convert, mogrify, montage, identify, including the Debian/Ubuntu versioned binaries such as convert-im6.q16 and magick-im7.q16hdri) creating or modifying a file that a document renderer should never write: server-side scripts (.php/.phtml/.phar/.jsp/.aspx/.cgi/.pl/.py/.sh), shared objects, SSH authorized_keys, cron and systemd units, shell profiles, or /etc/ld.so.preload. It also matches the /var/tmp/GS_CUPS_PIPE_RCE marker path from the public Debian CUPS proof chain, written by any process. After the Upload2Shell -dSAFER escape, Ghostscript can write files as the rendering account. In pwn.ai's WordPress renderer test it wrote a PHP file as www-data, which gives a persistent web shell. Equixly's guidance is to alert on gs processes run by a web, mail or print account that write outside their temporary directory. This rule also covers cases where Ghostscript is embedded as a library in ImageMagick, so the write is attributed to magick/convert instead of a separate gs process. Data source: file creation/modification events with process attribution (auditd, Sysmon for Linux EID 11, EDR) normalized to UDM. Validated with regex unit tests: 9 writer-process cases (including symlink-resolved IM6/IM7 binary names) and 10 target-path cases, all passing.
YARA-L
