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
ERB, a Ruby templating system, introduced a guard in Ruby 2.7.0 to prevent code execution during deserialization via Marshal.load by using an instance variable guard (@_init) in ERB#result and ERB#run. However, three other public methods—ERB#def_method, ERB#def_module, and ERB#def_class—that also evaluate template source code with eval() lacked this guard. An attacker able to trigger Marshal.load on untrusted data can exploit ERB#def_module to bypass the @_init protection and achieve arbitrary code execution. The vulnerability is identified as CWE-693 (Protection Mechanism Failure) and CWE-502 (Deserialization of Untrusted Data). It has a CVSS v3.1 score of 8.1 (high severity) with network attack vector, high attack complexity, no privileges required, no user interaction, and high impact on confidentiality, integrity, and availability. Red Hat has released patches for affected versions and provides advisories and updates for their supported products.
Potential Impact
This vulnerability allows an attacker who can cause deserialization of untrusted data in a Ruby application using ERB to execute arbitrary code remotely. The impact includes full compromise of confidentiality, integrity, and availability of the affected system. The vulnerability can be exploited without user interaction or privileges but requires high attack complexity. It can lead to unauthorized code execution, data modification, and denial of service.
Mitigation Recommendations
A fix is available and should be applied by upgrading to patched versions of ERB (4.0.3.1, 4.0.4.1, 6.0.1.1, or 6.0.4) or the corresponding Ruby packages provided by vendors such as Red Hat. Red Hat has released security updates for affected Enterprise Linux versions and recommends applying these updates promptly. If upgrading is not immediately possible, avoid deserializing untrusted data with Marshal.load in applications using ERB. Follow vendor advisories for detailed update instructions.
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
ruby
erb
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
ERB, a Ruby templating system, introduced a guard in Ruby 2.7.0 to prevent code execution during deserialization via Marshal.load by using an instance variable guard (@_init) in ERB#result and ERB#run. However, three other public methods—ERB#def_method, ERB#def_module, and ERB#def_class—that also evaluate template source code with eval() lacked this guard. An attacker able to trigger Marshal.load on untrusted data can exploit ERB#def_module to bypass the @_init protection and achieve arbitrary code execution. The vulnerability is identified as CWE-693 (Protection Mechanism Failure) and CWE-502 (Deserialization of Untrusted Data). It has a CVSS v3.1 score of 8.1 (high severity) with network attack vector, high attack complexity, no privileges required, no user interaction, and high impact on confidentiality, integrity, and availability. Red Hat has released patches for affected versions and provides advisories and updates for their supported products.
Potential Impact
This vulnerability allows an attacker who can cause deserialization of untrusted data in a Ruby application using ERB to execute arbitrary code remotely. The impact includes full compromise of confidentiality, integrity, and availability of the affected system. The vulnerability can be exploited without user interaction or privileges but requires high attack complexity. It can lead to unauthorized code execution, data modification, and denial of service.
Mitigation Recommendations
A fix is available and should be applied by upgrading to patched versions of ERB (4.0.3.1, 4.0.4.1, 6.0.1.1, or 6.0.4) or the corresponding Ruby packages provided by vendors such as Red Hat. Red Hat has released security updates for affected Enterprise Linux versions and recommends applying these updates promptly. If upgrading is not immediately possible, avoid deserializing untrusted data with Marshal.load in applications using ERB. Follow vendor advisories for detailed update instructions.
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
- 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: 08/05/2026, 12:59:13 UTC
Last updated: 09/15/2026, 03:28:47 UTC
Views: 158
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.