CVE-2026-41316
HIGH 8.1CVSS 3.1ERB 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.
- Published
- 24 Apr 2026
- Last modified
- 17 Nov 2026
- Assigned by
- security-advisories@github.com
- NVD status
- Deferred
- Weakness
- CWE-502CWE-693
- Also known as
- GHSA-q339-8rmv-2mhv
- Sources
- NVDJSONOSV GHSA-q339-8rmv-2mhvJSON
Scores
| Source | Scored by | Version | Score | Vector / decision |
|---|---|---|---|---|
| NVD | security-advisories@github.com (Secondary) | CVSS 3.1 | HIGH 8.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| NVD | 0b0ca135-0b70-47e7-9f44-1890c2a1c46c (Secondary) | CVSS 3.1 | HIGH 8.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| OSV | GitHub | CVSS 3.1 | HIGH 8.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
Affected
| Source | Vendor / ecosystem | Product / package | Affected versions | Fixed in |
|---|---|---|---|---|
| OSV | RubyGems | erb | < 4.0.3.1 | 4.0.3.1 |
| OSV | RubyGems | erb | >= 4.0.4, < 4.0.4.1 | 4.0.4.1 |
| OSV | RubyGems | erb | >= 5.0.0, < 6.0.1.1 | 6.0.1.1 |
| OSV | RubyGems | erb | >= 6.0.2, < 6.0.4 | 6.0.4 |
References
- https://github.com/ruby/erb/security/advisories/GHSA-q339-8rmv-2mhv · WEB
- https://access.redhat.com/errata/RHSA-2026:18030 · WEB
- https://access.redhat.com/errata/RHSA-2026:18039 · WEB
- https://access.redhat.com/errata/RHSA-2026:18065 · WEB
- https://access.redhat.com/errata/RHSA-2026:20596 · WEB
- https://access.redhat.com/errata/RHSA-2026:20606 · WEB
- https://access.redhat.com/errata/RHSA-2026:20614 · WEB
- https://access.redhat.com/errata/RHSA-2026:20670 · WEB
- https://access.redhat.com/errata/RHSA-2026:26312 · WEB
- https://access.redhat.com/errata/RHSA-2026:26655 · WEB
- https://access.redhat.com/errata/RHSA-2026:33462 · WEB
- https://access.redhat.com/errata/RHSA-2026:33478 · WEB
- https://access.redhat.com/errata/RHSA-2026:35834 · WEB
- https://access.redhat.com/errata/RHSA-2026:37238 · WEB
- https://access.redhat.com/security/cve/CVE-2026-41316 · WEB
- https://bugzilla.redhat.com/show_bug.cgi?id=2461369 · WEB
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-41316.json · WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-41316 · ADVISORY
- https://github.com/ruby/erb/commit/ef61b591b270f8ba58d47f12472a1c53a77b4d61 · WEB
- https://github.com/ruby/erb/commit/dd34ce41031327269a5fb83b0bc2c0d852895e9f · WEB
- https://github.com/ruby/erb/commit/c3b721f7f7570c23e3423590af0419c1b10e1255 · WEB
- https://github.com/ruby/erb/commit/9d017be4e375cdd058650ce528ee6adfead20cac · WEB
- https://www.ruby-lang.org/en/news/2026/04/21/erb-cve-2026-41316 · WEB
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/erb/CVE-2026-41316.yml · WEB
- https://github.com/ruby/erb · PACKAGE
History
- 25 Nov 2026 21:02 UTC · NVD: first stored (published 24 Apr 2026)
- 25 Nov 2026 20:14 UTC · OSV: first stored (published 24 Apr 2026)