/

CVE-2026-134814

Severity:

HIGH RISK

(8.1)

Code Injection (CWE-94) in binary-parser Definitions

CVE-2026-134814

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary JavaScript execution

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

binary-parser has a code injection vulnerability when parser definitions contain attacker-controlled string options that are used during parser compilation. If an attacker can influence those definitions, crafted values may cause arbitrary JavaScript to execute in the Node.js process.

Affected context

The issue affects binary-parser versions before 2.3.1 when parser definitions are compiled using string-typed options that are passed through Context.generateOption() without adequate validation. Relevant options include length, lengthInBytes, key, tag, offset, and aliases created with namely(). Risk depends on whether an untrusted party can supply or modify parser definitions.

Exploit preconditions

  • Attack surface: Applications that use binary-parser to compile parser definitions.
  • Required access: The ability to control or influence one or more string-typed parser option values; the description does not specify a particular access level.
  • Trigger point: Compilation of a parser containing an attacker-controlled option or alias.
  • Why exploitation is possible: Option values are passed into code-generation logic without sufficient validation, allowing injected JavaScript to become executable code.

Why this happens

The underlying issue is improper neutralization of input used in dynamically generated code. Context.generateOption() handles string-typed values without adequately restricting how they affect generated JavaScript. This maps to CWE-94: Improper Control of Generation of Code ('Code Injection').

Potential impact

  • An attacker may execute arbitrary JavaScript in the Node.js process.
  • The process could be used to access data or resources available to the application.
  • Application integrity or availability could be affected.
  • The consequences could extend to connected systems, depending on the process's permissions and environment.

General mitigation guidance

Defensive approaches focus on preventing untrusted values from becoming executable code:

  • Prefer parser construction patterns that do not generate code from input strings.
  • Treat parser definitions and aliases from external or user-controlled sources as untrusted.
  • Validate option types and values against strict schemas and allowlists before compilation.
  • Where dynamic generation is necessary, use safe structured representations and context-appropriate escaping rather than direct string composition.
  • Run the Node.js process with only the permissions and access it needs.

How teams detect issues like this

  • Use static analysis to identify dynamic code generation and string interpolation involving parser options.
  • Review paths from external inputs or configuration into Context.generateOption() and parser compilation.
  • Check for insufficient validation of length, lengthInBytes, key, tag, offset, and namely() alias values.
  • Apply code-review and CI policies that restrict unsafe dynamic code generation and require validation of parser definitions.

Sources

SourceLink
github.comgithub.com/keichi/binary-parser/blob/v2.3.0/lib/binary_parser.ts#L26-L35
github.comgithub.com/keichi/binary-parser/commit/110206bb126a80071158fb0e2e3d7cc658f2bfe4
github.comgithub.com/keichi/binary-parser/commit/4b26e04c396253e704ad8e41b928d9e31316f62e
github.comgithub.com/keichi/binary-parser/security/advisories/GHSA-xmxc-6c22-m377
vulncheck.comvulncheck.com/advisories/binary-parser-before-2.3.1-code-injection-via-string-typed-parser-options

Frequently asked

questions

It concerns parser definitions compiled by binary-parser when relevant string-typed options can be controlled by an attacker. The impact depends on how the application obtains and compiles those definitions.

An attacker needs a way to influence parser definition values. The specific access requirements depend on the application's configuration and input pathways.

Avoid turning untrusted strings into generated code. Validate definitions against strict schemas and use safe, structured alternatives to dynamic code generation.

Treat externally sourced parser definitions as untrusted, review data flows into code-generation functions, and enforce static-analysis and code-review checks for unsafe dynamic generation.

Find out what's already
exploitable in your codebase.