/

CVE-2026-44295

Severity:

HIGH RISK

(8.7)

Code Injection in protobufjs-cli Static Code Generator

CVE-2026-44295

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution in Generated JavaScript

Severity:

HIGH RISK

(8.7)

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 pbjs static code generation could emit unsafe JavaScript identifiers directly from schema-controlled names without proper sanitization.

When an attacker can influence the protobuf schema or JSON descriptor, they may craft names that inject arbitrary JavaScript into the generated output, leading to potential code execution when that code is built or run.

Affected context

The vulnerability appears in workflows where protobufjs-cli's pbjs tool is used to generate static JavaScript code from .proto schemas or JSON descriptors.

It becomes relevant when schema or descriptor files are sourced from, or modifiable by, untrusted or semi-trusted parties (for example, external contributors, automated conversion pipelines, or third-party specifications).

In these scenarios, attacker-controlled names for namespaces, enums, services, or related constructs can be embedded into the generated JavaScript and interpreted as code rather than inert identifiers.

Exploit preconditions

  • Attack surface: The code generation pipeline using pbjs to produce static JavaScript files.
  • Required access: Ability to create, modify, or supply protobuf schemas (.proto) or JSON descriptors consumed by pbjs.
  • Trigger point: Running pbjs to generate static JavaScript and then consuming or executing the generated code (e.g., bundling, serving, or running it in Node.js or the browser).
  • Why exploitation is possible: The generator embeds schema-derived names directly into JavaScript source without sufficient escaping or validation, allowing crafted names to break out of identifier contexts and introduce executable JavaScript.

Why this happens

The issue stems from treating schema-controlled names as safe identifiers in generated JavaScript, without enforcing identifier rules or applying proper escaping and validation.

This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where untrusted input influences code generation logic.

In this case, the static generator constructs JavaScript source by interpolating names (e.g., for namespaces, enums, or services) directly into the output; if those names contain characters or patterns that terminate identifiers or string literals, they can inject arbitrary code into the resulting file.

Potential impact

  • Injection of arbitrary JavaScript into generated client or server code.
  • Execution of attacker-controlled code when the generated module is loaded or executed.
  • Compromise of build pipelines that automatically generate and run code from provided schemas.
  • Potential lateral movement within environments that widely distribute or deploy generated artifacts.

General mitigation guidance

Effective mitigation focuses on ensuring that schema-derived names cannot alter the structure of generated JavaScript:

  • Treat schema and descriptor inputs as untrusted unless they are tightly controlled and verified.
  • Apply strict validation on all identifier-like fields before code generation; enforce character whitelists and language-specific identifier rules.
  • Use escaping routines that ensure generated identifiers and strings cannot break out of their expected syntactic context.
  • Separate code structure from data by avoiding raw string concatenation for code emission; use templating or AST-based code generators where possible.
  • Run code generation in a constrained environment, following least-privilege principles for build and CI systems so that any compromise has limited blast radius.

How teams detect issues like this

Detection commonly involves review of both generator behavior and schema inputs:

  • Static analysis or linters targeting the code generator to flag direct interpolation of untrusted names into code constructs (class names, property names, function declarations).
  • Code review guidelines that explicitly look for raw string-based code emission and missing identifier sanitization in tooling.
  • Schema validation policies (e.g., in CI/CD) that reject names containing characters outside an approved identifier set.
  • Automated scanning of generated artifacts for suspicious patterns, such as unexpected control characters, injected statements, or malformed declarations.
  • Use of security-focused build checks or SAST tools that can analyze generated code for injection markers and unusual syntactic constructs.

Sources

SourceLink
github.comgithub.com/protobufjs/protobuf.js/security/advisories/GHSA-6r35-46g8-jcw9

Frequently asked

questions

It can be, if an attacker can remotely provide or influence protobuf schemas or JSON descriptors that your build or generation pipeline consumes, for example via uploads, external repositories, or automated synchronization from third-party sources.

They need the ability to create or modify the .proto files or JSON descriptors that are fed into pbjs. Direct shell access is not required if your system ingests these files from external or user-facing interfaces.

The safest pattern is to sanitize and validate all schema-derived identifiers before inserting them into generated code, enforcing strict identifier rules and using safe code-generation techniques that avoid raw insertion of untrusted text into executable positions.

Future prevention relies on designing generators so that untrusted input never directly controls code structure: use AST-based generators, enforce strong validation on all code-influencing fields, and integrate security reviews and automated checks for code generation tools into your development and build processes.

Find out what's already
exploitable in your codebase.