r/programming • • 1d ago

High-Severity Code Injection Flaw in binary-parser: What Node.js Developers Need to Know

https://kylesinvestigation.com/2026/11/23/high-severity-code-injection-flaw-in-binary-parser-what-node-js-developers-need-to-know/
0 Upvotes

8 comments sorted by

View all comments

Show parent comment

2

u/backwrds 1d ago edited 1d ago

I really don't think it's like either of those, since this library is for creating custom binary protocols, and the only way it's vulnerable is if you use untrusted input to create the parser

typical (totally safe and reasonable) usage:

const parser = new Parser().uint8('n');
app.get('/', (req, res) => {
    console.log(parser.parse(req.body))
    res.send('ok')
})

"vulnerable" usage

app.get('/', (req, res) => {
    const { grammar, input } = JSON.parse(req.body);
    const parser = grammar.reduce((parser, { name, type }) => {
        return parser[type](name); // don't do this.
    }, new Parser());
    res.send(parser.parse(input))
});

TBF it is a pretty bad library that basically just wraps eval with convenience methods, but unless one is using it in an obviously unsafe way, it's not a security risk. Another example to drive the point home:

JSON.parse(data); // generally recognized as safe
JSON.parse(data, eval); // someone is doing something *incredibly* wrong

giving the latter a CVSS score is absurd, and a waste of everyone's time.