Remote Code Execution via Prototype Pollution in Blitz.js
A prototype pollution vulnerability in the superjson library used by Blitz.js allowed unauthenticated attackers to execute arbitrary code on the server by manipulating object prototypes through RPC calls. The exploit chained three gadgets to achieve remote code execution.
Published on blog.sonarsource.com
Third-party dependencies are an easy way for developers to add functionality to their applications. This is great for productivity, but it also adds more attack surface and potential for bugs.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the superjson library allowed user-controlled property paths in its deserialization process, enabling attackers to set properties on Object.prototype via the __proto__ key.
Impact
Unauthenticated attackers could execute arbitrary code on the server, leading to full compromise of the application.
What the attacker needed
Blitz.js application with at least one RPC call; No authentication required
The fix
The vulnerability was fixed by blocking property names __proto__, constructor, and prototype in paths, and by updating superjson and Blitz.js to patched versions.
How it was found
- Send a request that abuses the prototype pollution in the RPC layer to add properties to the Object prototype.
- This creates a new entry in the pages manifest pointing to the Blitz.js CLI wrapper script and sets spawn options.
- Send a request to the URL of the newly created pages manifest entry to trigger the chain.
- The CLI wrapper script is executed, spawning a new process with attacker-controlled options, leading to code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Prototype pollution is a bug where an attacker can add or change properties on a fundamental JavaScript object that many other objects inherit from. This can alter how the program behaves, and in this case, it let an attacker run their own code on the server. The vulnerability was in a library that Blitz.js uses to handle data sent between the browser and server.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.