Claude Code's Bundled Bun Breaks Javascript Spec

Interesting article here that predates the source code leak.

Here’s the wild part: Bun’s nativeFetch mutates the JS string in place. After fetch() returns, the original body variable has different bytes than what you passed in. JavaScript strings are supposed to be immutable — this is a spec violation.
It gets worse. JSC (JavaScriptCore, the engine Bun uses) shares string backing stores across references. If you do const alias = body, both variables point to the same memory. After fetch(), both are silently mutated. The same applies to Map/Set keys, interned strings, and rope substrings. Any code that coincidentally has cch=00000 in a runtime string and fetches to a /v1/messages URL — even on a different server — will get silently rewritten.

EDIT: I just realized, after going down a bit of a rabbit hole, that this article was written by someone working with Ellie Huxtable – the creator of Atuin :smile:

2 Likes

Wait so is this a Bun problem or a Claude Code problem? I’ll admit to having avoided Bun after their CEO crunched their devs in a pretty monstrous way. Also, y’know, Deno.

Basically, it’s Anthropic – who acquired Bun – using a custom-compiled version of Bun to break the JS spec by doing that in-line replace on the cch=00000 placeholder when the javascript fetch() function is called.

The replacement happens in Bun’s native fetch implementation — compiled Zig code, not JavaScript. Claude Code ships with a custom Bun build (1.3.9-canary.51+d5628db23), an unreleased private fork. The commit doesn’t exist on the public oven-sh/bun repository.