<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet href="/static/style.xsl" type="text/xsl"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title>Most recent entries from all</title>
    <link>https://vulnerability.circl.lu</link>
    <description>Contains only the most 10 recent entries.</description>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>python-feedgen</generator>
    <language>en</language>
    <lastBuildDate>Wed, 30 Sep 2026 00:53:11 +0000</lastBuildDate>
    <item>
      <title>GHSA-q339-8rmv-2mhv — ERB has an @_init deserialization guard bypass via def_module / def_method / def_class</title>
      <link>https://vulnerability.circl.lu/vuln/ghsa-q339-8rmv-2mhv</link>
      <description>&lt;p&gt;&lt;strong&gt;Affected:&lt;/strong&gt; RubyGems: erb&lt;/p&gt;
&lt;p&gt;## Summary&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;- `ERB#def_method`
- `ERB#def_module`
- `ERB#def_class`&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;&amp;lt;details&amp;gt;&lt;/p&gt;
&lt;p&gt;## The @_init Guard&lt;/p&gt;
&lt;p&gt;In `ERB#initialize`, the guard is set:&lt;/p&gt;
&lt;p&gt;```ruby
# erb.rb line 838
@_init = self.class.singleton_class
```&lt;/p&gt;
&lt;p&gt;In `ERB#result` and `ERB#run`, the guard is checked before `eval(@src)`:&lt;/p&gt;
&lt;p&gt;```ruby
# erb.rb line 1008-1012
def result(b=new_toplevel)
  unless @_init.equal?(self.class.singleton_class)
    raise ArgumentError, &amp;#34;not initialized&amp;#34;
  end
  eval(@src, b, (@filename || &amp;#39;(erb)&amp;#39;), @lineno)
end
```&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;## The Bypass&lt;/p&gt;
&lt;p&gt;`ERB#def_method`, `ERB#def_module`, and `ERB#def_class` all reach `eval(@src)` without checking `@_ini…&lt;/p&gt;</description>
      <content:encoded>&lt;p&gt;&lt;strong&gt;Affected:&lt;/strong&gt; RubyGems: erb&lt;/p&gt;
&lt;p&gt;## Summary&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;- `ERB#def_method`
- `ERB#def_module`
- `ERB#def_class`&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;&amp;lt;details&amp;gt;&lt;/p&gt;
&lt;p&gt;## The @_init Guard&lt;/p&gt;
&lt;p&gt;In `ERB#initialize`, the guard is set:&lt;/p&gt;
&lt;p&gt;```ruby
# erb.rb line 838
@_init = self.class.singleton_class
```&lt;/p&gt;
&lt;p&gt;In `ERB#result` and `ERB#run`, the guard is checked before `eval(@src)`:&lt;/p&gt;
&lt;p&gt;```ruby
# erb.rb line 1008-1012
def result(b=new_toplevel)
  unless @_init.equal?(self.class.singleton_class)
    raise ArgumentError, &amp;#34;not initialized&amp;#34;
  end
  eval(@src, b, (@filename || &amp;#39;(erb)&amp;#39;), @lineno)
end
```&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;## The Bypass&lt;/p&gt;
&lt;p&gt;`ERB#def_method`, `ERB#def_module`, and `ERB#def_class` all reach `eval(@src)` without checking `@_ini…&lt;/p&gt;</content:encoded>
      <guid isPermaLink="false">https://vulnerability.circl.lu/vuln/ghsa-q339-8rmv-2mhv</guid>
    </item>
  </channel>
</rss>
