Mustache for Ruby ≤1.1.2: Template-Only RCE Bypasses "Logic-Less" Safety Assumption
A GitHub Security Advisory (GHSA-5hrj-7fc3-cmx9) discloses a critical remote code execution flaw in the mustache RubyGem. It affects all versions up to and including 1.1.2. According to the advisory, the library fails to properly restrict access to built-in Ruby methods. Chaining several of these methods inside an attacker-supplied template string is enough to achieve arbitrary code execution. The maintainer states this requires no special configuration or application-supplied objects. Control over the template string alone is sufficient. The advisory was assigned a CVSS score of 9.8 and lists exploit status as PoC-public. The maintainer has so far withheld full payload details, citing a disclosure window to allow patching before publishing proofs of concept.
Why It Matters
Mustache is often recommended as a logic-less, safer alternative to template engines prone to server-side template injection (SSTI). This advisory undercuts that assumption. Any Ruby application that renders a Mustache template built from untrusted input is a candidate for full RCE with no authentication or user interaction required. That includes user-editable templates, email or notification templates, CMS content, and multi-tenant customization features. The maintainer notes the discovered payloads were found with a "fairly primitive" search approach. Those payloads include a universal RCE for a major Ruby version, three file-upload-to-RCE chains, and two denial-of-service variants. The advisory also states that application- or gem-provided methods could expand the attack surface further. Treat the current public payload set as a floor, not a ceiling.
What Defenders Should Do Now
- Inventory Ruby applications and gems for a dependency on
mustache, and check whether any code path renders a template string that is influenced by user input, even indirectly. - Upgrade past 1.1.2 as soon as a patched release is available. Until then, treat any user-controllable template string as equivalent to arbitrary code execution and block or isolate that input path.
- For hunting, review application and WAF logs for template-render calls fed unusual or encoded content resembling Mustache syntax (
{{ }},{{# }}). Watch for unexpected outbound process spawns, file writes, or sleep and CPU-spike anomalies correlated with template-rendering endpoints. - Where feasible, run template-rendering workloads in a sandboxed or privilege-reduced context so that method-chaining RCE in the templating layer cannot reach the full application environment.
This is developing, same-day intel. The advisory intentionally withholds full PoC and patch details pending a remediation window, and the scope of exploitable method chains is described as larger than what has been disclosed so far. See the original advisory for authoritative updates: GHSA-5hrj-7fc3-cmx9.