/

CVE-2026-41242

Severity:

CRITICAL RISK

(9.8)

Code Injection in protobufjs Decoding

CVE-2026-41242

Modified

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.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 versions prior to 8.0.1 and 7.5.5 contain a code injection flaw where attacker-controlled values in protobuf type definitions can be compiled into executable JavaScript.

When affected definitions are used for decoding, this injected code may execute within the application's runtime, enabling full remote code execution in environments that consume untrusted or indirectly influenced protobuf schemas.

Affected context

This vulnerability arises in applications that use protobufjs to compile and decode protobuf schemas which are, in whole or in part, influenced by untrusted or semi-trusted sources.

It is most relevant where:

  • Protobuf definitions are loaded at runtime (e.g., from configuration files, databases, network sources, or plugins), and
  • The type fields within message definitions can be modified or supplied by an attacker or a compromised upstream system.

In such contexts, the library's compilation and decoding mechanisms may treat these definitions as code templates, turning crafted schema data into executable JavaScript.

Exploit preconditions

  • Attack surface: The schema-loading or definition-compilation path in applications that use protobufjs to compile protobuf definitions into JavaScript.
  • Required access: Ability to inject, modify, or control protobuf definitions or their type fields before compilation/decoding (e.g., editing schema files, influencing remote schema registries, or man-in-the-middle of schema distribution).
  • Trigger point: Decoding operations that rely on the compiled protobuf definitions using protobufjs, which automatically execute the generated JavaScript code.
  • Why exploitation is possible: Earlier protobufjs versions treat type fields in definitions as inputs to code generation logic without sufficient sanitization or constraints, effectively allowing attacker-supplied text to be embedded into executable JavaScript functions.

Why this happens

The root cause is an unsafe code generation pattern where user-influenced protobuf type fields are incorporated into dynamically constructed JavaScript without robust validation or sanitization.

This maps directly to CWE-94: Improper Control of Generation of Code, where an application generates code based on external input and then executes it in the same trust context.

Instead of treating schema data as passive configuration, the library's compilation step effectively treats parts of the schema as code fragments, enabling arbitrary code injection when those compiled definitions are used during object decoding.

Potential impact

  • Remote code execution in the context of the process using protobufjs.
  • Full compromise of the affected service, including data exfiltration, modification, or destruction.
  • Use of the compromised service as a pivot point for lateral movement within the hosting environment or network.
  • Deployment of additional malware or backdoors within the application's infrastructure.
  • Integrity compromise of data processed through affected protobuf schemas.

General mitigation guidance

Effective mitigation focuses on reducing trust in schema inputs and removing opportunities for user-controllable data to influence code generation:

  • Prefer schema loading patterns where protobuf definitions are static, version-controlled assets, not dynamically retrieved from untrusted sources.
  • Constrain who and what can modify protobuf definitions by enforcing strict change-control and code review on schema files.
  • Avoid dynamic code generation based on raw schema fields; rely on APIs and code paths that treat schema definitions as data rather than templates for executable code.
  • Introduce validation layers that inspect protobuf definitions before compilation, rejecting or stripping suspicious type values or patterns.
  • Run services that process potentially untrusted schemas with least privilege, strong sandboxing, and process isolation, so that even if a similar issue arises, the blast radius is reduced.

How teams detect issues like this

Organizations can look for this class of issue using a mix of static and process-level checks:

  • Static analysis and code review:
  • Flag uses of dynamic code generation mechanisms in protobufjs integration code (e.g., constructing functions or using code templates from schema fields).
  • Review schema handling paths to ensure that type fields and related metadata are not sourced from untrusted locations without validation.
  • Policy and configuration checks:
  • Enforce policies that prohibit runtime downloading or accepting of arbitrary protobuf schema definitions in production systems.
  • Use build-time checks to ensure that only vetted, local schema files are compiled and packaged with the application.
  • Runtime monitoring:
  • Monitor for anomalous behavior in services using protobufjs, such as unexpected outbound network connections, unusual file system access, or invocation of system utilities during decoding operations.
  • Apply application-level logging around schema loading and compilation events to help identify when unapproved definitions are being processed.

Automated security testing tools, including SAST and configuration scanners, can help flag risky dynamic-code-generation patterns in the surrounding application code, even when they originate from third-party libraries.

Sources

SourceLink
access.redhat.comaccess.redhat.com/errata/RHSA-2026:21338
access.redhat.comaccess.redhat.com/errata/RHSA-2026:24977
access.redhat.comaccess.redhat.com/errata/RHSA-2026:26234
access.redhat.comaccess.redhat.com/errata/RHSA-2026:37275
access.redhat.comaccess.redhat.com/errata/RHSA-2026:62260
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-41242
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2459442
github.comgithub.com/protobufjs/protobuf.js/commit/086916b4a52c9f73ce88956edbb38fc902e54bbf
github.comgithub.com/protobufjs/protobuf.js/commit/535df444ac060243722ac5d672db205e5c531d75
github.comgithub.com/protobufjs/protobuf.js/commit/ff7b2afef8754837cc6dc64c864cd111ab477956
github.comgithub.com/protobufjs/protobuf.js/releases/tag/protobufjs-v7.5.5
github.comgithub.com/protobufjs/protobuf.js/releases/tag/protobufjs-v8.0.1
github.comgithub.com/protobufjs/protobuf.js/security/advisories/GHSA-xq3m-2v4x-88gg
github.comgithub.com/protobufjs/protobuf.js/tree/v6.11.6
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-41242.json

Frequently asked

questions

It can be, if an attacker can remotely influence or supply protobuf definitions or their type fields that your service then compiles and uses for decoding. In such deployments, sending or controlling malicious schema content may achieve remote code execution.

The attacker needs the ability to alter or provide protobuf definitions used by protobufjs—this could be write access to schema files, control over a schema registry or configuration source, or a position on the network where they can tamper with schema distribution.

The safest pattern is to eliminate or strictly limit dynamic schema inputs: treat protobuf definitions as static, trusted assets, and avoid any code-generation path that incorporates unvalidated schema fields into executable JavaScript. Additionally, ensure schema changes go through standard code review and testing.

Adopt a design principle that external data—schemas included—must never directly influence code generation or evaluation. Use libraries and patterns that separate data from code, enforce validation on all configuration-like inputs, and incorporate security-focused reviews and automated checks around any dynamic compilation or evaluation features in third-party components.

Find out what's already
exploitable in your codebase.