Status: Patched
This vulnerability has been verified as resolved and deployed.
Exponential merge keys in Bun's YAML implementation leads to DoS
Summary
Exponential merge keys in Bun.YAML.parse trigger CPU exhaustion
Bun.YAML.parse materialises YAML mappings by iterating every merge (<<) entry and blindly appending the referenced property list to the target object (src/bun.js/api/YAMLObject.zig:1034-1045). Because the loop does not track merge depth or repeated anchors, an attacker can craft a document where each level merges all previous anchors (<<: [*a0, *a1, …]). The parser repeatedly copies the entire accumulated property array for each level, resulting in exponential work while the payload remains only a few kilobytes. Running the supplied payload against Bun 1.3.0 (bun --eval …) shows parse times climbing past 9 seconds on a single CPU core, enabling a trivial network DoS via untrusted YAML input.
CVSS Score
Vulnerability Location
Sink-to-Source Analysis
Bun.YAML.parse accepts attacker-controlled input and invokes the YAML parser without imposing size or recursion limits.
parseFlowMapping / parseBlockMapping build AST nodes whose properties slices simply inline every merge (<<) target, duplicating anchors instead of referencing them.
ParserCtx.toJS iterates the properties slice and converts each entry into JS strings/values with no merge-depth accounting.
putMayBeIndex stores each property on the JS object, so the exponential number of duplicated keys translates directly into CPU time before YAML.parse returns to user code.
Impact Analysis
Critical Impact
Repeated requests allow an unauthenticated attacker to peg a CPU core and starve other work, causing a denial of service. Memory usage also spikes due to repeated property duplication.
Attack Surface
Any Bun application that calls Bun.YAML.parse (or YAML.parse) on user-controlled data—configuration endpoints, API payloads, etc.—is affected.
Preconditions
None; the attacker only needs the ability to submit a YAML document. No authentication or special privileges are required.
Proof of Concept
Environment Setup
Requirements: macOS 15.1 (Apple M1), Bun 1.3.0 (system install).
Verify version:
Target Configuration
Execute the following script, which builds a depth-24 merge payload (~2.2 KB) and measures parse time:
Exploit Delivery
Outcome
Bun.YAML.parse spends ~9.5 seconds materialising a 2.2 KB document, allowing a remote attacker to keep a core saturated by repeatedly sending the payload. Higher depths continue to grow exponentially, so parallel requests can knock the process offline entirely.
Expected Response:
