Skip to content
RCE Write-up Intermediate

Critical binary-parser Flaw Enables JavaScript Injection via Malicious Parser Definitions

Binary-parser before 2.3.1 inserts user-controlled string options such as length, key, tag, offset and namely() aliases directly into generated JavaScript without validation. An attacker who controls parser definitions can therefore execute arbitrary JavaScript in the Node.js process when the parser is compiled.

[email protected] (The Hacker News) Follow

Published on thehackernews.com

{{media:0}}

The Hacker News, on thehackernews.com

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, string options from parser definitions were concatenated into generated JavaScript source without being validated as plain identifier paths.

Impact

An attacker controlling parser definitions could execute arbitrary JavaScript in the host Node.js process when the parser is compiled; parsing untrusted binary data with a trusted definition is not affected.

What the attacker needed

Control over parser definitions

The fix

Version 2.3.1 was released and now validates these options as identifier paths, rejecting expressions such as arithmetic and requiring a function instead.

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.

A library called binary-parser builds JavaScript code from a description of a binary format. If that description contains special text in certain fields, the library treats it as code and runs it. Someone who can supply the description can therefore run their own code inside the program.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by [email protected] (The Hacker News)

View all

5 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.