# Ruby Marshal Deserialization

> Detects Marshal.load() or Marshal.restore() on untrusted data, enabling code execution.

- Skill: `zakirkun/ruby-marshal-deserialization` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add zakirkun/ruby-marshal-deserialization`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zakirkun/ruby-marshal-deserialization/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: zakirkun (https://skillmd.com/u/zakirkun)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/zakirkun/ruby-marshal-deserialization

---


# Ruby Marshal Deserialization

## Overview
Ruby's `Marshal.load()` deserializes a binary format that can instantiate arbitrary Ruby objects. Attackers can craft malicious payloads that invoke `initialize`, `[]`, and other methods during deserialization, leading to code execution.

This affected Rails versions using Marshal for cookie sessions before 4.x.

## Remediation
- Never use `Marshal.load()` on untrusted data
- Use `JSON.parse()` or `MessagePack` for data exchange
- For sessions, use signed/encrypted JSON-based session stores

