Tag: T1036.008

Detecting Upload2Shell: 5 Sigma rules for Ghostscript shells and disguised uploads

Detecting Upload2Shell: 5 Sigma rules for Ghostscript shells and disguised uploads

Upload2Shell has no IOCs. No IP addresses, no hashes, no file names you can grep for. pwn.ai published a proof of concept on November 21, 2026 that turns a disguised PostScript file into commands running as www-data or lp, and the only artefacts it mentions are what its own proofs left behind: a marker file in /var/tmp on the print server and a PHP file on the WordPress test, with no path given. If you want to know whether someone tried this on your servers, you have to watch behaviour.

The good news is that the behaviour is unusually clean. Ghostscript is a document renderer, and a renderer that starts a shell or opens a network socket has stopped rendering. This post is the detection companion to my analysis of the bug: five Sigma rules, what each one catches, how to tune it and how to test it without an exploit.

At a glance

  • Rules: 5 (two high, two medium, one low hunting rule), all status: experimental.
  • Domains: Linux (four rules) and Network (one rule).
  • Log sources: Linux process creation, network connection and file creation (Sysmon for Linux, auditd or EDR), plus the Zeek HTTP log.
  • ATT&CK: T1059.004 Unix Shell, T1190 Exploit Public-Facing Application, T1105 Ingress Tool Transfer, T1036.008 Masquerade File Type.
  • CVEs: CVE-2026-125396 (Ghostscript), CVE-2026-65640 (WordPress upload path).
  • YAML: my Detection Rules repo on GitHub, folders Linux and Network.

The case in brief

An attacker uploads a file named like an image or a PDF that actually contains PostScript. It might come through a WordPress upload field, as a Roundcube attachment or as an anonymous IPP print job to a shared CUPS queue. ImageMagick and Pillow pick a decoder by content, libvips reaches Ghostscript through its magickload (ImageMagick) loader, and on the IPP path CUPS hands the job to Ghostscript through its gstopdf filter. Either way, the file lands in Ghostscript. The use-after-free in the Type 1 font loader switches off -dSAFER, and the document’s code runs as whichever account called Ghostscript. pwn.ai saw uid=33(www-data) for web apps and Roundcube, uid=7(lp) for CUPS, roundcube_sysuser on Plesk and uid 1000 inside a Mayan EDMS container. The full story is in the analysis.

That gives three places to look: the upload on the wire, the process tree on the host, and whatever the payload does next (a connection, a dropped file). pwn.ai describes no attacker post-exploitation beyond its proof artefacts, so everything past “a command runs” is my inference about what an attacker would do with a shell. That is why every rule here is experimental.

Detection map

Block diagram: Linux process creation, network connection and file creation logs plus the Zeek HTTP log feed five Sigma rules (PostScript upload posing as image or PDF, gs spawns shell or tool, renderer or CUPS filter child, gs network connection, temp-dir drops) mapped to T1190, T1036.008, T1059.004 and T1105, with print jobs, mail attachments and in-memory payloads marked as a gap.
Four log sources, five rules. Print and mail delivery and in-memory payloads stay outside Sigma.

Read it left to right. Host telemetry carries most of the weight: three of the four sources are Sysmon for Linux event types (or their auditd and EDR equivalents), and none of them is on by default on a typical web or print server. The Zeek rule is the only one that fires before any code runs, but it needs to see uploads in cleartext, which means a sensor behind your TLS terminator. The dashed box is what nothing here covers well: print jobs, mail attachments and payloads that never leave the Ghostscript process.

Rule overview

RuleDomainLog sourceATT&CK (tactic / technique)LevelStatus
Ghostscript spawning shell, interpreter or download toolLinuxlinux / process_creationExecution / T1059.004, Initial Access / T1190HighExperimental
Image converter, PHP or CUPS filter spawning suspicious child as service accountLinuxlinux / process_creationExecution / T1059.004, C2 / T1105MediumExperimental
Outbound network connection initiated by GhostscriptLinuxlinux / network_connectionC2 / T1105HighExperimental
Ghostscript or service account writing to temp directoriesLinuxlinux / file_eventC2 / T1105Low (hunting)Experimental
PostScript upload disguised as an image or PDFNetworkzeek / httpInitial Access / T1190, Defense Evasion / T1036.008MediumExperimental

The rules

Ghostscript spawning shell, interpreter or download tool

Context: this is the moment of compromise. Once -dSAFER is off, the obvious next move for a document is to open a pipe to a command, and Ghostscript does that by starting sh. SnapAttack’s 2024 write-up on CVE-2024-29510 showed exactly this tree (gs starting dash), and Splunk’s ESCU “Linux Ghostscript Exploitation” analytic alerts on gs parents with sh -c children. My rule uses the same idea with a broader child list. I wrote it independently and didn’t copy their search.

Condition: alert when the parent image is gs, gsc or ghostscript and the child is a shell, Python, Perl, Ruby, PHP, curl, wget, netcat, socat, telnet or openssl. Exclude it only if the gs command line itself carries a %pipe% output. The direction is what makes this work: callers starting gs is routine (ImageMagick’s delegates.xml defines its Ghostscript delegate as a shell-quoted command line), but gs starting a shell is not normal.

ATT&CK: Execution (TA0002) – T1059.004 Unix Shell; Initial Access (TA0001) – T1190 Exploit Public-Facing Application.

title: Ghostscript Spawning Shell, Interpreter or Download Tool - Potential -dSAFER Escape
id: 9a8d85d9-4f81-45f2-906b-1bf101ade773
status: experimental
description: |
    Detects a Ghostscript process (gs, gsc, ghostscript) starting a shell, script interpreter or network/download tool.
    A -dSAFER escape such as CVE-2026-125396 (Upload2Shell) ends with the interpreter running commands as the service
    account that called it (www-data, lp). Direction matters: callers starting gs is normal (ImageMagick runs it as a delegate command line), gs starting a shell is not.
references:
    - https://pwn.ai/upload2shell/research.html
    - https://www.cve.org/CVERecord?id=CVE-2026-125396
    - https://research.splunk.com/endpoint/580f99d8-a4c8-4ef1-9c84-f355867bca41/
    - https://github.com/ImageMagick/ImageMagick/blob/main/config/delegates.xml.in
    - https://netsec101.com/?p=476
author: netsec101.com
date: 2026-11-23
tags:
    - attack.execution
    - attack.t1059.004
    - attack.initial-access
    - attack.t1190
    - cve.2026-125396
logsource:
    product: linux
    category: process_creation
detection:
    selection_parent:
        ParentImage|endswith:
            - '/gs'
            - '/gsc'
            - '/ghostscript'
    selection_child_name:
        Image|endswith:
            - '/sh'
            - '/bash'
            - '/dash'
            - '/zsh'
            - '/ksh'
            - '/busybox'
            - '/perl'
            - '/ruby'
            - '/php'
            - '/curl'
            - '/wget'
            - '/nc'
            - '/ncat'
            - '/netcat'
            - '/socat'
            - '/telnet'
            - '/openssl'
    selection_child_python:
        Image|re: '/python[0-9.]*$'
    filter_optional_pipe_output:
        # Print setups that put an output pipe on the gs command line itself (for example -sOutputFile=%pipe%lpr)
        ParentCommandLine|contains:
            - '-sOutputFile=%pipe%'
            - '-sOutputFile=|'
    condition: selection_parent and 1 of selection_child_* and not 1 of filter_optional_*
falsepositives:
    - Print or conversion setups that pipe Ghostscript output to another command (the %pipe% device runs it through sh); keep the optional filter only where the pipe is on the gs command line, not in the document
    - Desktop or batch workflows that script Ghostscript with %pipe% output
level: high

View on GitHub

False positives and tuning: the real false positives come from Ghostscript’s %pipe% output device, which some print setups use to send output to lpr. That pipe runs through sh, so you get gs, then sh, then lpr. The optional filter drops those, but only when the pipe sits on the gs command line, where the caller put it. A malicious document opens its pipe from inside the PostScript, so the parent command line stays clean and the alert still fires. Don’t widen the filter to match on the child command line. On desktops, scripted gs workflows can trip it too. Scope to servers if that’s noisy.

How to test: on a lab box, run gs -dNOSAFER -dNODISPLAY -dBATCH -c "(%pipe%id) (w) file closefile". That turns off the sandbox on purpose and asks gs to pipe to id, which should log gs starting sh without any exploit. Don’t expect a tidy gs, sh, id chain: dash often execs a single command in place, so id may show up with gs as its parent instead of sh. The rule fires on the sh event either way.

Image converter, PHP or CUPS filter spawning a suspicious child as a service account

Context: rule one depends on a process actually named gs. That isn’t always the case. ImageMagick can be built against libgs and run Ghostscript inside its own process, Pillow and libvips sit inside Python or PHP workers, and a bundled copy in a container may carry another name. This rule looks one level up, at the processes that hand files to Ghostscript, and only when they run as the accounts pwn.ai saw: www-data, lp and roundcube_sysuser, plus the usual apache, nginx and http.

Condition: the parent is ImageMagick (convert, magick, mogrify, identify, montage), vips, Apache, PHP or PHP-FPM, Python, or anything under a CUPS filter directory. The user is one of the service accounts. The child is either a download or network tool, or a shell whose command line fetches something, opens /dev/tcp, decodes base64 or touches /dev/shm. Shells that carry -sDEVICE= are excluded: every Ghostscript delegate command in ImageMagick’s delegates.xml sets an output device, so a shell with that flag is a delegate call, not a payload. CUPS parents are handled separately and only match download or network tools.

ATT&CK: Execution (TA0002) – T1059.004 Unix Shell; Command and Control (TA0011) – T1105 Ingress Tool Transfer; Initial Access (TA0001) – T1190.

title: Image Converter, PHP or CUPS Filter Spawning Download Tool or Suspicious Shell as Service Account
id: 82a7bb2c-e41d-4241-8367-913ab6251b2a
status: experimental
description: |
    Detects ImageMagick, libvips, PHP, Python, web server or CUPS filter processes running as a web or print service account
    that start a download or network tool, or a shell whose command line fetches or opens a connection. Catches the Upload2Shell
    chain one level up, including builds where Ghostscript runs in-process (libgs). Inferred from the pwn.ai process context, not from incident data.
references:
    - https://pwn.ai/upload2shell/research.html
    - https://www.cve.org/CVERecord?id=CVE-2026-125396
    - https://www.patchstack.com/articles/when-a-png-isnt-a-png-wordpress-patches-an-author-level-imagick-rce/
    - https://github.com/ImageMagick/ImageMagick/blob/main/config/delegates.xml.in
    - https://netsec101.com/?p=476
author: netsec101.com
date: 2026-11-23
tags:
    - attack.execution
    - attack.t1059.004
    - attack.command-and-control
    - attack.t1105
    - attack.initial-access
    - attack.t1190
    - cve.2026-125396
logsource:
    product: linux
    category: process_creation
detection:
    selection_parent_web_name:
        ParentImage|endswith:
            - '/convert'
            - '/magick'
            - '/mogrify'
            - '/identify'
            - '/montage'
            - '/vips'
            - '/apache2'
            - '/httpd'
    selection_parent_web_versioned:
        ParentImage|re: '/(php-fpm[0-9.]*|php[0-9.]*|python[0-9.]*)$'
    selection_parent_cups:
        ParentImage|contains: '/cups/filter/'
    selection_user:
        User:
            - 'www-data'
            - 'apache'
            - 'nginx'
            - 'http'
            - 'lp'
            - 'roundcube_sysuser'
    selection_child_tool:
        Image|endswith:
            - '/curl'
            - '/wget'
            - '/nc'
            - '/ncat'
            - '/netcat'
            - '/socat'
            - '/telnet'
            - '/busybox'
    selection_child_shell:
        Image|endswith:
            - '/sh'
            - '/bash'
            - '/dash'
        CommandLine|contains:
            - 'curl '
            - 'wget '
            - '/dev/tcp/'
            - '/dev/udp/'
            - 'nc '
            - 'ncat '
            - 'socat '
            - 'base64 -d'
            - '/dev/shm/'
    filter_main_gs_delegate:
        # ImageMagick's gs delegate commands (delegates.xml) set -sDEVICE=; a shell carrying that is a delegate call, not a payload
        CommandLine|contains: '-sDEVICE='
    # CUPS filters are often shell scripts, so CUPS parents only match download/network tools, never shells
    condition: ((1 of selection_parent_web_* and 1 of selection_child_*) or (selection_parent_cups and selection_child_tool)) and selection_user and not filter_main_gs_delegate
falsepositives:
    - PHP or Python applications that legitimately shell out to curl or wget (update checkers, webhooks); exclude by full command line after a baseline
    - CUPS backends or custom filters that fetch resources over the network
    - Service accounts named differently on your distribution; extend the user list rather than removing it
level: medium

View on GitHub

False positives and tuning: this is the noisiest of the process rules, because PHP and Python apps do call curl, for update checks and webhooks. Baseline for a week and exclude by full command line, not by parent. The CUPS branch only matches download and network tools, never shells, because many CUPS filters are shell scripts and their ordinary children would drown you. If your distribution names its web user differently, add the name to the list. Don’t delete the user clause, or this turns into a generic web shell rule that fires all day.

How to test: sudo -u www-data php -r 'system("curl -s http://127.0.0.1/");' produces php, then sh with a curl command line, under the right user.

Outbound network connection initiated by Ghostscript

Context: a payload that lives inside the gs process, such as a reverse connection built from the memory primitive rather than a child shell, gets past both process rules. A renderer has no business opening sockets, so any connection from gs is worth a look. pwn.ai published no network indicators. This rule is pure inference from the bug class.

Condition: alert when gs, gsc or ghostscript initiates a connection to anything other than loopback.

ATT&CK: Command and Control (TA0011) – T1105 Ingress Tool Transfer.

title: Outbound Network Connection Initiated by Ghostscript
id: c8efc9fe-8344-4263-a90a-a5093c46df3c
status: experimental
description: |
    Detects a Ghostscript process (gs, gsc, ghostscript) initiating a network connection to a non-loopback address. A renderer
    that converts or thumbnails documents has no reason to talk to the network, so a connection suggests the interpreter is
    running attacker code after a -dSAFER escape such as CVE-2026-125396. Inferred from the bug class; pwn.ai published no network indicators.
references:
    - https://pwn.ai/upload2shell/research.html
    - https://www.cve.org/CVERecord?id=CVE-2026-125396
    - https://netsec101.com/?p=476
author: netsec101.com
date: 2026-11-23
tags:
    - attack.command-and-control
    - attack.t1105
    - cve.2026-125396
logsource:
    product: linux
    category: network_connection
detection:
    selection:
        Image|endswith:
            - '/gs'
            - '/gsc'
            - '/ghostscript'
        Initiated: 'true'
    filter_main_loopback:
        DestinationIp|cidr:
            - '127.0.0.0/8'
            - '::1/128'
    condition: selection and not filter_main_loopback
falsepositives:
    - Print servers where Ghostscript itself writes to a network printer socket configured on its command line; confirm which printer ports your print path uses and scope out those hosts and ports
level: high

View on GitHub

False positives and tuning: on most web hosts I’d expect it to stay silent. On print servers, check whether gs ever writes straight to a printer socket before you page anyone, and exclude those hosts and printer ports if it does. Which ports that means depends on your print path, so check rather than assume. Sysmon for Linux only logs network connections if your config includes event 3, so check that first.

How to test: a benign gs run seldom opens a socket itself (in the rule one test, the connection would come from the child). The easiest check is to replay a synthetic Sysmon event 3 with Image set to /usr/bin/gs into your SIEM and confirm the converted query matches.

Ghostscript or service account writing to temp directories

Context: the one concrete artefact pwn.ai mentions is a marker file its proof wrote under /var/tmp on the Debian print server (/var/tmp/GS_CUPS_PIPE_RCE). That name only tells you the proof ran, so I treat it as a lab artefact, not an indicator. The broader pattern is worth hunting, though: attackers who land as www-data or lp tend to stage things in world-writable temp directories.

Condition: match any of three things. First, gs writes into /var/tmp, /dev/shm or a /tmp file that isn’t one of its own scratch files or an ImageMagick temp file. I assumed the prefixes gs_ and magick- for those; check what your builds actually write before you trust the filter. Second, a web or print service account creates a script, shared object or binary-looking file in any of the three directories. Third, the PoC marker file shows up.

ATT&CK: Command and Control (TA0011) – T1105 Ingress Tool Transfer.

title: Ghostscript or Web/Print Service Account Writing Scripts or Unexpected Files to Temp Directories
id: fce501fb-70ab-4899-b2a0-1634140ed9cd
status: experimental
description: |
    Hunts for Ghostscript writing files in /var/tmp or /dev/shm, or outside its own scratch files in /tmp, and for web or print
    service accounts dropping scripts or binaries into /tmp, /var/tmp or /dev/shm. The pwn.ai proof wrote a marker file under
    /var/tmp on the Debian print server; that exact name is included as a lab and PoC artefact, not an in-the-wild indicator.
references:
    - https://pwn.ai/upload2shell/research.html
    - https://www.cve.org/CVERecord?id=CVE-2026-125396
    - https://netsec101.com/?p=476
author: netsec101.com
date: 2026-11-23
tags:
    - attack.command-and-control
    - attack.t1105
    - cve.2026-125396
    - detection.threat-hunting
logsource:
    product: linux
    category: file_event
detection:
    selection_gs_image:
        Image|endswith:
            - '/gs'
            - '/gsc'
            - '/ghostscript'
    selection_gs_path:
        TargetFilename|startswith:
            - '/tmp/'
            - '/var/tmp/'
            - '/dev/shm/'
    filter_gs_scratch:
        # Assumed prefixes, verify on your hosts: gs scratch files gs_, ImageMagick temp files magick-
        TargetFilename|startswith:
            - '/tmp/gs_'
            - '/tmp/magick-'
    selection_svc_user:
        User:
            - 'www-data'
            - 'apache'
            - 'nginx'
            - 'http'
            - 'lp'
            - 'roundcube_sysuser'
    selection_svc_path:
        TargetFilename|startswith:
            - '/tmp/'
            - '/var/tmp/'
            - '/dev/shm/'
    selection_svc_ext:
        TargetFilename|endswith:
            - '.sh'
            - '.py'
            - '.pl'
            - '.php'
            - '.elf'
            - '.so'
            - '.bin'
    selection_poc_marker:
        TargetFilename: '/var/tmp/GS_CUPS_PIPE_RCE'
    condition: (selection_gs_image and selection_gs_path and not filter_gs_scratch) or (selection_svc_user and selection_svc_path and selection_svc_ext) or selection_poc_marker
falsepositives:
    - Applications that point Ghostscript's TMPDIR or -sOutputFile into /var/tmp or /dev/shm; add that prefix to the filter
    - PHP applications that cache compiled templates or plugin files as .php under /tmp
    - Package or plugin installers running as www-data
level: low

View on GitHub

False positives and tuning: it’s a hunting rule at level: low for a reason. PHP apps cache templates as .php under /tmp, plugin installers run as www-data, and some apps point gs’s TMPDIR at /var/tmp. Review it weekly, add the prefixes your apps legitimately use, and don’t alert on it. Note that the User field depends on your Sysmon for Linux version and field mapping. With auditd you’ll match on uid instead.

How to test: sudo -u lp touch /var/tmp/test.sh.

PostScript upload disguised as an image or PDF

Context: this is the delivery trick, and the only rule that fires before any code runs. Patchstack’s analysis of the WordPress fix (CVE-2026-65640) shows the gap: WordPress picked the editor by file extension, while ImageMagick read the magic bytes. A file named .png or .jpg that starts with %!PS is almost never innocent on an upload form.

Condition: an HTTP POST or PUT whose request body Zeek identifies as application/postscript, with an uploaded file name ending in an image or PDF extension. Zeek records both in http.log as orig_mime_types and orig_filenames.

ATT&CK: Initial Access (TA0001) – T1190 Exploit Public-Facing Application; Defense Evasion (TA0005) – T1036.008 Masquerade File Type.

title: HTTP Upload of PostScript Content With an Image or PDF File Name - Upload2Shell Delivery
id: 7bd3de21-4aff-4be3-b42d-2244ebbee66c
status: experimental
description: |
    Detects an HTTP upload whose body Zeek's content sniffing identifies as PostScript (it starts with %!PS) while the uploaded
    file name ends in an image or PDF extension. This is the Upload2Shell delivery trick: ImageMagick and Pillow pick a decoder
    by content, so a .jpg, .png or .pdf full of PostScript reaches Ghostscript. Needs cleartext HTTP visibility (after TLS termination).
references:
    - https://pwn.ai/upload2shell/research.html
    - https://www.patchstack.com/articles/when-a-png-isnt-a-png-wordpress-patches-an-author-level-imagick-rce/
    - https://www.cve.org/CVERecord?id=CVE-2026-125396
    - https://netsec101.com/?p=476
author: netsec101.com
date: 2026-11-23
tags:
    - attack.initial-access
    - attack.t1190
    - attack.defense-evasion
    - attack.t1036.008
    - cve.2026-125396
    - cve.2026-65640
    - detection.emerging-threats
logsource:
    product: zeek
    service: http
detection:
    selection_method:
        method:
            - 'POST'
            - 'PUT'
    selection_mime:
        orig_mime_types|contains: 'application/postscript'
    selection_name:
        orig_filenames|endswith:
            - '.jpg'
            - '.jpeg'
            - '.png'
            - '.gif'
            - '.bmp'
            - '.tif'
            - '.tiff'
            - '.webp'
            - '.pdf'
    condition: all of selection_*
falsepositives:
    - Print, prepress or design portals where users upload EPS artwork under the wrong extension; scope to upload endpoints of apps that never accept PostScript
    - Zeek only fills orig_filenames when the multipart part carries a file name; drop selection_name for a broader, noisier hunt
level: medium

View on GitHub

False positives and tuning: design and prepress portals do get EPS artwork with the wrong extension, so scope the rule to upload endpoints of apps that never accept PostScript. Both fields are arrays in Zeek, so check how your backend handles contains and endswith on lists. The bigger limit is visibility: Zeek must see the request after TLS termination, so a sensor on the internet side of your load balancer sees nothing useful.

How to test: upload any benign EPS file renamed to test.jpg to a lab application behind your Zeek sensor.

Coverage and gaps

Step in the caseTacticTechniqueRuleCovered?
Disguised PostScript uploaded over HTTPInitial Access, Defense EvasionT1190, T1036.008PostScript upload disguised as image or PDFYes, with cleartext Zeek visibility
Anonymous IPP print job to shared CUPS queueInitial AccessT1190NoneGap: no content check in CUPS logs (my understanding, verify)
Disguised attachment in Roundcube or mail importInitial AccessT1190NoneGap: mail path not covered
gs escapes -dSAFER and runs a commandExecutionT1059.004Ghostscript spawning shell or toolYes
In-process libgs or renamed gs runs a commandExecutionT1059.004Renderer or CUPS filter childPartial: needs a suspicious child
Tool download or reverse connectionCommand and ControlT1105Ghostscript outbound connection, renderer childYes
Files staged in temp directoriesCommand and ControlT1105Temp-dir writes (hunting)Hunting only
PHP file written by the WordPress proofPersistenceT1505.003NoneGap: path not published
Payload that stays inside gs memoryn/an/aNoneGap

The two delivery paths I can’t cover in Sigma are print and mail. For CUPS, the practical control is configuration, not detection: require authentication on shared queues and watch /var/log/cups/access_log for Print-Job requests from hosts that never print. That’s a manual hunt: as far as I know, the access log tells you who printed, not what the file was, so check your own CUPS logs before relying on that. For mail, a gateway or Zeek files.log with MIME sniffing on SMTP can apply the same “PostScript posing as an image” logic. The WordPress proof wrote a PHP file, but pwn.ai doesn’t say where, so file integrity monitoring on the web root is the honest answer there. A payload that never leaves the gs process needs syscall-level telemetry (eBPF tools such as Falco or Tetragon) or, better, a seccomp or AppArmor profile that stops gs from calling execve or connect at all.

Deploying the rules

Grab the YAML from GitHub and convert it with sigma-cli. The Linux rules use Sysmon for Linux field names (Image, ParentImage, CommandLine, User), so either your data already uses those names or you add a small custom pipeline that maps them to auditd, ECS or your EDR schema. Converting without a pipeline, as below, keeps the Sysmon names. The Zeek rule uses native Zeek field names.

sigma convert -t splunk --without-pipeline proc_creation_lnx_ghostscript_spawns_shell_or_tool.yml
sigma convert -t lucene --without-pipeline net_connection_lnx_ghostscript_outbound_connection.yml
sigma convert -t lucene -p ecs_zeek_beats zeek_http_upload_postscript_disguised_as_image_or_pdf.yml

Check the converted queries by hand, especially the |re modifiers and the array fields, because backends treat both differently. Run every rule in alert-only mode for a week before it pages anyone, and use the lab tests above to prove each one fires in your SIEM rather than just compiles.

My take

This is one of the more detectable bugs I’ve written rules for, as long as you have process telemetry on the boxes that render files. That’s the catch. Thumbnailing workers, print servers and webmail hosts are exactly the machines that tend to get no EDR and no Sysmon, because nobody thinks of them as exposed. If you only do one thing, put process-creation logging on those hosts and turn on the gs-spawns-shell rule. It’s cheap, it’s quiet, and it will catch the next -dSAFER escape too, not just this one.

I’d also argue the best “detection” here is prevention that leaves a log. A seccomp or AppArmor profile that stops gs from executing anything turns a successful exploit into a denied syscall in the audit log, and that’s a better alert than any of my five rules. Ghostscript distributions could ship such a profile by default. Until they do, the process tree is your best bet.

Sources