<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet href="/static/style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <id>https://vulnerability.circl.lu/rss/recent/all/10</id>
  <title>Most recent entries from all</title>
  <updated>2026-09-30T00:53:13.562866+00:00</updated>
  <author>
    <name>Vulnerability-Lookup</name>
    <email>info@circl.lu</email>
  </author>
  <link href="https://vulnerability.circl.lu" rel="alternate"/>
  <generator uri="https://lkiesow.github.io/python-feedgen" version="1.0.0">python-feedgen</generator>
  <subtitle>Contains only the most 10 recent entries.</subtitle>
  <entry>
    <id>https://vulnerability.circl.lu/vuln/ghsa-q339-8rmv-2mhv</id>
    <title>GHSA-q339-8rmv-2mhv — ERB has an @_init deserialization guard bypass via def_module / def_method / def_class</title>
    <updated>2026-09-30T00:53:13.564265+00:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml"><p><strong>Affected:</strong> RubyGems: erb</p>
<p>## Summary</p>
<p>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:</p>
<p>- `ERB#def_method`
- `ERB#def_module`
- `ERB#def_class`</p>
<p>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.</p>
<p>&lt;details&gt;</p>
<p>## The @_init Guard</p>
<p>In `ERB#initialize`, the guard is set:</p>
<p>```ruby
# erb.rb line 838
@_init = self.class.singleton_class
```</p>
<p>In `ERB#result` and `ERB#run`, the guard is checked before `eval(@src)`:</p>
<p>```ruby
# erb.rb line 1008-1012
def result(b=new_toplevel)
  unless @_init.equal?(self.class.singleton_class)
    raise ArgumentError, "not initialized"
  end
  eval(@src, b, (@filename || '(erb)'), @lineno)
end
```</p>
<p>When an ERB object is reconstructed via `Marshal.load`, `@_init` is either `nil` (not set during marshal reconstruction) or an attacker-controlled value. Since `ERB.singleton_class` cannot be marshaled, the attacker cannot set `@_init` to the correct value, and `result`/`run` correctly refuse to execute.</p>
<p>## The Bypass</p>
<p>`ERB#def_method`, `ERB#def_module`, and `ERB#def_class` all reach `eval(@src)` without checking `@_ini…</p></div>
    </content>
    <link href="https://vulnerability.circl.lu/vuln/ghsa-q339-8rmv-2mhv"/>
  </entry>
</feed>
