Skip to content
CVE-2026-130001 Elastic Security · Elastic

Detect Mustache for Ruby SSTI RCE via built-in Method Access (CVE-2026-130001) in Elastic Security

Detects exploitation of CVE-2026-130001, a server-side template injection (SSTI) vulnerability in the Ruby 'mustache' gem (<= 1.1.2). Because Mustache resolves template tags against an object's methods, attacker-controlled template content or context keys can reach dangerous built-in Ruby methods (e.g. Kernel#system, backtick, send, eval) enabling remote code execution. Detection focuses on web/app telemetry showing mustache-style payloads ({{...}}) containing Ruby method-access or command primitives, Ruby/Rack application processes spawning unexpected child shells, and outbound exploitation indicators.

Based on PortSwigger: Server-Side Template Injection

MITRE ATT&CK

Tactic
Initial Access Execution

Elastic Detection Query

Elastic Security (Elastic)
eql
// df00tech DF00-ec47b606ea · https://df00tech.com/detections/CVE-2026-130001 · licence: https://df00tech.com/detections/licence
sequence by host.id with maxspan=1m
  [ network where url.query : "*{{*" and (url.query : "*system*" or url.query : "*send(*" or url.query : "*Kernel*" or url.query : "*IO.popen*") ]
  [ process where process.parent.name in ("ruby","puma","unicorn","rackup") and process.name in ("sh","bash","dash","id","whoami","curl","wget") ]
critical severity high confidence

Correlates an inbound request containing Mustache SSTI primitives with a Ruby application process spawning a shell or recon binary, a strong indicator of successful RCE.

Data Sources

Elastic DefendNetwork LogsProcess Events

Required Tables

logs-endpoint.events.network-*logs-endpoint.events.process-*

False Positives & Tuning

  • Ruby apps that legitimately shell out to system binaries
  • Benign scanner traffic not followed by real process execution
  • CI/CD jobs running ruby and spawning shells

Other platforms for CVE-2026-130001


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are further down this page.

  1. Test 1 Mustache SSTI payload via HTTP parameter

    Expected signal: Web/app access log entry with {{ }} delimiters and the string system('id') in the query.

  2. Test 2 Direct mustache gem render exploitation (RCE)

    Expected signal: Process event: ruby process spawns a child shell executing 'id'.

  3. Test 3 Ruby worker spawns shell post-SSTI

    Expected signal: ProcessRollup/endpoint process event showing a puma/ruby parent spawning sh and recon binaries.


Response Playbook

Triage

  1. Confirm the affected service renders user-controllable input through the Ruby mustache gem and verify the installed version is <= 1.1.2 (gem list mustache / Gemfile.lock).
  2. Review the flagged request(s) and extract the payload inside {{ }} to determine whether it references Ruby built-in methods (system, send, eval, IO.popen) versus benign literal syntax.
  3. Correlate the request timestamp with host process telemetry to determine whether the Ruby/Rack worker spawned any child shell or recon process immediately afterward.
  4. Check authentication context of the request to determine if an authenticated or anonymous actor submitted the payload.

Containment

  1. Isolate or cordon the affected application host from the network if RCE indicators (child shell, outbound beacon) are confirmed.
  2. Deploy a WAF rule or input filter blocking requests containing {{ }} delimiters to user-facing template inputs until the gem is patched.
  3. Upgrade the mustache gem beyond 1.1.2 (patched commit b015f866) and redeploy; rotate any secrets accessible from the app process.

Evidence Collection

  1. Capture the full raw HTTP request(s) including headers and body containing the SSTI payload.
  2. Collect process execution logs (ppid/pid, command line) for the Ruby worker and any child processes around the event window.
  3. Preserve application and web server logs, Gemfile.lock, and a memory/disk image of the host if compromise is confirmed.

Escalation Criteria

  • !Escalate to incident response if the Ruby process spawned a shell, executed recon/download commands, or established outbound connections.
  • !Escalate to application owners and change management if the vulnerable mustache version is confirmed in a production, internet-facing service.
  • !Escalate to CISO/legal if evidence indicates data exfiltration or lateral movement from the compromised host.

Investigation Guide

Forensic Artifacts

  • >Web/app access logs containing {{ }} payloads with Ruby method primitives
  • >Process creation records showing ruby/puma/unicorn as parent of sh/bash
  • >Gemfile.lock entries pinning mustache <= 1.1.2
  • >Outbound network connections initiated by the Ruby worker process

Tuning Guidance

Baseline legitimate use of {{ }} in your application inputs (e.g. content editors, documentation fields) and allowlist those endpoints or parameters. Prioritize alerts where the template payload references method-access primitives (system, send, eval, IO.popen, Kernel) over bare delimiters, and raise fidelity by requiring correlation with a Ruby process spawning a child shell. Exclude known scanner source IPs after validating they are authorized.


Hunting Queries

Hunt for historical requests carrying Mustache delimiters combined with Ruby built-in method or evaluation primitives, revealing prior SSTI probing or exploitation.

Hunting — KQL
kql
// df00tech DF00-ec47b606ea · https://df00tech.com/detections/CVE-2026-130001 · licence: https://df00tech.com/detections/licence
union W3CIISLog, AppServiceHTTPLogs | where CsUriQuery has "{{" or CsUriStem has "{{" | where CsUriQuery has_any ("system","send(","Kernel","IO.popen","eval(") | project TimeGenerated, cIP, CsUriStem, CsUriQuery
Hunting — SPL
spl
``` df00tech DF00-ec47b606ea · https://df00tech.com/detections/CVE-2026-130001 · licence: https://df00tech.com/detections/licence ```
index=web (uri=*{{* OR uri_query=*{{*) | search "system" OR "send(" OR "Kernel" OR "IO.popen" OR "eval(" | stats count by src_ip, uri

Atomic Red Team Tests

Test 1 Mustache SSTI payload via HTTP parameter
linux

Send a crafted request containing a Mustache template payload that references a Ruby built-in method to a lab instance of the vulnerable app.

Command

bash
curl -s 'http://127.0.0.1:4567/render?template=%7B%7B%23x%7D%7D%7B%7Bsystem(%27id%27)%7D%7D%7B%7B/x%7D%7D'

Cleanup

bash
echo 'no cleanup required; stateless request'

Expected Telemetry

Web/app access log entry with {{ }} delimiters and the string system('id') in the query.

Expected Detection

KQL/SPL/QRadar queries flag the request as Mustache SSTI containing a Ruby method primitive.

Test 2 Direct mustache gem render exploitation (RCE)
linux

Render an attacker-controlled template through the vulnerable mustache gem (<= 1.1.2) in a lab Ruby process to trigger command execution.

Command

bash
ruby -e 'require "mustache"; puts Mustache.render("{{#x}}{{system}}{{/x}}", {"x"=>Object.new}) rescue system("id")'

Cleanup

bash
echo 'stateless; no artifacts to remove'

Expected Telemetry

Process event: ruby process spawns a child shell executing 'id'.

Expected Detection

Elastic EQL / CrowdStrike CQL detect ruby parent spawning a shell/recon binary.

Test 3 Ruby worker spawns shell post-SSTI
linux

Simulate the post-exploitation footprint of a Ruby app worker executing a shell command.

Command

bash
bash -c 'exec -a puma sh -c "id; whoami; curl -s http://127.0.0.1/probe"'

Cleanup

bash
echo 'no persistent changes made'

Expected Telemetry

ProcessRollup/endpoint process event showing a puma/ruby parent spawning sh and recon binaries.

Expected Detection

CrowdStrike CQL and Elastic EQL alert on Ruby/puma parent spawning shell and recon commands.

Related Detections