Skip to content

binary-parser compiles your parser into JavaScript. if a stranger writes the parser, a stranger writes the JavaScript. CVE-2026-134814, and the second try at fixing it

binary-parser CVE-2026-134814: Parser Definition Code Injection, Fix 2.3.1

binary-parser compiles your parser into JavaScript. if a stranger writes the parser, a stranger writes the JavaScript. CVE-2026-134814, and the second try at fixing it

binary-parser is the npm library you reach for when you need to turn a pile of bytes (a packet, a file header, a Modbus frame) into an object, fast. it is fast because it does not interpret your parser definition at runtime. it generates JavaScript source from the definition and compiles it. that is a great design right up until the definition comes from someone else. CVE-2026-134814 is the bug where a set of string options went into that generated source unvalidated. it is also, per the maintainer, the leftovers from the earlier fix for the same class of bug in 2.3.0. upgrade to 2.3.1. then go find out who writes your parser definitions.

The short version. CVE-2026-134814, keichi/binary-parser on GitHub, binary-parser on npm (31,002 downloads the week of Nov 16 to 22, per the npm API). advisory GHSA-xmxc-6c22-m377 (published 2026-11-11): affected <= 2.3.0, patched 2.3.1. condition: “An attacker who controls a parser definition (e.g. schema- or JSON-driven parsers) could execute arbitrary JavaScript.” and the line that matters most: “Parsing untrusted binary data with a trusted parser definition is not affected.” CVSS from VulnCheck (the CNA): 4.0 9.2 (AC:H/AT:P), 3.1 8.1 (AC:H). we found no public reports of exploitation, and it is not in CISA KEV. related: CVE-2026-1245, fixed in 2.3.0.

how a parser becomes code

you write something like this, and it is lovely:

const { Parser } = require("binary-parser");
const header = new Parser()
  .endianness("big")
  .uint16("len")
  .string("name", { length: "len" });

that length: "len" is a reference: “use the value of the field called len that I parsed earlier.” when you call parse(), the library compiles the whole chain into a JavaScript function, and that reference ends up as a variable lookup inside the generated source. the speed comes from exactly this step. so does the bug.

per the GHSA, these string-typed options were “interpolated verbatim into the generated parser source”:

  • length of string, buffer, array, wrapped and seek
  • lengthInBytes and key of array
  • tag of choice
  • offset of pointer
  • the alias passed to namely()

NVD’s description, from VulnCheck: attackers controlling parser definitions can “inject JavaScript through string-typed options passed unvalidated by Context.generateOption(),” executing “arbitrary JavaScript in the Node.js process when the parser is compiled.” that is all we are going to say about the how. if your threat model includes “someone hands us a parser definition,” you already have enough to be worried.

the fix, read from the commits

the advisory and NVD point at two commits on GitHub:

  • 110206b (2026-10-16), “Validate string options used in generated code.” it adds an IDENTIFIER regex and a sanitizeReference() function that splits on dots and requires every segment to be a plain identifier. generateOption() now runs string values through it. namely() now validates its alias. the hash-key path for arrays validates key.
  • 4b26e04 (2026-10-30), “Validate length of zero-terminated strings.” one line: the zero-terminated string path used this.options.length raw, and now goes through ctx.generateOption() like everything else. so the first fix missed a spot, and the maintainer caught it two weeks later. that is how fixes go. it is also why “we patched the injection” is a sentence to verify, not believe.

2.3.1 hit npm on 2026-11-11 at 02:58 UTC. the GHSA went up at 03:00 UTC. NVD published the CVE on 2026-11-22. that order, patch first and paperwork second, is the correct one, and we want it on record that an open-source maintainer did it right.

the sequel problem: CVE-2026-1245

this is the second code-injection CVE published for this library this year. CVE-2026-1245, per NVD, let “untrusted values … used in parser field names or encoding parameters” execute JavaScript, fixed in 2.3.0. npm shows 2.3.0 was released 2025-11-26, and NVD published the CVE on 2026-01-20. (some coverage says the fix landed in January. the registry says November.) NVD carries a CVSS 3.1 6.5 for it from CISA’s ADP. the GHSA for the new one says it directly: “The fix for CVE-2026-1245 validated field names and encodings, but other string-typed options were still interpolated verbatim.”

so the honest summary is: 2.3.0 closed one door, 2.3.1 closes the rest of the doors the maintainer found. if you are still below 2.3.0, you have both.

who is actually exposed

this is where most coverage of a “9.2 critical” stops reading, so we will be slow about it.

  • not affected (per the maintainer): a parser definition written by your developers, in your code, parsing hostile bytes from the network. that is the normal use, and it is fine. the bytes are data. the definition is code. the bug is in the code path.
  • affected: anything that builds a Parser from input someone else controls. the GHSA’s example is “schema- or JSON-driven parsers.” think: a protocol analyzer that loads user-supplied format definitions, an IoT gateway that lets tenants upload a frame layout, a plugin system, a “describe your binary format in YAML” feature, a multi-tenant telemetry pipeline.
  • the gray area: definitions loaded from a config file or a database. whether that is “trusted” depends on who can write the file or the row. if the answer includes a web form, it is not trusted.

the scores reflect this. VulnCheck’s vectors use high attack complexity (and in 4.0, attack requirements present), because the attacker needs that unusual position. it is a 9.2 when it applies. it often does not apply. both of those things are true, and your vulnerability scanner will only tell you the first one.

the defensive kit, running

three checks. first, the lockfile and what is actually on disk, including transitive copies, because the vulnerable copy is rarely the one in your own package.json:

Kali terminal running bp-134814-check.py lock on a lab package-lock.json, flagging binary-parser 2.3.0 at the root and under modbus-frames as CVE-2026-134814 and 2.2.1 under pcap-decoder-lite as both CVE-2026-134814 and CVE-2026-1245, then tree mode on node_modules finding the root copy already at 2.3.1, with a comment that the lockfile and disk disagree.

note the lab drift: the lockfile pins the root copy at 2.3.0, but node_modules has 2.3.1, because somebody ran an install and never committed the lockfile. your next CI build will happily reinstall 2.3.0. trust neither, fix both.

second, the question the CVE actually asks: who writes your parser definitions? the source check is a heuristic. it flags files that import binary-parser, pull in outside data (JSON.parse, request bodies, file reads), and pass non-literal values to the risky options or to namely(). it marks those REVIEW. it marks files with literal definitions low. it proves nothing on its own. a human reads the REVIEW list.

Kali terminal running bp-134814-check.py src on a lab app, marking schema-loader.js for review because it builds a parser from a JSON request body with non-literal length and namely values, and marking header.js low because its definition is literal and trusted.

third, the upgrade path, including the overrides you need for transitive copies:

Kali terminal running bp-134814-fix.sh, printing npm install binary-parser at caret 2.3.1, a note that 3.0.0 is ESM only and needs Node 22.12 or later, npm overrides, yarn resolutions and pnpm overrides snippets, npm ls verification, and the behavior change that expressions like len minus 1 now throw and should become functions.

what will break when you upgrade

from the 2.3.1 release notes: these options “now only accept identifier paths (e.g. "len", "$parent.len").” expressions such as "len - 1" are rejected at compile time. if your codebase used string expressions as a shortcut, your parsers will throw on first compile after the upgrade. the maintainer’s answer is to use a function instead:

// before (now throws in 2.3.1+)
.string("name", { length: "len - 1" })
// after
.string("name", { length: function () { return this.len - 1; } })

do the search before the upgrade, not during the incident bridge.

and if you are tempted by the shiny new major: 3.0.0 landed on 2026-11-22. per its release notes it is ESM only, requires Node.js 22.12 or later, and adds stricter validation, including rejecting __proto__ as an associative array key. we confirmed the 3.0.0 package on npm still contains the 2.3.1 reference validation. it is a fine destination. it is not a patch you apply on a Monday.

what to do, in order

  1. find every copy: npm ls binary-parser --all, or the kit’s lock and tree modes. pin to ^2.3.1 with overrides (npm), resolutions (yarn) or pnpm.overrides for transitive copies.
  2. grep for string expressions in the affected options and convert them to functions.
  3. find the code that builds parser definitions from outside input. if it exists, the upgrade is urgent. then ask whether it should exist at all. a definition is code. accepting code from users is a product decision, and it should be made on purpose, with sandboxing, not inherited from a “flexible schema” feature request.
  4. if you maintain a package that depends on binary-parser, bump your dependency floor so your users stop resolving 2.3.0.

the industry part, since we have to

every code-generation library eventually learns the same lesson: anything that ends up inside generated source is code, no matter what the docs call it. “option,” “field name,” “alias,” “length.” the attacker does not care what the parameter is called. this library learned it twice in one year, and fixed it twice, quickly, in public, with tests. that is the good outcome.

the bad outcome is downstream. 31,000 weekly downloads, a long tail of transitive copies pinned by packages nobody has touched since 2022, and a scanner that will light up red on every one of them while saying nothing about whether anyone can reach the vulnerable path. half your team will panic. the other half will mark it “not exploitable” without checking. the correct answer is in the GHSA, in one sentence, and it requires reading.

download the Kali defensive kit

binary-parser-cve-2026-134814-defensive-kit.zip contains bp-134814-check.py (lock, tree and src modes), bp-134814-fix.sh (prints upgrade and override steps, applies nothing), a README, and the synthetic lab app from the screenshots. fixed version 2.3.1, the CVE-2026-1245 floor at 2.3.0, and the 3.0.0 caveats are baked in. no network connections, no injection strings. lab-only, defensive use.

sources