/

CVE-2026-42290

Severity:

HIGH RISK

(7.8)

OS Command Injection in protobufjs-cli pbts JSDoc Invocation

CVE-2026-42290

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary OS Command 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

protobufjs-cli's pbts command previously constructed a shell command string from user-supplied file paths and executed it with child_process.exec, allowing shell metacharacters in paths to be interpreted by the shell.

An attacker who can influence or control the input file paths passed to pbts could inject additional commands, leading to arbitrary OS command execution under the privileges of the invoking user.

Affected context

This vulnerability affects workflows that use protobufjs-cli's pbts tool to generate TypeScript definitions, particularly when file paths are derived from external or user-controlled input.

The issue arises when:

  • pbts is invoked in build or generation scripts with file paths that may contain untrusted content, and
  • Those paths are passed into pbts versions that construct a shell command string and execute it via child_process.exec.

It is most relevant in CI/CD pipelines, code generation services, or build tools that automatically discover or accept user-specified .proto files and then invoke pbts.

Exploit preconditions

  • Attack surface: The pbts CLI command in protobufjs-cli invoked as part of local builds, CI/CD pipelines, or automated code generation.
  • Required access: Ability to supply or influence the input file paths used as arguments to pbts (e.g., by controlling proto filenames, directories, command-line arguments, or configuration used to build the command).
  • Trigger point: Execution of pbts that internally constructs a shell command and passes it to child_process.exec to run JSDoc.
  • Why exploitation is possible: File paths are interpolated into a shell command string without proper escaping or bypassing the shell; shell metacharacters (such as ;, &, |, backticks, or $()) within the path are interpreted by the shell as separate commands or operators rather than as literal characters.

Why this happens

The root cause is the construction of shell commands from untrusted data and their execution via a shell interpreter, mapping directly to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

Instead of invoking JSDoc using an argument-based API (e.g., child_process.spawn/execFile with an array of arguments), pbts concatenated input file paths into a command string and called child_process.exec. This pattern inherently trusts the content of file paths and fails to neutralize shell metacharacters.

As a result, any attacker-controlled input embedded in the command string can break out of the intended argument context and inject arbitrary shell commands that execute with the same permissions as the process running pbts.

Potential impact

  • Execution of arbitrary OS commands in the environment where pbts runs (developer workstation, build server, CI agent).
  • Compromise of CI/CD pipelines, including the ability to exfiltrate credentials, tokens, or other secrets available to the build process.
  • Unauthorized modification of generated artifacts, source trees, or build outputs.
  • Lateral movement within the developer or build infrastructure through abuse of the compromised process's network and filesystem access.
  • Planting of backdoors or malicious code into generated or packaged artifacts, contributing to software supply-chain compromise.

General mitigation guidance

Effective mitigation centers on eliminating direct shell invocation with untrusted input and strictly separating data from command interpretation:

  • Prefer process-spawning APIs that do not invoke a shell, such as child_process.spawn, spawnSync, or execFile, passing arguments as arrays so they are not parsed by a shell.
  • Avoid building command strings via concatenation or interpolation of file paths; treat file paths as data-only and let the OS handle them as discrete arguments.
  • Normalize and validate file paths before use, limiting to expected character sets and directory scopes to reduce the risk from unexpected metacharacters or traversal.
  • Run build and code-generation processes with least privilege, without unnecessary network or secret access, to limit impact if a similar issue arises.
  • Apply the same secure patterns in custom scripts or wrappers around pbts and other CLI tools, ensuring that any tool invocation that uses untrusted input never passes through a shell when avoidable.

How teams detect issues like this

Detection can focus on both code patterns and runtime behavior:

  • Static analysis: Configure rules to flag usages of child_process.exec (and similar shell-invoking APIs) where command strings are constructed via concatenation or template literals that include variables derived from user input, file names, or environment variables.
  • Code review: In build tooling, CLIs, and scripts, look specifically for patterns where:
  • Command strings are manually assembled (e.g., "jsdoc " + filePath),
  • File system input or configuration drives command construction, or
  • Shell metacharacters are not explicitly rejected or escaped.
  • Secure coding policies: Establish guidelines and linting rules that disallow shell-based command construction in build pipelines and enforce argument-array process invocation.
  • Runtime monitoring: On CI/CD infrastructure, monitor for unexpected outbound connections, anomalous process trees (e.g., shell processes spawned from node build processes), and unusual file modifications during code generation steps.
  • Automated review tools and CI-integrated scanners that understand Node.js patterns can help surface risky child_process usage before it reaches production workflows.

Sources

SourceLink
github.comgithub.com/protobufjs/protobuf.js/security/advisories/GHSA-f84p-cvgm-xgjj

Frequently asked

questions

It can be, but only if an attacker can indirectly control the file paths passed to pbts, such as through a web interface, API, or automated process that accepts user uploads or input and then invokes pbts with those paths. In purely local, manually driven usage, exploitation typically requires a local attacker or malicious project content.

The attacker must be able to influence or control the proto file paths or other arguments that pbts uses internally to build the JSDoc command. This could be through creating specially named files, manipulating configuration, or providing input to systems that wrap pbts.

The most robust fix is to remove shell involvement entirely by using APIs that execute programs with argument arrays and do not parse a command string via a shell. Avoid concatenating untrusted data into command strings and strictly separate command selection (trusted) from arguments (potentially untrusted, but treated as data).

Adopt secure coding standards for command execution, including prohibiting exec-style shell invocations with untrusted input, enforcing use of safer process-spawning APIs, and incorporating static analysis or linting rules that flag risky patterns. Additionally, review and harden build and generation pipelines, treating them as part of the attack surface for supply-chain security.

Find out what's already
exploitable in your codebase.