RCE in 'Copy as Node Request' BApp via code injection
The Copy as Node Request Burp extension failed to escape single quotes when generating Node.js code from a request's cookie header. An attacker could place crafted content in a cookie so that, once the user copies the request as Node.js code and runs it, arbitrary Node.js code executes on their machine.
- Triaged in 29 hours
- Fixed in 2 days
- Disclosed after 4 days
Description
Copy as Node Request is a burp suite extension that allows users to copy requests as Node.js code.
Due to improper sanitization of cookie, it's possible to inject arbitrary Node.js code in copied text, which may lead remote code execution with a significant amount of user interaction.
Root cause
This extension has a function named escapeQuotes.
While this function escapes double quotes, it doesn't escape single quotes.
https://github.com/PortSwigger/copy-as-node-request/blob/b34456463310836e93365541189626909adc70bb/src/burp/BurpExtender.java#L165-L167
As the cookie field of generated codes use single quote, it's possible to escape string literal and inject arbitrary Node.js codes.
https://github.com/PortSwigger/copy-as-node-request/blob/b34456463310836e93365541189626909adc70bb/src/burp/BurpExtender.java#L123-L125
Step to reproduce
- Install Copy as Node Request extension.
- Open https://example.com
- Open DevTools and type
document.cookie = "test='/require('child_process').exec('calc.exe')//" - Enable intercept and reload the browser tab.
- Right click on intercepted request and click
Copy as Node.js Request. - Execute copied text in Node.js.
calc.exewill be popped up.
Impact
Remote code execution via Node.js code injection with user interaction.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The escapeQuotes function escaped double quotes but not single quotes, while the generated cookie code used single-quoted string literals, allowing string breakout and code injection.
Impact
An attacker could achieve remote code execution on the user's machine, but only with a significant amount of user interaction: the victim must copy the request as Node.js code and then run it.
What the attacker needed
Burp Suite with the extension installed; Victim sets a crafted cookie; Victim copies request as Node.js code; Victim runs the copied code
How it was found
- Install the Copy as Node Request extension in Burp Suite.
- Open a website in the browser.
- Set a crafted cookie value through the browser's developer console.
- Enable interception and reload the page.
- Right-click the intercepted request and choose Copy as Node.js Request.
- Run the copied code in Node.js, which executes the injected command.
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 report has not been written yet. The Original tab links to the source.
This is a tool that turns a captured web request into ready-to-run Node.js code. The tool put the cookie value into the generated code without properly escaping a quote character, so a malicious cookie could break out of the text and add its own code. If the user then ran the copied code, that extra code would run on their computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.