CVE-2026-41316: ERB has an @_init deserialization guard bypass via def_module / def_method / def_class
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.
Security readout for executives and security teams
Plain-English summary
A flaw in Ruby's ERB library can let an attacker execute code when an application deserializes attacker-controlled data using Marshal.load. Exploitation requires a specific unsafe application behavior, but successful exploitation could compromise data, integrity, and service availability.
Executive priority
Treat this as a high-priority patching and code-review issue for internet-facing or multi-tenant Ruby services. Accelerate remediation where untrusted Marshal deserialization exists. Systems that do not deserialize untrusted data remain lower priority, but should still upgrade during the normal security cycle.
Technical view
The @_init guard in ERB#result and ERB#run does not protect ERB#def_method, ERB#def_module, or ERB#def_class, which also evaluate @src. A crafted ERB object reconstructed through untrusted Marshal.load can therefore reach a code-execution sink. CVSS 3.1 is 8.1, reflecting network reachability, high complexity, no privileges, no user interaction, and high impact.
Likely exposure
Exposure is limited to Ruby applications using affected ERB versions, with erb loaded, that pass untrusted or attacker-influenced data to Marshal.load. Merely using ERB does not establish exploitability. Affected ranges are below 4.0.3.1, 4.0.4, 5.0.0 through 6.0.1, and 6.0.2 through 6.0.3.
Exploitation context
The source bundle does not report CISA KEV listing or confirmed active exploitation. Exploitation is remotely reachable in some deployments but rated high complexity because it depends on an application exposing unsafe Ruby Marshal deserialization with ERB available.
Researcher notes
This is a guard-coverage failure rather than a general ERB template-injection issue. Assessment should focus on the intersection of a vulnerable ERB version, loaded ERB code, attacker-influenced Marshal data, and a reachable deserialization path. Public sources provided here do not establish exploitation in the wild.
Mitigation direction
Upgrade ERB to 4.0.3.1, 4.0.4.1, 6.0.1.1, 6.0.4, or a later vendor-supported release.
Prioritize applications that deserialize data influenced by external users, services, queues, caches, or stored sessions.
Eliminate Marshal.load for untrusted data and use a serialization format that cannot reconstruct executable Ruby objects.
Apply relevant Red Hat errata when ERB is supplied through affected Red Hat packages.
Validation and detection
Inventory ERB gem and operating-system package versions across production, development, CI, and container images.
Review code paths calling Marshal.load and determine whether any input can be influenced outside the trust boundary.
Confirm the deployed dependency resolves to a patched ERB version, including bundled or transitive copies.
Retest affected deserialization workflows after upgrading without constructing or executing a malicious payload.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · medium confidence lookup
CWE-502: Code execution behavior lookup
Code execution and unsafe deserialization weaknesses often justify reviewing execution behavior and process telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The CVE wording references code or command execution, so execution technique review may help defensive triage. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
5Timeline events
2ADP providers
18Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: total
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-502 · source CWE mapping
Deserialization of Untrusted Data
Deserialization of Untrusted Data represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Protection Mechanism Failure represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.