79% vs 51%: independent neobanks lag on app security. Read the report

Deep Dive

Deep Dive

Mustache for Ruby Template RCE (CVE-2026-130001)

An attacker who controls a Mustache template can call built-in Ruby methods and run code; fixed in mustache 1.1.3 with a default method blacklist.

TL;DR

  • Affected versions of Mustache for Ruby let an untrusted template invoke built-in Ruby methods and execute code as the rendering process. CVE-2026-130001 has a CVSS v3.1 score of 9.8 (Critical).
  • Every release through 1.1.2 is affected. The fix is in 1.1.3, released on 2026-08-20.
  • No exploitation in the wild is known, and the CVE is not in KEV as of 2026-11-19. The advisory withholds the payloads.
  • Upgrade to mustache 1.1.3 or later. The new default blocks reflection methods; review any place where users supply the template string.

Am I affected?

All of these must hold:

  • The application uses the mustache Ruby gem at 1.1.2 or earlier.
  • An attacker can influence the template string, not only the data passed to it.

The advisory says exploitation does not depend on any configuration or on the objects passed to the template engine. That is the important distinction: a Mustache template is usually treated as trusted code written by the developer, but the flaw is exploitable when the template itself comes from an untrusted source.

Branch Affected versions Fixed version
1.x 1.1.2 and earlier 1.1.3
1.1.3 Not affected Current release

The gem recorded 83,857,242 downloads in total on RubyGems, and 508,178 downloads of version 1.1.3. That is the package's download count, not the number of applications that accept user-supplied templates.

Check what is installed:

# Bundler projects
bundle list | grep -i mustache

# A global gem install
gem list mustache

# The resolved version in a lockfile
grep -n -A 2 "mustache" Gemfile.lock

Any version up to and including 1.1.2 is affected. A project with no direct dependency can still include the gem through another gem, so check the lockfile rather than only the Gemfile.

How do I fix it?

Upgrade to 1.1.3 or later. The fix adds a context access security level, and the default level blocks the reflection methods that make the escape possible.

# Bundler
bundle update mustache

# A global gem install
gem update mustache
  1. Upgrade the gem and commit the updated Gemfile.lock.
  2. Rebuild and redeploy every application that bundles it. A running process keeps the old gem until it restarts.
  3. Search for places where users supply the template string, such as stored templates, notification bodies or report layouts. Move those templates to a trusted store or render them with a non-executable format.
  4. If you cannot upgrade immediately, do not render untrusted template strings. Passing untrusted values as data is not the same as letting the attacker write the template.

The upgrade keeps the normal API. The default security level is 2, which blocks a list of reflection methods. A template that legitimately calls those methods will need a different design; do not lower the level to keep it working without understanding the exposure.

What is the root cause?

When a key referred to a method on the view object, Mustache checked whether the object responded to the name. This normally excluded private methods, but some public methods exposed capabilities that a template author should never inherit from the application.

What can an attacker do?

The attacker can run code with the privileges of the Ruby application that renders the template. That is usually the application server account, with access to the application's configuration, database credentials and files.

  • The attacker can read environment variables and configuration files reachable by the process.
  • The attacker can read and modify data the application can reach.
  • The attacker can run commands on the host, depending on how the application is deployed.
  • The attacker can use the application as a base for further access.

The conditions are listed in full in "Am I affected?". The critical condition is control of the template string. An application that renders only developer-written templates does not expose this path, even if it passes user data into the template. The advisory says no configuration or extra objects are needed, so a single untrusted template is enough.

The template string is often stored in a database, a notification template or a report layout, so the attacker may not need a live request to inject it. A stored template that is rendered later still reaches the method lookup.

The advisory describes the impact as arbitrary code execution and rates the flaw CVSS v3.1 9.8. It does not publish a victim or an exploitation report.

Why does the fix work?

The fix adds context_access_security_level to Mustache, with a default of 2, and checks it before resolving a key. Level 2 blocks a blacklist of reflection methods; higher levels block inherited methods, all method access, or any context that is not an exact Hash.

Levels 3, 4 and 5 are stricter options for applications that render untrusted templates. Level 3 blocks inherited methods, level 4 blocks all method access, and level 5 requires the context to be exactly a Hash. The default level 2 is the compatibility choice: it blocks the known escape methods while keeping ordinary view objects working.

How do I check if I was compromised?

There are no published indicators of compromise. The request is an ordinary render call, and the template may be stored long before it is used.

# Search template files for selected bare or dotted method names
grep -RInE '\{\{[[:space:]]*([^{}[:space:]]+\.)?(send|method|class|instance_eval|instance_exec|const_get)(\.|[[:space:]]*\}\})' /path/to/templates

# Recent changes to stored templates
find /path/to/templates -type f -mtime -30 2>/dev/null

# Candidate Ruby application processes for manual inspection
ps -eo user,pid,ppid,cmd | grep -E "ruby|rails|puma|sidekiq" | grep -v grep

A match identifies a template to inspect. Ordinary data keys can share these names. This line-based search covers files under the specified directory. Check database-backed templates, change history and application logs separately. The process list is a point-in-time snapshot. To investigate possible shell execution, check historical process events for parent PID, executable and timestamp. If you find a suspicious template, preserve it and the logs, rotate secrets accessible to the Ruby process and review who can edit templates.

The advisory does not publish request patterns or file names, so the search has to start from the application's own template store.

Timeline

  • 2026-08-20 — The maintainer published the advisory and RubyGems released mustache 1.1.3.
  • 2026-11-18 — GitHub added the advisory to its reviewed advisory database.
  • 2026-11-19: no exploitation is known and the CVE is not in KEV.

Timeline of CVE-2026-130001: the fix and the advisory
Maintainer advisory and gem release in August, GitHub database entry in November.

FAQ

Is it unauthenticated?

It depends on the application. The flaw needs control of the template string, not a Mustache account. If the application lets an unauthenticated user store or edit a template, the path is unauthenticated; if only an authenticated administrator can edit templates, the attacker needs that role.

Which versions are affected?

Every mustache release through 1.1.2. The fix is in 1.1.3, released on 2026-08-20. A project that locks an older version stays affected until it upgrades.

Is there a public exploit?

The maintainer deferred publication of the demonstration payloads.

Was it exploited in the wild?

No exploitation is known, and CVE-2026-130001 is not in KEV as of 2026-11-19. The advisory does not report an attack.

Does the fix break templates?

The default level 2 blocks reflection methods such as send, method and class. Ordinary data fields and view methods keep working. A template that deliberately calls a blocked method needs a different design; do not lower the level for an untrusted template.

Is Mustache still safe for user-supplied templates?

Only with the stricter levels and a design that treats the template as data. The advisory's own recommendation is to upgrade, and levels 4 and 5 remove method dispatch. If the application does not need user-written templates, keep them developer-controlled.

Find vulnerable Mustache dependencies with Ostorlab

Ostorlab's SCA and SBOM inventories the open-source packages in your applications and container images. For a Ruby service, it shows which lockfiles still resolve mustache to 1.1.2 or earlier, so you can upgrade the applications that render user-supplied templates first.

References

  • GHSA-5hrj-7fc3-cmx9 (Mustache)
  • GitHub advisory, GHSA-5hrj-7fc3-cmx9, "Mustache for Ruby: RCE using built-in method access": https://github.com/advisories/GHSA-5hrj-7fc3-cmx9 (checked November 19, 2026)
  • CVE record, CVE-2026-130001: https://www.cve.org/CVERecord?id=CVE-2026-130001 (checked November 19, 2026)
  • Mustache 1.1.3 on RubyGems: https://rubygems.org/gems/mustache/versions/1.1.3 (checked November 19, 2026)
  • Mustache source at 1.1.2, context.rb: https://github.com/mustache/mustache/blob/v1.1.2/lib/mustache/context.rb (checked November 19, 2026)
  • Mustache fix commit 6f0b0a27 adding the context access security level: https://github.com/mustache/mustache/commit/6f0b0a27a864 (checked November 19, 2026)
  • RubyGems download statistics for mustache: https://rubygems.org/gems/mustache (checked November 19, 2026)