# CVE-2026-134814 — binary-parser: JavaScript injection through unsanitized string options
[ |
| **Fixed in** | **2.3.1** — commit `110206b` (`Validate string options used in generated code`, GHSA-hhq6-2gpv-hrf4) |
| **CWE** | CWE-94 (Improper Control of Generation of Code) |
| **Impact** | String-valued parser options (`length`, `lengthInBytes`, `offset`, `tag`, `key`) were interpolated verbatim into generated JavaScript. An application that builds a parser from attacker-controlled option strings executes arbitrary JavaScript in its own context when parsing data — here demonstrated by setting `globalThis.INJECTED` from the generated code |
| **Vector** | attacker-controlled string option passed to a parser builder at runtime |
| **Trigger** | `length: "x+(globalThis.INJECTED=1,0)"` on a `buffer()` parser |
return this.generateVariable(val); // raw string becomes parser code
// fixed (commit 110206b, verbatim logic)
const IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
function sanitizeReference(ref: string): string {
if (!ref.split(".").every((s) => IDENTIFIER.test(s))) {
throw new Error(`Invalid reference: ${ref}`);
binary-parser builds a JavaScript function from a parser definition and
compiles it. String options were treated as expressions or variable
references without validation, so a crafted string containing JavaScript
operators became executable code in the generated function. The fix
validates every such string as a dotted JavaScript identifier before use and
also validates `namely()` aliases, rejecting expressions with a descriptive
| `bp-vuln` | `cve-2026-134814:vuln` | real `binary-parser` 2.3.0 from npm |
| `bp-fixed` | `cve-2026-134814:fixed` | real `binary-parser` 2.3.1 from npm |
| `poc` | `cve-2026-134814-poc:local` | stdlib-only Python driver |
The harness uses the exact payload from the upstream regression test and a
numeric `length: 2` control. Both sides run the same harness; only the npm
./run-lab.sh build # builds both sides (node:22-alpine + pinned npm packages)
./run-lab.sh up # cve134814lab network: bp-vuln / bp-fixed
* **check** — exit 1 when attacker JavaScript executes, 0 when the option is
rejected; 3 no worker, 2 unreachable/indeterminate.
* **exploit** — narrated chain: hostile option string → generated parser code
→ executed expression → application-context code execution.
* **probe** — malicious and benign numeric options.
* **mitigation** — 2.3.1 / commit `110206b` / `sanitizeReference()`.
A standalone full-chain exploit ships at `exploit/exploit.py`:
python3 exploit/exploit.py --host=bp-vuln
# exit 1 on confirmed injection, 0 on a safe target
| option | `bp-vuln` (2.3.0) | `bp-fixed` (2.3.1) |
| `length: "x+(globalThis.INJECTED=1,0)"` | **`globalThis.INJECTED === 1`** | **`Invalid reference: ...`** |
| `length: 2` (control) | parses | parses |
Captured runs: `evidence/check-*-run.txt`, `evidence/exploit-*-run.txt`,
`evidence/probe-*-run.txt`, `evidence/mitigation-*-run.txt`,
`evidence/exploit-standalone-run.txt`, `evidence/exploit-standalone-fixed-run.txt`,
`evidence/versions.txt`, `evidence/0day-sweep.txt`.
* Podman (or Docker); bounded containers on the isolated `cve134814lab`
network; pinned npm packages in the lab images.
* Real-world exploitation requires an application to construct parser
definitions from attacker-controlled strings and parse data with them.
## 7. Additional findings (0-day sweep on the fixed line)
`sanitizeReference()` is applied to every string option that reaches
generated code, and `namely()` aliases are validated as identifiers. Dotted
identifier references still work on the fixed build, so normal parser usage is
unchanged. No residual code-generation channel was found on the fixed line in
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
poc/poc.py the PoC (check / exploit / probe / mitigation)
exploit/exploit.py standalone full-chain exploit
lab/harness.js upstream regression payload + control
lab/lab.Dockerfile builds both sides from pinned npm packages
lab/service.js HTTP wrapper (POST /parse), child-process isolation
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)
* CVE record —
* GitHub advisory —
* Fix commit —
