/

CVE-2026-76833

Severity:

HIGH RISK

(7.8)

Code Injection (CWE-95) in @cgauge/yaml npm Package

CVE-2026-76833

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-95

Impact:

Arbitrary JavaScript Execution

Severity:

HIGH RISK

(7.8)

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

The @cgauge/yaml npm package can execute attacker-controlled JavaScript when parsing YAML containing its custom !js tag. Applications that parse untrusted YAML may expose the Node.js process to arbitrary code execution, including filesystem, network, environment, and subprocess operations.

Affected context

The vulnerability occurs in applications that use @cgauge/yaml to parse YAML from untrusted or insufficiently trusted sources. Risk is present when the parser recognizes the custom !js tag and invokes its construct callback during document processing, particularly when the parsing process runs with meaningful application or operating-system privileges.

Exploit preconditions

  • Attack surface: YAML parsing performed by an application using @cgauge/yaml
  • Required access: Ability to supply or modify YAML content that the application will parse
  • Trigger point: Processing of a document containing the custom !js tag
  • Why exploitation is possible: The tag's construct callback unconditionally evaluates attacker-controlled string values, without a safe-mode alternative or opt-out mechanism

Why this happens

The underlying bug is direct evaluation of untrusted YAML-derived data. The custom !js tag maps attacker-controlled strings to a construct callback that invokes eval(), treating serialized input as executable JavaScript rather than inert data. This behavior maps to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, because untrusted input reaches a dynamic code-evaluation operation without effective restriction.

Potential impact

  • Attackers may execute arbitrary JavaScript in the Node.js process
  • Attackers could read environment variables and application secrets
  • Attackers may read, modify, or delete accessible files
  • The process could initiate network connections or execute subprocesses
  • Applications could experience data theft, tampering, or service disruption

General mitigation guidance

Mitigation generally centers on ensuring that untrusted YAML is not processed by a parser that evaluates embedded code.

Common defensive patterns include:

  • Replacing code-evaluating YAML features with data-only parsing behavior
  • Using a parser with safe-by-default semantics and no executable custom tags
  • Treating YAML from external users, integrations, or repositories as untrusted
  • Validating parsed data against a strict schema and rejecting unexpected tags
  • Isolating parsing workloads with least-privilege identities, restricted filesystem access, and limited network permissions
  • Avoiding reliance on application-level validation as a substitute for disabling dynamic evaluation

How teams detect issues like this

Detection can include static analysis and dependency review for uses of eval(), dynamic JavaScript evaluation, and YAML custom-tag constructors that process input values. Code review should flag parser callbacks that convert serialized data into executable code, especially when no explicit trust boundary or safe parsing mode exists. Runtime policy can monitor unexpected child-process creation, filesystem access, or outbound network activity from YAML-processing components. Automated security review tools may help identify dynamic evaluation and risky parser integrations.

Sources

SourceLink
gist.github.comgist.github.com/arjunjaincs/35da3a80b4b16f324f194acec18489ba
github.comgithub.com/cgauge/packages
vulncheck.comvulncheck.com/advisories/cgauge-yaml-npm-package-arbitrary-code-execution-via-eval-yaml-tag

Frequently asked

questions

It can be exploitable remotely when an application parses YAML supplied through a network-accessible endpoint, upload workflow, integration, or other attacker-influenced channel. Applications that only parse trusted, integrity-controlled YAML have a narrower exposure.

The attacker needs the ability to provide or alter YAML that the vulnerable application will parse. Direct access to the host is not inherently required if the application accepts untrusted YAML remotely.

Use a data-only YAML parser that does not evaluate embedded JavaScript, remove executable custom tags, and reject unexpected tags before processing input.

Establish a strict trust boundary for serialized data, prohibit dynamic evaluation in parsers, enforce schema and tag allowlists, review dependency behavior, and run parsing components with minimal privileges.

Find out what's already
exploitable in your codebase.