Skip to content
Security & Trust Talking point

Bun's new compiler bans the usual route for prototype pollution, for code it builds

Bun's creator said its new compiler bans writes to object.prototype, how prototype pollution usually works.

W
WebPulse Newsroom
AI-assisted · 2 min read
Share on X LinkedIn
Bun's new compiler bans the usual route for prototype pollution, for code it builds
In brief
  • Jarred Sumner said Bun's new compiler bans assigning properties onto object.prototype, which he described as how prototype pollution usually works. He called it a rare edge case.
  • He said the two breaking changes are mostly security things that also help performance. The talk does not say whether regular Bun has the same ban.

A toolchain can rule out an attack route for the code it builds, instead of leaving each team to fix it alone. Jarred Sumner, creator of Bun, described one case on the AI Engineer podcast. Bun is a runtime, the program that runs JavaScript. Its new ahead-of-time compiler bans the route he said prototype pollution usually takes.

What was said

Sumner was describing one very large change to Bun, several million lines in a single merge. It adds an ahead-of-time compiler, which prepares code before it runs rather than while it runs. He said the change brings two breaking changes, meaning some existing code stops working. He tied them to why certain tests fail.

By his account, the two breaking changes are "mostly security things" aimed at prototype pollution attacks. He said they also help speed, because they "also end up benefiting for performance". Security came first in his description, and performance was the extra.

On the attack itself, Sumner said it "usually works by assigning properties onto object.prototype". Then he said "the compiler bans that." He called this a rare edge case.

Why it matters

Background, not a claim from the talk: nearly every JavaScript object inherits from object.prototype, a shared base. In a pollution attack, input the attacker controls, such as a crafted key name, reaches that shared base. A write there can change behaviour across a whole program. The talk gives no mechanism for how the compiler bans such a write.

Our reading: if the ban works as Sumner described, it covers that route for code the compiler builds. No team has to find that weak spot in its own code first. When software fails, the cost lands on users and on the maintainers who clean up. A ban in the toolchain moves some of that work upstream.

For engineering leaders, the practical question is which bug classes your build tools already rule out. A second question is whether an upgrade you want anyway brings that protection with it.

The other side

The ban closes one route. It does not end prototype pollution as a class of attack, and Sumner did not claim it does. He called the case a rare edge case.

A breaking change also has a price. Sumner did not say whether the object.prototype ban is one of the two breaking changes. If it is, code that writes to object.prototype would need to change.

The talk leaves other questions open. Sumner described the ban as part of the compiler. He did not say whether regular Bun has the same rule, so how many apps are covered is unclear. He also did not say how the ban works or what exactly it covers. He gave no data on how many real attacks it stops.

Written by the WebPulse Newsroom with AI assistance, and checked by our editorial review: every quotation was verified against the recording's transcript. How we use AI.

The conversation this talking point comes from