Intel

AIKIDO-2026-41159

psych is vulnerable to Deserialization of Untrusted Data

Deserialization of Untrusted Data Pre-CVE
Found by Aikido Intel before public disclosure or CVE publication.
Published 2 days ago

48

Medium Risk

This Affects:

RUBYpsych
2.0.0 - 5.4.0
Fixed in 5.5.0
Are you affected? Scan for Free

TL;DR

Psych resolves the !ruby/encoding tag by calling ::Encoding.find directly instead of using the restricted class loader, so safe_load returns an Encoding object even when no classes are permitted. The container tags !ruby/hash, !map:, !ruby/hash-with-ivars, !ruby/array, !seq:, and !ruby/string load the class named in the tag without checking that it is a subclass of the expected Hash, Array, or String, so a crafted document can allocate any permitted class and then call replace, push, or []= on the uninitialized instance, or write instance variables onto it, skipping init_with and returning an instance whose state holds types the class never accepts. The fix registers Encoding with the class loader and rejects tags whose target is not a subclass of the expected Hash, Array, or String.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range and you parse untrusted YAML with Psych.safe_load or the default safe Psych.load.

Background info

psych is vulnerable to Deserialization of Untrusted Data in versions 2.0.0 - 5.4.0.

How to fix this

Upgrade the psych library to the patch version.

Are You Affected?

Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.

Free. No credit card required.

Aikido Platform