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
CVE-2026-41316 is a protection mechanism failure in Ruby's ERB templating system. Ruby 2.7.0 introduced an instance variable guard (@_init) in ERB#result and ERB#run to prevent code execution when an ERB object is deserialized via Marshal.load. However, three other public methods—ERB#def_method, ERB#def_module, and ERB#def_class—that also evaluate the source code via eval() lacked this guard. An attacker able to trigger Marshal.load on untrusted data can exploit ERB#def_module to bypass the @_init guard and achieve arbitrary code execution. The vulnerability is addressed in ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, and 6.0.4. Red Hat advisories provide patches for affected Red Hat Enterprise Linux versions.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary code in the context of the Ruby application using ERB, leading to full confidentiality, integrity, and availability compromise. The CVSS v3.1 score is 8.1 (High), reflecting network attack vector, high impact on confidentiality, integrity, and availability, and requiring no privileges or user interaction but with high attack complexity.
Mitigation Recommendations
Fixes are available and have been released in ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, and 6.0.4. Users should upgrade to these or later patched versions. Red Hat has issued security advisories and errata with updated packages for affected Red Hat Enterprise Linux versions. Applying these vendor-provided updates will remediate the vulnerability. Patch status is confirmed by vendor advisories linked in the references.
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
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
CVE-2026-41316 is a protection mechanism failure in Ruby's ERB templating system. Ruby 2.7.0 introduced an instance variable guard (@_init) in ERB#result and ERB#run to prevent code execution when an ERB object is deserialized via Marshal.load. However, three other public methods—ERB#def_method, ERB#def_module, and ERB#def_class—that also evaluate the source code via eval() lacked this guard. An attacker able to trigger Marshal.load on untrusted data can exploit ERB#def_module to bypass the @_init guard and achieve arbitrary code execution. The vulnerability is addressed in ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, and 6.0.4. Red Hat advisories provide patches for affected Red Hat Enterprise Linux versions.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary code in the context of the Ruby application using ERB, leading to full confidentiality, integrity, and availability compromise. The CVSS v3.1 score is 8.1 (High), reflecting network attack vector, high impact on confidentiality, integrity, and availability, and requiring no privileges or user interaction but with high attack complexity.
Mitigation Recommendations
Fixes are available and have been released in ERB versions 4.0.3.1, 4.0.4.1, 6.0.1.1, and 6.0.4. Users should upgrade to these or later patched versions. Red Hat has issued security advisories and errata with updated packages for affected Red Hat Enterprise Linux versions. Applying these vendor-provided updates will remediate the vulnerability. Patch status is confirmed by vendor advisories linked in the references.
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
- Vendor Advisory Urls
- [{"url":"https://access.redhat.com/security/cve/CVE-2026-41316","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:18065","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:20606","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:20614","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:20670","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26312","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26655","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:18039","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:18030","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:20596","vendor":"Red Hat"}]
Threat ID: 69eada9887115cfb68a5e99c
Added to database: 04/24/2026, 02:51:04 UTC
Last enriched: 07/16/2026, 09:00:08 UTC
Last updated: 07/31/2026, 19:22:58 UTC
Views: 126
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.
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.