Vulnerabilities

Critical RCE Vulnerability in protobuf.js Allows JavaScript Code Injection

April 18, 2026 16:00 · 4 min read
Critical RCE Vulnerability in protobuf.js Allows JavaScript Code Injection

What Is protobuf.js and Why Does It Matter?

protobuf.js is a JavaScript implementation of Google's Protocol Buffers, one of the most heavily downloaded packages on the Node Package Manager (npm) registry. The library averages close to 50 million weekly downloads, making it a foundational component across a wide range of software ecosystems. Developers rely on it for inter-service communication, real-time applications, and the efficient storage of structured data in databases and cloud environments.

Given that scale, a critical flaw in protobuf.js carries significant supply-chain implications — any application that processes protobuf schemas could be exposed if it runs a vulnerable version of the library.

The Vulnerability: Unsafe Dynamic Code Generation

Application security company Endor Labs published a report on Friday, April 18, 2026, detailing a remote code execution (RCE) vulnerability in protobuf.js. The flaw has not yet been assigned an official CVE number; it is currently tracked under the GitHub identifier GHSA-xq3m-2v4x-88gg.

According to Endor Labs, the root cause is unsafe dynamic code generation. The library constructs JavaScript functions from protobuf schemas by concatenating strings and then executing them via the Function() constructor. Critically, the library does not validate schema-derived identifiers — such as message names — before passing them into this process.

Because those identifiers go unchecked, an attacker can craft a malicious schema that injects arbitrary code into the generated function. That injected code runs the moment an application processes a message using the compromised schema.

Scope of Potential Exploitation

The consequences of successful exploitation are severe. Endor Labs outlines several potential outcomes:

Endor Labs warns that "exploitation is straightforward," a concern underscored by the minimal proof-of-concept (PoC) code included in the security advisory. That PoC is now publicly available. Despite this, no active exploitation in the wild has been detected as of the report's publication date.

Affected Versions and Available Patches

The vulnerability affects protobuf.js versions 8.0.0 and 7.5.4 and all earlier releases. Endor Labs recommends upgrading to the following patched versions immediately:

The underlying patch works by sanitizing type names, specifically stripping non-alphanumeric characters to prevent an attacker from closing the synthetic function and inserting malicious logic. The protobuf.js maintainers published the fix to GitHub on March 11, 2026, following a responsible disclosure report submitted by Endor Labs researcher and security bug bounty hunter Cristian Staicu on March 2, 2026.

The Patch Has Limits — A Longer-Term Fix Is Needed

While the current patch addresses the immediate attack surface, Endor Labs notes it is not a definitive long-term solution. The advisory states that a more robust fix would be to stop routing attacker-reachable identifiers through the Function() constructor entirely, eliminating the dynamic code generation pattern at its source rather than simply sanitizing its inputs.

Recommended Mitigations for Administrators and Developers

Beyond upgrading to the patched versions, Endor Labs offers several additional guidance points for system administrators and developers:

  1. Audit transitive dependencies — protobuf.js is frequently pulled in as a dependency of other packages, so organizations should verify their full dependency tree for vulnerable versions.
  2. Treat schema-loading as untrusted input — even schemas sourced from seemingly internal or controlled systems should be handled with appropriate validation and sandboxing.
  3. Prefer precompiled or static schemas in production — moving away from runtime schema loading where possible reduces the attack surface considerably.

With nearly 50 million downloads occurring every week, the window between public PoC availability and active exploitation in the wild can close quickly. Organizations depending on protobuf.js in any capacity are strongly advised to apply the available patches without delay.


Source: BleepingComputer

Source: BleepingComputer

Powered by ZeroBot

Protect your website from bots, scrapers, and automated threats.

Try ZeroBot Free