/

CVE-2026-44291

Severity:

HIGH RISK

(8.1)

Code Injection in protobufjs Code Generation

CVE-2026-44291

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution in Generated JavaScript

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

protobufjs used plain JavaScript objects with inherited prototypes for internal type lookup tables when compiling protobuf definitions into encode/decode functions.

In environments where Object.prototype is already polluted, attacker-controlled inherited properties can be treated as valid protobuf type metadata, causing untrusted strings to be emitted into generated JavaScript code and enabling potential code injection.

Affected context

This vulnerability affects applications that use protobufjs code generation (static or runtime) in JavaScript/TypeScript environments where Object.prototype may be modified by other code or dependencies.

It is most relevant when:

  • protobufjs compiles .proto definitions into JavaScript encode/decode functions
  • The runtime environment allows or has already experienced prototype pollution
  • Generated code or code snippets are treated as executable JavaScript, either directly or via dynamic evaluation patterns

Exploit preconditions

  • Attack surface: Applications using protobufjs to generate or compile protobuf encode/decode functions.
  • Required access: Ability to influence Object.prototype or otherwise introduce polluted inherited properties into the process (e.g., via another vulnerability, malicious dependency, or untrusted plugin/module).
  • Trigger point: Execution of protobufjs compilation or generation routines that read from internal type lookup tables backed by plain objects.
  • Why exploitation is possible: The internal lookup tables rely on plain objects that inherit from Object.prototype. If the global prototype is polluted with attacker-controlled properties, those inherited keys can be resolved as legitimate type information, and their values can be emitted as part of generated JavaScript code, enabling injection of untrusted strings into executable contexts.

Why this happens

The core issue stems from using plain JavaScript objects (with default prototypes) as lookup tables for protobuf type metadata, instead of using structures that do not inherit from Object.prototype.

Because these tables inherit from the global object prototype chain, any pre-existing prototype pollution can introduce attacker-controlled properties that appear as valid lookup results.

When protobufjs translates these lookups into generated encode/decode functions, it effectively embeds unvalidated, inherited values into JavaScript code, aligning with CWE-94: Improper Control of Generation of Code ('Code Injection'), where untrusted input influences the construction of executable code.

Potential impact

  • Injection of attacker-controlled strings into generated JavaScript encode/decode functions
  • Execution of arbitrary code if the generated output is evaluated or executed in a trusted context
  • Tampering with serialization/deserialization logic, potentially leading to data corruption or logic manipulation
  • Escalation of impact when combined with other vulnerabilities that allow prototype pollution or dynamic code evaluation

General mitigation guidance

Mitigations generally focus on decoupling internal data structures from the global prototype chain and reducing trust in dynamically generated code:

  • Use prototype-free data structures (e.g., objects created with null prototypes or Map-like structures) for lookup tables that may be influenced by external input.
  • Avoid designing systems where generated JavaScript code is treated as executable content without strict validation and sanitization.
  • Reduce or eliminate dynamic evaluation patterns (such as eval-like constructs) when working with generated code artifacts.
  • Apply defense-in-depth by hardening the environment against prototype pollution and ensuring shared prototypes are not used as a communication channel for untrusted data.

How teams detect issues like this

Detection typically involves both code-level and environment-level analysis:

  • Static analysis rules that flag use of plain objects as lookup tables in security-sensitive code generation paths, especially where Object.prototype inheritance is intact.
  • Code review practices that look for patterns where untrusted values influence generated code templates, function bodies, or dynamic function constructors.
  • Security testing for prototype pollution vectors, including automated tests that inject unexpected properties into Object.prototype and observe resulting behavior in protobufjs-based components.
  • Use of automated security review tools or linters configured to detect dangerous combinations of prototype inheritance and code generation.

Sources

SourceLink
github.comgithub.com/protobufjs/protobuf.js/security/advisories/GHSA-75px-5xx7-5xc7

Frequently asked

questions

Exploitability hinges on two conditions: the presence of prototype pollution affecting Object.prototype and the use of protobufjs code generation in a way that treats generated output as executable JavaScript. When both conditions are met, an attacker may influence generated functions and potentially achieve code execution.

An attacker generally needs a way to introduce or control properties on Object.prototype, which often requires another flaw such as a prototype pollution vulnerability or a malicious dependency. Direct exploitation without such influence is unlikely.

The safest pattern is to ensure that internal lookup tables and similar structures do not inherit from Object.prototype, typically by using prototype-less objects or dedicated map structures, and by strictly separating untrusted data from any code generation logic.

To prevent similar issues, design code generation paths so they cannot be influenced by inherited properties, avoid reliance on global prototypes for internal data structures, minimize dynamic code execution mechanisms, and include automated checks that detect prototype-dependent lookups and untrusted input flowing into generated code.

Find out what's already
exploitable in your codebase.