<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/cve-2026-41316-erb-init-deserialization-guard-bypass-via-def-module-def-method-def-class-pzlvmxzk8" -->

---
title: CVE-2026-41316: ERB @_init deserialization guard bypass...
description: A deserialization vulnerability (CVE-2026-41316) has been disclosed in the Ruby ERB gem. The flaw allows attackers to bypass the @_init guard that normally...
canonical: https://daily.dev/posts/cve-2026-41316-erb-init-deserialization-guard-bypass-via-def-module-def-method-def-class-pzlvmxzk8
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: CVE-2026-41316: ERB @_init deserialization guard bypass via def_module / def_method / def_class | daily.dev
og:description: A deserialization vulnerability (CVE-2026-41316) has been disclosed in the Ruby ERB gem. The flaw allows attackers to bypass the @_init guard that normally...
og:url: https://daily.dev/posts/cve-2026-41316-erb-init-deserialization-guard-bypass-via-def-module-def-method-def-class-pzlvmxzk8
og:image: https://api.daily.dev/og/posts/pzlVMxzk8.png
og:image:alt: CVE-2026-41316: ERB @_init deserialization guard bypass via def_module / def_method / def_class
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

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

**[Ruby](https://daily.dev/sources/ruby)** · 2 min read · 2 upvotes · 0 comments

## Summary

A deserialization vulnerability (CVE-2026-41316) has been disclosed in the Ruby ERB gem. The flaw allows attackers to bypass the @_init guard that normally prevents code execution during Marshal.load deserialization, by invoking ERB#def_method, ERB#def_module, or ERB#def_class — which evaluate template source without checking the guard. Any Ruby application calling Marshal.load on untrusted data with both erb and activesupport loaded is vulnerable to arbitrary code execution, including all Ruby on Rails applications. The fix is to upgrade the erb gem to version 4.0.3.1, 4.0.4.1, 6.0.1.1, 6.0.4 or later. Versions 6.0.3 and below are affected.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.ruby-lang.org/en/news/2026/04/21/erb-cve-2026-41316/>

## Similar posts on daily.dev

- [Issue \#814: Bringing Rails into the Ractor age — Ruby Weekly](https://daily.dev/posts/issue-814-bringing-rails-into-the-ractor-age-ruby-weekly-vch5zguhp) · Ruby Weekly · 0 upvotes · 0 comments
- [CVE-2026-67989 \(ruby\_llm\): Polynomial-Time Regular Expression Denial of Service \(ReDoS\) vulnerability](https://daily.dev/posts/cve-2026-67989-ruby-llm-polynomial-time-regular-expression-denial-of-service-redos-vulnerabilit-sshpahedi) · RUBYLAND · 0 upvotes · 0 comments
- [Ruby & Rails Weekly: KindaRails2Shell Exploited, Ractor Rails](https://daily.dev/posts/ruby-rails-weekly-kindarails2shell-exploited-ractor-rails-70dte5arg) · Ruby Flow · 3 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#ruby](https://daily.dev/tags/ruby), [#rails](https://daily.dev/tags/rails)

[View this post on daily.dev](https://daily.dev/posts/cve-2026-41316-erb-init-deserialization-guard-bypass-via-def-module-def-method-def-class-pzlvmxzk8)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"CVE-2026-41316: ERB @_init deserialization guard bypass via def_module / def_method / def_class","url":"https://daily.dev/posts/cve-2026-41316-erb-init-deserialization-guard-bypass-via-def-module-def-method-def-class-pzlvmxzk8","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/cve-2026-41316-erb-init-deserialization-guard-bypass-via-def-module-def-method-def-class-pzlvmxzk8"},"datePublished":"2026-04-21T08:09:02.134Z","dateModified":"2026-04-22T08:26:11.115Z","description":"A deserialization vulnerability (CVE-2026-41316) has been disclosed in the Ruby ERB gem. The flaw allows attackers to bypass the @_init guard that normally...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/70148b15fea2449ce466c507466a051c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/70148b15fea2449ce466c507466a051c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Ruby","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ruby","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/05592459849b4d6b8e7af1758235a337","url":"https://daily.dev/sources/ruby"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/cve-2026-41316-erb-init-deserialization-guard-bypass-via-def-module-def-method-def-class-pzlvmxzk8","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,ruby,rails","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ruby","item":"https://daily.dev/sources/ruby"},{"@type":"ListItem","position":3,"name":"CVE-2026-41316: ERB @_init deserialization guard bypass via def_module / def_method / def_class"}]}
```

