Advisory Database
  • Advisories
  • Dependency Scanning
  1. gem
  2. ›
  3. erb
  4. ›
  5. CVE-2026-41316

CVE-2026-41316: ERB has an @_init deserialization guard bypass via def_module / def_method / def_class

April 24, 2026

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
  • 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.

References

  • github.com/advisories/GHSA-q339-8rmv-2mhv
  • github.com/ruby/erb/security/advisories/GHSA-q339-8rmv-2mhv
  • nvd.nist.gov/vuln/detail/CVE-2026-41316

Code Behaviors & Features

Detect and mitigate CVE-2026-41316 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 4.0.3.1, all versions starting from 4.0.4 before 4.0.4.1, all versions starting from 5.0.0 before 6.0.1.1, all versions starting from 6.0.2 before 6.0.4

Fixed versions

  • 4.0.3.1
  • 4.0.4.1
  • 6.0.1.1
  • 6.0.4

Solution

Upgrade to versions 4.0.3.1, 4.0.4.1, 6.0.1.1, 6.0.4 or above.

Impact 8.1 HIGH

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-693: Protection Mechanism Failure

Source file

gem/erb/CVE-2026-41316.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Tue, 19 May 2026 00:17:36 +0000.