Apr 21, 2026·5 min read·121 visits
protobufjs versions prior to 7.5.5 and 8.0.1 suffer from a code injection vulnerability (CWE-94) during dynamic code generation. Attackers can achieve RCE by supplying crafted Protobuf definitions containing unsanitized JavaScript syntax in type names.
A critical remote code execution vulnerability in the protobufjs package allows unauthenticated attackers to execute arbitrary JavaScript within the Node.js runtime environment via maliciously crafted schema definitions.
The protobufjs library is a widely adopted Node.js package that provides protocol buffer serialization and deserialization capabilities. Many modern architectures rely on protocol buffers for efficient inter-service communication and data storage. The library handles parsing .proto files and JSON descriptor objects to construct message schemas dynamically at runtime.
CVE-2026-41242 is a critical Improper Control of Generation of Code vulnerability (CWE-94) located within the schema processing logic of the package. The flaw manifests when the library dynamically generates encoding and decoding routines to optimize processing performance. This optimization technique relies on Just-In-Time (JIT) compilation of JavaScript strings.
An attacker who can control the schema definition processed by the application can inject arbitrary JavaScript into these generated routines. Execution of this injected code occurs within the context of the running Node.js process. This results in complete system compromise if the node process runs with sufficient privileges.
To achieve high throughput, protobufjs constructs specialized encoding and decoding functions on the fly for each processed schema. The library concatenates static JavaScript code templates with dynamic variables derived from the parsed schema. These concatenated strings are subsequently instantiated into executable routines using the JavaScript new Function() constructor.
The vulnerability stems from an absolute lack of input sanitization during this string concatenation phase. The library directly interpolates metadata properties extracted from the user-supplied schema into the executable code string. Specifically, the type and name properties of a nested schema type are placed into the code without escaping or validation.
When the JavaScript runtime attempts to compile the output of the new Function() constructor, it parses the entire string as code. An attacker can construct a schema where the name property contains characters that break out of the intended string or variable context. By inserting characters such as closing parentheses, semicolons, and curly braces, the attacker defines new lexical boundaries and inserts arbitrary executable statements.
The vulnerability was addressed by introducing a rigorous sanitization step within the type instantiation logic. Maintainers released patch commits, specifically 535df444ac060243722ac5d672db205e5c531d75 for the main branch and ff7b2afef8754837cc6dc64c864cd111ab477956 for the 7.x release line.
The core fix resides in src/type.js. The vulnerable implementation accepted the name parameter directly from the parsed descriptor and passed it unmodified into the namespace constructor. The patched version applies a strict regular expression filter to strip any non-alphanumeric characters.
// src/type.js - Patched Implementation
function Type(name, options) {
+ // Strips non-alphanumeric/underscore characters to prevent syntax breakout
+ name = name.replace(/\W/g, "");
Namespace.call(this, name, options);
// ...This mitigation forces the name string to conform strictly to valid JavaScript identifier constraints. Any structural characters required for an injection attack are silently removed before the string reaches the new Function() sink. The following diagram illustrates the patched execution flow.
Exploiting CVE-2026-41242 requires the attacker to supply a malicious Protobuf descriptor to a vulnerable application endpoint. The attack sequence typically begins with the application invoking protobuf.Root.fromJSON() or parsing an equivalent .proto file containing untrusted input. The exploit payload targets the namespace identifier structure.
The provided proof-of-concept payload defines a nested type with an extensively crafted string as its key. The string ExploitType; (function(){ console.log('RCE_EXECUTED'); require('child_process').execSync('touch /tmp/pwned'); })(); // serves as the malicious name property. When the library evaluates this schema, the compilation process maps this key directly into the uncompiled source text.
const maliciousDescriptor = {
nested: {
"ExploitType; (function(){ require('child_process').execSync('touch /tmp/pwned'); })(); //": {
fields: { someField: { type: "string", id: 1 } }
}
}
};The initial ExploitType; terminates the preceding logical statement inside the dynamically generated function. The subsequent immediately invoked function expression contains the arbitrary commands, executed instantly upon compilation. The trailing // neutralizes any trailing code appended by the template, preventing syntax errors that would halt execution.
Successful exploitation of CVE-2026-41242 yields unauthenticated Remote Code Execution (RCE). The injected JavaScript commands inherit the execution context and permissions of the hosting Node.js application. This access level permits the execution of arbitrary system commands, direct interaction with the underlying filesystem, and access to process environment variables.
The primary attack vector involves network services that accept dynamic schema definitions. Multi-tenant environments, plugin architectures, and systems processing serialized data from untrusted repositories represent the highest risk profiles. Applications statically loading trusted schemas at startup remain vulnerable only if an attacker compromises the schema repository.
The vulnerability possesses a CVSS v4 score of 9.4, reflecting its minimal attack complexity and severe impact metrics. The public availability of functional exploit repositories elevates the probability of widespread scanning and exploitation attempts targeting internet-facing Node.js services.
The fundamental remediation strategy requires updating the protobufjs dependency to a secured version. Organizations must upgrade to version 7.5.5 or 8.0.1 immediately. Dependency trees should be audited using package management tools to identify transitive dependencies relying on vulnerable versions of the library.
Applications must enforce strict boundary validation for all external inputs. Protobuf definitions and JSON descriptors must not be loaded from untrusted network sources or unauthenticated users. If dynamic schema loading is a rigid business requirement, implement strict schema structure validation before passing the data to the protobufjs parser.
Employing defense-in-depth measures limits the blast radius of a successful exploit. Execute Node.js processes with least-privilege service accounts to restrict filesystem and network access. Implement system-level sandboxing, such as seccomp profiles or restricted container capabilities, to prevent child process execution.
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H| Product | Affected Versions | Fixed Version |
|---|---|---|
protobufjs protobufjs | < 7.5.5 | 7.5.5 |
protobufjs protobufjs | >= 8.0.0-experimental, < 8.0.1 | 8.0.1 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-94 |
| CVSS Score | 9.4 |
| Attack Vector | Network |
| EPSS Percentile | 15.37% |
| Exploit Status | PoC Available |
| KEV Status | Not Listed |
Improper Control of Generation of Code ('Code Injection')
A stored Cross-Site Scripting (XSS) vulnerability exists within plone.restapi, the REST API package for Plone content management system. By supplying a spoofed input MIME type (text/x-html-safe), an attacker can mislead the rendering layer (plone.app.textfield) into assuming that the supplied content is already sanitized. This causes the system to skip the safe_html transform, allowing arbitrary JavaScript to execute in the victim's browser when they view the compromised page.
An untrusted search path vulnerability in the GlobalDatabasePlugin component of the AWS Advanced JDBC Wrapper for Amazon Aurora PostgreSQL allows authenticated, low-privilege database users to hijack administrative session queries. By defining a custom function in a writable schema such as the public schema, an attacker can hijack queries executed automatically during driver-level topology detection. When a highly privileged database user connects to the database utilizing an affected version of the wrapper, the custom function executes under their security context, enabling remote privilege escalation to rds_superuser.
CVE-2026-27771 represents a critical security flaw in Gitea and Forgejo (up to and including version 1.26.1) involving missing authorization checks (CWE-862). Unauthenticated remote attackers can query, enumerate, and download private container images from the OCI-compliant container registry. Additionally, unauthorized users can retrieve private or internal source repository URLs via the Composer package registry metadata API. A public proof-of-concept exists, and threat metrics indicate highly active scanning and exploitation risks.
A missing authorization vulnerability in the Formie plugin for Craft CMS prior to version 3.1.28 allows low-privileged Control Panel users to read and modify sensitive administrative settings, configuration options, and third-party integrations.
CVE-2026-53598 is a directory traversal and arbitrary file read vulnerability in Microsoft Prompty ecosystem loaders across multiple languages. Prior to version 2.0.0-beta.2, the loaders resolved `${file:...}` reference strings inside frontmatter configuration blocks without enforcing that the target file paths resided within authorized directories. This deficiency allows an attacker-controlled configuration file to read sensitive operating system and application files through absolute paths, directory traversal, or symbolic link escapes. The issue is addressed across the Python, C#, Node.js/TypeScript, and Rust ecosystems.
A directory traversal vulnerability exists in the copy subcommand of the proot-distro utility. Due to incomplete path sanitization, local attackers or malicious scripts can read from or write to arbitrary files outside the container rootfs, bypassing isolation barriers and potentially gaining unauthorized access or persistent execution on the host system.