Skip to content
Tech News
← Back to articles

Ruby 4.0 Universal RCE Deserialization Gadget Chain

read original more articles
Why This Matters

The release of a new universal Ruby 4.0.6 deserialization gadget chain highlights ongoing security risks associated with Ruby's serialization process, especially as it now enables command execution across multiple Ruby versions. This development underscores the importance for developers and organizations to scrutinize and secure their use of serialization to prevent potential exploits that could compromise systems or data.

Key Takeaways

Introduction

On August 5, 2026, OpenAI disclosed that a collective of AI agents under evaluation had broken out of their sandboxes and taken admin control of the cluster they were running on. It got there, in part, by exploiting Ruby deserialization to execute commands. That caught our attention, because in 2018 we published the first universal RCE deserialization gadget chain for Ruby, built entirely from the standard library with no dependencies. That chain works only against Ruby versions up to 2.6.10, and the most recent public chain only works up to 3.4-rc.

This post releases a new universal chain that turns a single Marshal.load into command execution on Ruby 4.0.6, the most recent release at the time of writing, and works unchanged as far back as 3.3. The chain is built with new gadgets from untapped sources as well as old gadgets put to new use.

Background

Serialization is the process of converting an object into a series of bytes which can then be transferred over a network or stored on the filesystem or in a database. These bytes include all the information required to reconstruct the original object. This reconstruction process is called deserialization. Each programming language typically has its own native serialization format and may refer to this process by a name other than serialization/deserialization. In the case of Ruby, the terms marshalling and unmarshalling are commonly used, and the operations are provided by Marshal.dump and Marshal.load .

Thirteen years of Ruby deserialization

Universal Ruby deserialization gadget chains begin in 2018, built on earlier research into application specific chains against Ruby on Rails, and that universal work then fed back into the application specific chains that came after it. Several of the milestones below supply pieces that this chain builds on.

How the 3.4 chain broke

The most recent public chain, published in late 2024, reached command execution on Ruby 3.4-rc with this payload:

... continue reading