CVE-2026-41316: CWE-693: Protection Mechanism Failure in ruby erb
ERB 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.
AI Analysis
Technical Summary
Ruby's ERB templating system introduced an instance variable guard (@_init) in version 2.7.0 to prevent code execution during deserialization via Marshal.load. However, this guard was not applied to three public methods—ERB#def_method, ERB#def_module, and ERB#def_class—that also evaluate the source code (@src) using eval(). An attacker who can cause Marshal.load on untrusted data in an application with ERB loaded can exploit ERB#def_module with default parameters to bypass the @_init guard and execute arbitrary code. This vulnerability affects multiple ERB versions prior to 4.0.3.1 and certain later versions as specified. The issue is patched in ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, and 6.0.4.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary code remotely without privileges or user interaction, impacting confidentiality, integrity, and availability of the affected system. This can lead to full system compromise in applications that deserialize untrusted data using Marshal.load with vulnerable ERB versions.
Mitigation Recommendations
Patch to ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, or 6.0.4 where the vulnerability is fixed. Since no vendor advisory or official patch links are provided, verify patch availability from the official Ruby or ERB project sources. Avoid deserializing untrusted data with Marshal.load as a general best practice. Patch status is not yet confirmed in the provided data; check the vendor advisory for current remediation guidance.
CVE-2026-41316: CWE-693: Protection Mechanism Failure in ruby erb
Description
ERB 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.
CVSS v3.1
Score 8.1high
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Ruby's ERB templating system introduced an instance variable guard (@_init) in version 2.7.0 to prevent code execution during deserialization via Marshal.load. However, this guard was not applied to three public methods—ERB#def_method, ERB#def_module, and ERB#def_class—that also evaluate the source code (@src) using eval(). An attacker who can cause Marshal.load on untrusted data in an application with ERB loaded can exploit ERB#def_module with default parameters to bypass the @_init guard and execute arbitrary code. This vulnerability affects multiple ERB versions prior to 4.0.3.1 and certain later versions as specified. The issue is patched in ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, and 6.0.4.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary code remotely without privileges or user interaction, impacting confidentiality, integrity, and availability of the affected system. This can lead to full system compromise in applications that deserialize untrusted data using Marshal.load with vulnerable ERB versions.
Mitigation Recommendations
Patch to ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, or 6.0.4 where the vulnerability is fixed. Since no vendor advisory or official patch links are provided, verify patch availability from the official Ruby or ERB project sources. Avoid deserializing untrusted data with Marshal.load as a general best practice. Patch status is not yet confirmed in the provided data; check the vendor advisory for current remediation guidance.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-04-20T14:01:46.671Z
- Cvss Version
- 3.1
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 69eada9887115cfb68a5e99c
Added to database: 4/24/2026, 2:51:04 AM
Last enriched: 5/1/2026, 8:39:02 PM
Last updated: 6/7/2026, 10:36:43 AM
Views: 73
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.