Tag: T1105

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

Detecting SAP Portal JNDI injection CVE-2025-42884: 5 Sigma rules from request to shell

Detecting SAP Portal JNDI injection CVE-2025-42884: 5 Sigma rules from request to shell

CISA put CVE-2025-42884 in its Known Exploited Vulnerabilities catalog on November 20, 2026 and gave agencies until November 23. What it didn’t give anyone is something to search for. No IOCs, no request samples, no attacker infrastructure, no vulnerable parameter name. SAP’s note is behind a login, and I found no detection guidance from the researchers credited with the bug, though I couldn’t open their advisory. If you run SAP NetWeaver Enterprise Portal 7.50 and want to know whether somebody already used this on you, you’re hunting blind.

Not completely blind, though. JNDI injection is a well-understood bug class, and it has to touch a few things you can log. The background (what the bug is, why a 6.5 deserves RCE-class priority, what to patch) is in my analysis of the bug. This post is the detection side: five experimental Sigma rules, the telemetry they need, honest false-positive notes and the gaps none of them close.

At a glance

  • Rules: 5 (two high, three medium), all hunting heuristics built from the bug class, none from observed attacks
  • Domains: Web/App (two rules), Linux (two rules), Windows (one rule)
  • Log sources: reverse proxy or portal HTTP access logs with full query strings; host network connection events with process image (Sysmon event 3, Sysmon for Linux or EDR); Linux process creation with parent image
  • ATT&CK: T1190 Exploit Public-Facing Application; T1059.004 Unix Shell and T1105 Ingress Tool Transfer for the post-exploitation rule
  • Status: all experimental
  • YAML: Detection Rules repo on GitHub (Web-App, Linux and Windows folders)

The case in brief

The CVE record says an unauthenticated attacker can inject JNDI environment properties, or pass a URL that the portal uses during a JNDI lookup, and so reach “an unintended JNDI provider”. SAP scores the result as limited disclosure or modification of server information. Onapsis, which found the bug, claims more: according to Rescana’s summary of the Onapsis advisory, the lookup can be pointed at an attacker-run RMI registry and, with a usable gadget chain and no deserialization filter, end in code execution. I couldn’t verify that claim, and CISA says nothing about what the observed exploitation achieved. The analysis has the details.

That gives three moments to catch: the request (if the properties or URL travel in the query string), the callback from the portal’s Java server to the attacker’s provider, and, only if the RCE claim holds, a shell or download tool started by the Java process. Everything specific here (match strings, ports, process names) is my inference from the bug class. The one piece I could anchor in a source is the process name: WithSecure’s write-up of the 2025 NetWeaver attacks shows the SAP Java launcher as jstart.EXE under \usr\sap\<SID>\J00\exe\ on Windows. That the server process image is also jstart on Linux is my assumption; check it with ps on your own hosts before you rely on rules 3 and 5.

Detection map

Detection map: proxy and portal access logs, host network events and Linux process creation feed five Sigma rules (JNDI property in request, provider URL in request, Java server outbound LDAP or RMI on Linux and Windows, shell from Java server) mapped to T1190 and T1059.004/T1105, with POST bodies, odd ports and in-memory payloads marked as gaps.
Which telemetry feeds which rule, and what stays dark. All five rules are experimental hunting heuristics; no IOCs have been published.

Left to right: access logs feed the two request rules, host network events feed the Linux and Windows callback rules, and Linux process creation feeds the shell rule. The callback rules are the ones I trust most in principle, because a JNDI injection that works has to connect somewhere, however the request was encoded. The dashed box is what stays dark: injection in POST bodies or headers, callbacks on non-standard ports or over DNS, and any payload that never starts a process.

Rule overview

RuleDomainLog sourceATT&CK (tactic / technique)LevelStatus
JNDI environment property in SAP portal requestWeb/AppwebserverInitial Access / T1190HighExperimental
JNDI provider URL scheme in SAP portal requestWeb/AppwebserverInitial Access / T1190MediumExperimental
SAP Java server outbound LDAP or RMI to public IP (Linux)Linuxlinux / network_connectionInitial Access / T1190MediumExperimental
SAP Java server outbound LDAP or RMI to public IP (Windows)Windowswindows / network_connectionInitial Access / T1190MediumExperimental
Shell or download tool spawned by SAP Java server (Linux)Linuxlinux / process_creationExecution / T1059.004, Command and Control / T1105HighExperimental

The rules

JNDI environment property in SAP portal request

Context: the CVE text names “JNDI environment properties” as one of the two injection paths. In Java those properties have fixed, documented names that all start with java.naming.: the provider URL, the initial context factory, the object and URL factory packages, the security principal. If an attacker sends them in a GET request, the name has to appear in the query string.

Condition: alert when the request URI or query string contains java.naming., or its URL-encoded form java%2enaming. Sigma’s contains is case-insensitive, so %2E matches too. I put the stem in a second selection because some parsers keep the whole URI in one field.

ATT&CK: Initial Access (TA0001) – T1190 Exploit Public-Facing Application.

title: Potential CVE-2025-42884 Exploitation - JNDI Environment Property in SAP Portal Request
id: 06184bae-fd4a-4a75-896c-0af780ed4e0b
status: experimental
description: |
    Hunting heuristic for CVE-2025-42884: detects HTTP requests whose URI or query string carries a standard
    JNDI environment property name (java.naming.*), plain or URL-encoded. The CVE describes unauthenticated
    injection of JNDI environment properties into SAP NetWeaver Enterprise Portal. No IOCs or request samples
    are public, so the match strings are inferred from the bug class, not from observed attacks.
references:
    - https://cveawg.mitre.org/api/cve/CVE-2025-42884
    - https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2025-42884
    - https://support.sap.com/en/my-support/knowledge-base/security-notes-news/bulletin-2025.html
    - https://netsec101.com/?p=429
author: netsec101.com
date: 2026-11-22
tags:
    - attack.initial-access
    - attack.t1190
    - cve.2025-42884
    - detection.emerging-threats
logsource:
    category: webserver
detection:
    selection_query:
        cs-uri-query|contains:
            - 'java.naming.'
            - 'java%2enaming'
    selection_stem:
        cs-uri-stem|contains:
            - 'java.naming.'
            - 'java%2enaming'
    condition: 1 of selection_*
falsepositives:
    - Vulnerability scanners and authorised penetration tests probing for JNDI injection
    - Administrators testing JNDI or UME settings through the portal from an internal admin workstation (scope the rule to external or reverse-proxy traffic)
level: high

View on GitHub

False positives and tuning: I expect very few from outside. Scanners that probe for JNDI injection will hit it, and an administrator testing JNDI or UME settings through the portal might. Scope the rule to logs from your reverse proxy or to requests from outside your admin networks, and it should stay quiet enough for high. The blind spot is the request body: if the vulnerable endpoint takes these properties in a POST, access logs won’t show them, and you need WAF or reverse proxy body logging to see them.

How to test: send a harmless GET to a lab web server whose logs you ship, with ?test=java.naming.provider.url in the query, and confirm the alert. No exploit involved; the log line is the test.

JNDI provider URL scheme in SAP portal request

Context: the other injection path in the CVE is a URL used during the lookup. JNDI providers that matter for this bug class take ldap://, ldaps://, rmi://, iiop:// or dns:// URLs. Unlike Log4Shell, there is no ${jndi: wrapper here, so SigmaHQ’s Log4j rules, which match on the wrapper, won’t catch a bare provider URL. I borrowed the scheme list from SigmaHQ’s “Log4j RCE CVE-2021-44228 Generic” rule by Florian Roth; the logic is my own.

Condition: alert when the URI or query string matches one of those schemes followed by ://, with the colon and slashes plain, URL-encoded or double-encoded. The regex is case-insensitive. It does not match ordinary links such as http://ldap.example.com/.

ATT&CK: Initial Access (TA0001) – T1190 Exploit Public-Facing Application.

title: Potential CVE-2025-42884 Exploitation - JNDI Provider URL Scheme in SAP Portal Request
id: debb5055-ec28-4b73-bf08-4d7c766bba3d
status: experimental
description: |
    Hunting heuristic for CVE-2025-42884: detects HTTP requests whose URI or query string contains a
    JNDI-capable provider URL (ldap, ldaps, rmi, iiop, dns), plain, URL-encoded or double-encoded. The CVE
    says an attacker can pass a URL used during a JNDI lookup. No IOCs are public; the logic is inferred
    from the bug class and will also fire on Log4Shell-style spraying.
references:
    - https://cveawg.mitre.org/api/cve/CVE-2025-42884
    - https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2025-42884
    - https://netsec101.com/?p=429
author: netsec101.com
date: 2026-11-22
tags:
    - attack.initial-access
    - attack.t1190
    - cve.2025-42884
    - detection.emerging-threats
logsource:
    category: webserver
detection:
    selection_query:
        cs-uri-query|re|i: '(ldaps?|rmi|iiop|dns)(:|%3a|%253a)(/|%2f|%252f){2}'
    selection_stem:
        cs-uri-stem|re|i: '(ldaps?|rmi|iiop|dns)(:|%3a|%253a)(/|%2f|%252f){2}'
    condition: 1 of selection_*
falsepositives:
    - Internet-wide Log4Shell and JNDI scanners (expected background noise on any exposed web server; triage by response code and by outbound connections from the portal host)
    - Portal or UME administration pages that take an LDAP server URL as a parameter (usually POST bodies, which access logs do not record)
    - Redirect or deep-link parameters that legitimately embed an ldap:// URL (rare; allowlist by cs-uri-stem)
level: medium

View on GitHub

False positives and tuning: this is the noisy one. Any internet-facing web server still gets Log4Shell-style spraying, and much of it carries ldap:// URLs. Don’t page on every hit. Group by source IP and check whether the portal host connected out to the host named in the URL shortly afterwards: that correlation turns a scanner hit into an incident. Admin pages that take an LDAP URL usually send it in a POST body, which access logs don’t record. If the volume is high, drop the level to low and use it for hunting.

How to test: request ?ref=ldap%3A%2F%2Ftest.invalid%2Fx against a lab web server. The .invalid top-level domain never resolves, so nothing leaves your network.

SAP Java server outbound LDAP or RMI to public IP (Linux)

Context: a successful JNDI injection makes the server talk to a provider the attacker chose. For the RCE path Onapsis describes, that’s an RMI registry; for classic JNDI tricks, an LDAP server. Either way the connection starts from the SAP Java server process, and a portal has little reason to talk LDAP or RMI to the internet. This rule sees the callback regardless of how the request was encoded or whether it came in a body.

Condition: alert when jstart (or a java binary under /usr/sap/) opens a connection to a non-private IP on port 389 (LDAP), 636 (LDAPS), 3268 or 3269 (Active Directory global catalog) or 1099 (the default RMI registry port).

ATT&CK: Initial Access (TA0001) – T1190 Exploit Public-Facing Application. The callback is part of the exploit, so I map it there rather than inventing a C2 technique for it.

title: SAP NetWeaver Java Server Outbound LDAP or RMI Connection to Public IP - Linux
id: 7fd81d3d-f4d9-4b13-85b8-61f056e16923
status: experimental
description: |
    Hunting heuristic: detects the SAP NetWeaver AS Java server process (jstart, or a java binary under
    /usr/sap/) opening an outbound connection to a non-private address on an LDAP, LDAPS, global catalog or
    RMI registry port. A JNDI injection such as CVE-2025-42884 makes the server contact an attacker-chosen
    provider; this is that callback. Process names and ports are inferred, not from observed attacks.
references:
    - https://cveawg.mitre.org/api/cve/CVE-2025-42884
    - https://labs.withsecure.com/publications/netweaver-cve-2025-31324
    - https://netsec101.com/?p=429
author: netsec101.com
date: 2026-11-22
tags:
    - attack.initial-access
    - attack.t1190
    - cve.2025-42884
logsource:
    product: linux
    category: network_connection
detection:
    selection_img_jstart:
        Image|endswith: '/jstart'
    selection_img_java:
        Image|contains: '/usr/sap/'
        Image|endswith: '/java'
    selection_port:
        DestinationPort:
            - 389
            - 636
            - 1099
            - 3268
            - 3269
    filter_main_private:
        DestinationIp|cidr:
            - '10.0.0.0/8'
            - '172.16.0.0/12'
            - '192.168.0.0/16'
            - '127.0.0.0/8'
            - '169.254.0.0/16'
            - '100.64.0.0/10'
            - '::1/128'
            - 'fc00::/7'
            - 'fe80::/10'
    condition: 1 of selection_img_* and selection_port and not filter_main_private
falsepositives:
    - Portals configured against a directory hosted on public address space (cloud LDAP or a partner directory); add those destinations to a filter
    - Organisations that use public IP ranges internally; replace the private-range filter with your own internal ranges
level: medium

View on GitHub

False positives and tuning: the main one is a portal that really does use a directory on public address space, such as a cloud LDAP service or a partner directory. Add those destinations as a filter. If your company uses public IP ranges internally, replace the private-range filter with your own ranges. Attackers can use any high port, so also run a version without the port selection as a weekly hunt and stack the destinations. Without host telemetry, use firewall logs: outbound flows from portal IPs to non-allowlisted destinations.

How to test: you can’t safely make the SAP server do a JNDI lookup on demand, so replay a network connection event into a test index instead. Set the image to your real jstart path, destination port 389 and a documentation address such as 203.0.113.10.

SAP Java server outbound LDAP or RMI to public IP (Windows)

Context: the same callback idea for portals on Windows, which is where WithSecure saw jstart.EXE in the 2025 NetWeaver investigations. It needs Sysmon event 3 or an EDR that records the initiating process.

Condition: alert when jstart.exe (or java.exe under \usr\sap\) initiates a connection to a non-private IP on 389, 636, 3268, 3269 or 1099.

ATT&CK: Initial Access (TA0001) – T1190 Exploit Public-Facing Application.

title: SAP NetWeaver Java Server Outbound LDAP or RMI Connection to Public IP - Windows
id: f7521fb5-300b-4416-97d4-6fec90c317f9
status: experimental
description: |
    Hunting heuristic: detects the SAP NetWeaver AS Java server process (jstart.exe, or java.exe under
    \usr\sap\) initiating a connection to a non-private address on an LDAP, LDAPS, global catalog or RMI
    registry port. A JNDI injection such as CVE-2025-42884 makes the server contact an attacker-chosen
    provider; this is that callback. Process names and ports are inferred, not from observed attacks.
references:
    - https://cveawg.mitre.org/api/cve/CVE-2025-42884
    - https://labs.withsecure.com/publications/netweaver-cve-2025-31324
    - https://netsec101.com/?p=429
author: netsec101.com
date: 2026-11-22
tags:
    - attack.initial-access
    - attack.t1190
    - cve.2025-42884
logsource:
    product: windows
    category: network_connection
detection:
    selection_img_jstart:
        Image|endswith: '\jstart.exe'
    selection_img_java:
        Image|contains: '\usr\sap\'
        Image|endswith: '\java.exe'
    selection_net:
        Initiated: 'true'
        DestinationPort:
            - 389
            - 636
            - 1099
            - 3268
            - 3269
    filter_main_private:
        DestinationIp|cidr:
            - '10.0.0.0/8'
            - '172.16.0.0/12'
            - '192.168.0.0/16'
            - '127.0.0.0/8'
            - '169.254.0.0/16'
            - '100.64.0.0/10'
            - '::1/128'
            - 'fc00::/7'
            - 'fe80::/10'
    condition: 1 of selection_img_* and selection_net and not filter_main_private
falsepositives:
    - Portals configured against a directory hosted on public address space (cloud LDAP or a partner directory); add those destinations to a filter
    - Organisations that use public IP ranges internally; replace the private-range filter with your own internal ranges
level: medium

View on GitHub

False positives and tuning: same as the Linux version. Many Windows-hosted portals authenticate against Active Directory over 389 or 3268, but to internal addresses, which the private-range filter removes. If your domain controllers sit on public ranges, filter them by address. Some Sysmon configs drop network events for noisy processes, so check that yours doesn’t exclude jstart.exe.

How to test: replay a Sysmon event 3 with the image set to your jstart.exe path, Initiated true, destination port 1099 and destination 203.0.113.10.

Shell or download tool spawned by SAP Java server (Linux)

Context: this rule only matters if the RCE claim holds. If it does, whatever the attacker runs starts inside the Java server, and the first visible step is usually a shell, an interpreter or a download tool. SigmaHQ already has “Suspicious Child Process of SAP NetWeaver – Linux” (from Elastic’s idea, written for the 2025 Visual Composer attacks), but it keys on the IRJ web application directories, which suits web shells. A JNDI or deserialization payload runs in the server process itself, so I key on the parent image instead. Elastic’s “Suspicious Java Child Process” follows the same idea for any Java parent.

Condition: alert when jstart (or a java binary under /usr/sap/) starts sh, bash, dash, ksh, zsh, busybox, python, perl, curl, wget, nc, ncat or socat.

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

title: Shell or Download Tool Spawned by SAP NetWeaver Java Server Process - Linux
id: 6b5f1a48-c9b3-4966-980f-beed8b0a5a7e
status: experimental
description: |
    Detects the SAP NetWeaver AS Java server process (jstart, or a java binary under /usr/sap/) starting a
    shell, scripting interpreter or network/download tool. If a JNDI injection such as CVE-2025-42884 is
    chained into code execution (an Onapsis claim, unconfirmed), the payload runs as a child of the Java
    server. Complements the SigmaHQ CVE-2025-31324 rule, which keys on IRJ web-application paths instead.
references:
    - https://cveawg.mitre.org/api/cve/CVE-2025-42884
    - https://www.rescana.com/post/sap-netweaver-enterprise-portal-cve-2025-42884-jndi-injection-kev-patch-now
    - https://detection.fyi/sigmahq/sigma/emerging-threats/2025/exploits/cve-2025-31324/proc_creation_lnx_sap_netweaver_susp_child_process/
    - https://netsec101.com/?p=429
author: netsec101.com
date: 2026-11-22
tags:
    - attack.execution
    - attack.t1059.004
    - attack.command-and-control
    - attack.t1105
    - cve.2025-42884
logsource:
    product: linux
    category: process_creation
detection:
    selection_parent_jstart:
        ParentImage|endswith: '/jstart'
    selection_parent_java:
        ParentImage|contains: '/usr/sap/'
        ParentImage|endswith: '/java'
    selection_child:
        Image|endswith:
            - '/sh'
            - '/bash'
            - '/dash'
            - '/ksh'
            - '/zsh'
            - '/busybox'
            - '/python'
            - '/python3'
            - '/perl'
            - '/curl'
            - '/wget'
            - '/nc'
            - '/ncat'
            - '/socat'
    condition: 1 of selection_parent_* and selection_child
falsepositives:
    - SAP-delivered or custom jobs that run OS commands from the Java stack (for example scripts started through NetWeaver Administrator or a scheduler); baseline the CommandLine values for two weeks and filter them by exact match
    - Support engineers running OS diagnostics through SAP tooling
level: high

View on GitHub

False positives and tuning: some SAP shops run OS commands from the Java stack on purpose, through NetWeaver Administrator, a job scheduler or custom code. Run the rule silently for two weeks, list the command lines it catches and filter the legitimate ones by exact match, not by a broad contains an attacker could imitate. If the baseline is clean, keep it at high.

How to test: on a lab Linux host with Sysmon for Linux or EDR, copy /bin/bash to /tmp/test/jstart and run /tmp/test/jstart -c '/bin/sh -c id; true'. The trailing ; true stops bash from replacing itself, so /bin/sh becomes a real child of a process whose image ends in /jstart. Not on a production SAP host.

Coverage and gaps

Step in caseTacticTechniqueRuleCovered?
JNDI properties in requestInitial Access (TA0001)T1190JNDI environment property ruleYes, query string only
Provider URL in requestInitial Access (TA0001)T1190Provider URL scheme ruleYes, query string only
Injection in POST body or headersInitial Access (TA0001)T1190NoneGap: access logs don’t record bodies
Callback to attacker LDAP or RMIInitial Access (TA0001)T1190Linux and Windows callback rulesYes on standard ports; gap for high ports, IIOP, DNS
Information read or changedCollection / ImpactUnknownNoneGap: no telemetry for what the lookup returned
Possible RCE, shell or download on LinuxExecution (TA0002), C2 (TA0011)T1059.004, T1105Java server child process ruleYes
Possible RCE on a Windows hostExecution (TA0002)T1059.001 / T1059.003None of minePartly: SigmaHQ’s CVE-2025-31324 Windows rule covers IRJ paths only
In-memory payload, no new processExecution / PersistenceUnknownNoneGap: needs JVM-level or EDR memory telemetry

The biggest hole is that nobody has said which endpoint or parameter is vulnerable, or whether the payload goes in a GET or a POST. If it’s a POST, both web rules are blind and the callback rules carry the load. The second hole is the payload that never forks: code running in a JVM can do a lot without a shell. What would help: body logging at the reverse proxy or WAF for portal paths, deny-by-default egress on SAP Java hosts (every blocked callback becomes a firewall log line), and the NetWeaver default trace in your SIEM so naming exceptions from portal requests are searchable, a check SentinelOne’s entry also suggests. A published request sample would allow a proper Suricata signature.

For a quick retro-hunt before you deploy anything, the same strings work with grep over raw access logs:

grep -Eai "(ldaps?|rmi|iiop|dns)(:|%3a|%253a)(/|%2f|%252f){2}|java(\.|%2e)naming" \
  /path/to/reverse-proxy/access*.log /path/to/httpaccess/*.log

Deploying the rules

Grab the YAML from the GitHub repo and convert it with sigma-cli after installing the backend plugin for your SIEM. Pick a pipeline that matches each rule’s log source: the Windows rule works with the standard Windows pipelines, while the web and Linux rules need your own field mappings for cs-uri-query, cs-uri-stem, Image, ParentImage and DestinationIp. A few examples (I haven’t run these here; check the target and pipeline names against the sigma-cli plugins you have installed):

sigma convert -t splunk -p splunk_windows net_connection_win_sap_java_outbound_ldap_rmi_public.yml
sigma convert -t lucene -p ecs_windows net_connection_win_sap_java_outbound_ldap_rmi_public.yml
sigma convert -t kusto -p microsoft_xdr net_connection_win_sap_java_outbound_ldap_rmi_public.yml
sigma convert -t splunk --without-pipeline web_cve_2025_42884_sap_portal_jndi_property_in_request.yml

Check two things in the converted queries. The |re|i regex in the URL scheme rule needs a backend that supports case-insensitive regex; if yours doesn’t, lower-case the field first or expand the pattern. And the |cidr filters need the destination IP field mapped as an IP type, otherwise some backends silently match nothing. Run all five in alert-only mode for a week before anything pages a human.

My take

This bug is hard to detect well from the request side. Without a known endpoint or request sample, the web rules are educated guesses that catch lazy GET-based exploitation and plenty of scanner noise. The callback is where I’d put my effort. A portal server connecting to an unknown LDAP or RMI server on the internet is suspicious for this CVE, for the next JNDI bug and for Log4Shell-style payloads hitting any Java component on that box. If I could turn on only one rule, it would be the callback rule for whichever OS your portals run on, paired with an egress deny policy so the attack fails even when the alert is missed.

What I’d like from SAP is a log line. The fix validates request parameters; logging the rejected ones, with the parameter name, would give every customer a high-fidelity signal for free. Until then, if your portal was on the internet and unpatched at any point since November 11, 2025, the absence of alerts from these rules is weak evidence, and I’d treat it that way.

Sources