CVE-2026-41316
Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.
NVD · uneditedERB is a templating system for Ruby. Ruby 2.7.0 (before ERB 2.2.0 was published on rubygems.org) introduced an `@_init` instance variable guard in `ERB#result` and `ERB#run` to prevent code execution when an ERB object is reconstructed via `Marshal.load` (deserialization). However, three other public methods that also evaluate `@src` via `eval()` were not given the same guard: `ERB#def_method`, `ERB#def_module`, and `ERB#def_class`. An attacker who can trigger `Marshal.load` on untrusted data in a Ruby application that has `erb` loaded can use `ERB#def_module` (zero-arg, default parameters) as a code execution sink, bypassing the `@_init` protection entirely. ERB 4.0.3.1, 4.0.4.1, 6.0.1.1, and 6.0.4 patch the issue.
Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.
dbcve analysis · high confidenceERB's Ruby 2.7.0 update added an @_init instance variable guard to prevent code execution during Marshal.load deserialization, but this protection was only applied to ERB#result and ERB#run methods. Three other public methods (def_method, def_module, and def_class) that also evaluate @src via eval() were missed, allowing an attacker to use ERB#def_module as a code execution sink that completely bypasses the @_init protection when untrusted data is deserialized.
Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.
CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.
From the vector- Attack vector
- Network
- Complexity
- High
- Privileges
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.
dbcve checksWork through these to decide whether this CVE applies to you.
-
Check Ruby versionRun `ruby --version` to determine the installed Ruby version. The @_init protection was introduced in Ruby 2.7.0, so versions 2.7.0 and later contain the partial protection that can be bypassed.Affected if Ruby version is 2.7.0 or later AND the application uses ERB with the vulnerable methods
-
Verify ERB library is loadedSearch codebase for `require 'erb'` or `require 'erb'` statements, or check Gemfile for erb dependency.Affected if ERB library is loaded in the application
-
Identify use of vulnerable ERB methodsSearch source code for calls to `ERB.new(...).def_method`, `ERB.new(...).def_module`, or `ERB.new(...).def_class`. These methods evaluate ERB templates via eval() without the @_init guard.Affected if Codebase contains any calls to def_method, def_module, or def_class on ERB objects
-
Identify Marshal.load usage on untrusted dataSearch for `Marshal.load` calls in the codebase, particularly those that process data from external sources (user input, network, files from untrusted sources).Affected if Marshal.load is used to deserialize data that originates from untrusted sources
-
Check for deserialization gadgets in loaded objectsIf ERB is loaded and Marshal.load is used, audit what classes are autoloaded or defined that could be leveraged during deserialization to trigger the vulnerable code path.Affected if Classes loaded in the application can be manipulated during Marshal.load to reach ERB vulnerability
You are affected if your Ruby version is 2.7.0 or later, your application loads the ERB library, uses ERB#def_method/def_module/def_class, and deserializes untrusted data with Marshal.load.
Generated from the published advisory. Verify against your own configuration.
Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.
dbcve · scopedUpgrade ERB to version 4.0.3.1, 4.0.4.1, 6.0.1.1, 6.0.4 or later to receive the patch. Additionally, avoid deserializing untrusted data with Marshal.load when the erb library is loaded.
ERB 4.0.4.1 (for 4.x) or ERB 6.0.4 (for 6.x)
- Identify the current ERB gem version in your Ruby application using `gem list erb` or `bundle exec gem list erb`
- Upgrade ERB to a patched version by running `gem install erb` or updating your Gemfile with `gem 'erb', '>= 4.0.4.1'` (for 4.x) or `gem 'erb', '>= 6.0.4'` (for 6.x)
- Run `bundle install` or `bundle update erb` to apply the change
- Verify the installed ERB version with `ruby -r erb -e 'puts ERB::VERSION'` to confirm it matches 4.0.3.1, 4.0.4.1, 6.0.1.1, or 6.0.4 or higher
- If using a framework (Rails, Sinatra), ensure the new ERB version is compatible with your application's dependencies
Generated from the published advisory — verify against the referenced sources before acting.
- Consultation2.0 h
- Implementation1.0 h
- Testing3.0 h
- Review / QA1.0 h
An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $1,936.
Scan for this in your stack
Free · runs locallyCheck whether your project pulls in CVE-2026-41316 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.
References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.
Primary sources- github.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- access.redhat.com
- bugzilla.redhat.com
- security.access.redhat.com
- nvd.nist.gov
Practitioner notes
ContributedPeer-ranked notes from engineers who’ve handled CVE-2026-41316 in production — separate from our analysis above.
The advisory tells you what broke. It rarely tells you what actually worked. If you’ve dealt with this one, that detail is what the next engineer is searching for.
- The version that genuinely resolved it — not the one the vendor claimed
- A config change or rule that shut the vector down
- A gotcha in the upgrade path that cost you an afternoon
No notes yet
Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.
A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.
- Verified mitigations, workarounds, and config changes
- Version or environment caveats, and links to real fixes
- No weaponised exploit code, or anything meant to cause harm
- No spam, self-promotion, credentials, or personal data