Oct 2, 2026·6 min read·30 visits
A flaw in vm2's bare-specifier matcher allowlist check allows sandbox escape. It uses unanchored substring matching and fails to filter directory traversal sequences, allowing untrusted code to load and execute arbitrary host packages with full authority.
An incorrect authorization and directory traversal vulnerability in the vm2 library before version 3.11.7 allows remote attackers to bypass the sandbox's external package allowlist. This flaw permits sandboxed code to resolve and execute arbitrary packages available on the host filesystem under host privileges, leading to unauthenticated sandbox escape and host code execution.
The vm2 npm package is a widely used Node.js library designed to run untrusted code in a highly restricted sandbox environment. The library exposes various configurations to control access to system resources. Under specific setups, the NodeVM class restricts access to external Node modules using the require.external configuration option. This feature is critical for multi-tenant applications and plugins that execute user-submitted scripts while preventing arbitrary filesystem access or network interaction.\n\nWhen combined with a custom resolver via the require.resolve callback, the package resolution falls back to the LegacyResolver internal component. Security verification within this resolver relies on a pre-check mechanism designed to determine whether a requested package matches the user-configured allowlist. If the requested identifier passes this initial pre-check, the application hands resolution to the custom host-level resolver.\n\nThe core issue lies within LegacyResolver.customResolve, which performs validation checks against bare specifiers before delegating the module resolution process to the host. Because these checks lack proper bounds and directory boundaries, attackers can satisfy the allowlist filters while requesting unauthorized host packages. The flaw manifests in two distinct vulnerability classes: a substring matching collision (CWE-863) and a path traversal vulnerability (CWE-706). Both security failures undermine the isolation boundary and permit complete escape from the execution sandbox.
The technical breakdown of the vulnerability highlights two separate architectural flaws inside LegacyResolver.customResolve. Both bugs are tied to how the LegacyResolver determines if a module request matches the allowlist before passing it to the custom resolver. These bugs together allow a sandboxed execution thread to arbitrarily extend its allowed packages list.\n\nThe first flaw involves unanchored regular expressions during string verification. The system constructs regex matchers dynamically for each configured allowlist pattern using the internal makeExternalMatcherRegex(pattern) function. These expressions are compiled and stored in this.externalCache. However, the resulting regular expression was compiled without the string start (^) and end ($) anchors. For example, if the allowlist permits the left-pad package, the matcher compiles to /left\-pad/. Because this expression performs an unanchored search, it matches any specifier containing the substring left-pad, such as evil-left-pad or left-pad-evil. If such a module exists on the host system, the resolver resolves it and permanently registers it in this.externals as an allowed module, allowing full host execution.\n\nThe second flaw involves directory traversal vulnerability (CWE-829). To allow access to subpaths of allowlisted modules (e.g., left-pad/utils), the validation engine needs to permit suffix patterns. However, the parser treated the path suffix as arbitrary text. The evaluation system failed to filter directory traversal segments such as .. before parsing. This omission allows an attacker to specify a path like left-pad/../evil-package. The pre-check identifies left-pad/ at the start of the string and allows the query. During actual module loading, standard Node.js resolution path canonicalization processes the traversal segments, collapsing left-pad/../evil-package into evil-package. Because this resolves to a separate, unauthorized directory location, the validation engine is completely bypassed, and unauthorized libraries run under host authority.
An analysis of the vulnerable and patched states in lib/resolver-compat.js illustrates how the two-stage security failure occurred and how the mitigation was structured. The patch directly resolves both the unanchored regex match and the lack of lexical path validation.\n\nBefore the patch, this.externalCache was built by mapping the allowlisted patterns without anchors. The pre-check evaluated bare specifiers directly against this cache:\n\njavascript\n// VULNERABLE CODE PATH\nthis.externalCache = externals.map(pattern => new RegExp(makeExternalMatcherRegex(pattern)));\n// ...\nif (!(this.pathIsAbsolute(x) || this.pathIsRelative(x))) {\n if (!this.externalCache.some(regex => regex.test(x))) return undefined;\n}\nconst resolved = this.customResolver(x, path);\n\n\nThe patch resolves the substring matching issue by anchoring both ends of the regular expression. The pattern now requires the input to be either the exact package name, or the package name followed directly by a path separator (\\ or /) and any arbitrary subpath:\n\njavascript\n// PATCHED REGEX GENERATION\nthis.externalCache = externals.map(pattern => new RegExp('^(?:' + makeExternalMatcherRegex(pattern) + ')(?:[\\\\/].*)?$'));\n\n\nTo block directory traversal attacks that abuse the permitted subpath tail, the patch adds lexical segment validation. The resolver splits the raw specifier string using platform-neutral directory separators. If the sequence contains a double-dot (..) segment, the resolution is rejected immediately, preventing any traversal before the path is passed to the filesystem-level resolver:\n\njavascript\n// PATCHED PATH TRAVERSAL MITIGATION\nif (x.split(/[\\/]/).indexOf('..') !== -1) return undefined;\n\n\nBy implementing this early lexical rejection, the module load process falls back to the standard loader, which denies access through isPathAllowed, raising a 'module not found' error inside the sandbox environment.
Exploitation of CVE-2026-92951 requires specific environmental prerequisites: the sandboxed execution framework must implement a custom package resolver configuration while using an allowlist of permitted external libraries. This layout is typical for serverless compute workers or plugin management systems built on vm2.\n\nAn attacker can trigger the vulnerability using two separate methods based on host package configuration. The first path leverages the substring mismatch. If the administrator allowlists a standard library such as left-pad, the attacker can introduce an external dependency with a colliding name (e.g., evil-left-pad) to their local package list. Invoking require('evil-left-pad') matches /left\-pad/. The sandbox passes this specifier to the host resolver, which loads the attacker's module, executing its entry point within the host's high-privilege context.\n\njavascript\n// Exploit Vector 1: Substring Collision Bypass\nconst payload = "require('evil-left-pad');";\nvm.run(payload);\n\n\nThe second vector bypasses safety rules using directory traversal. Even with anchored regular expressions, the engine permits subpaths starting with the allowlisted prefix. By executing require('left-pad/../evil-package'), the string begins with the legitimate prefix, satisfying the pre-check. When the custom resolver processes the request, the path resolves to the parent directory, allowing the sandbox to execute sibling modules outside of the permitted scope. The following diagram maps the lifecycle of a traversal-based bypass attempt:\n\nmermaid\ngraph LR\n A["Sandboxed require('left-pad/../evil')"] --> B["LegacyResolver Pre-check"]\n B --> C["Regex prefix check matches 'left-pad/'"]\n C --> D["Lexical Traversal Verification (Missing in <3.11.7)"]\n D --> E["Custom Resolver evaluates 'left-pad/../evil'"]\n E --> F["Host filesystem executes 'evil' package entrypoint"]\n\n style A fill:#f9f,stroke:#333,stroke-width:2px\n style F fill:#f99,stroke:#333,stroke-width:2px\n
The security impact of CVE-2026-92951 is classified as Critical, as denoted by its CVSS score of 9.9. Successful exploitation results in complete compromise of host integrity, confidentiality, and availability. Because the executing environment runs within the host process, escaping the vm2 sandbox grants the attacker the underlying operating system privileges of the Node.js runner.\n\nOnce the sandbox boundary is crossed, the attacker can execute arbitrary operating system commands, access environment variables containing database credentials or API keys, and perform internal network scans. For cloud-hosted environments, such as Serverless functions or CI/CD pipelines, this can lead to lateral movement, infrastructure takeover, or data exfiltration.\n\nThe scope of this flaw is further widened due to structural design limitations within the Node.js architecture. Once an untrusted module runs inside the host's V8 engine context, the executing thread can access global properties, manipulate standard input/output streams, or load native platform binaries, rendering sandbox recovery impossible.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
vm2 Patrik Šimek | < 3.11.7 | 3.11.7 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-706, CWE-863, CWE-829 |
| Attack Vector | Network |
| CVSS v3.1 Score | 9.9 (Critical) |
| Exploit Status | Proof of Concept (PoC) documented in test suite |
| CISA KEV Status | Not Listed |
| EPSS Score | 0.00539 |
| Impact | Complete Sandbox Escape & Host Code Execution |
The application uses a name or reference to access a resource, but fails to correctly resolve or restrict the resource boundaries, allowing access to unexpected resources.
An incorrect authorization vulnerability (CWE-863) exists in the Hono web application framework (npm package `hono`) from version 4.1.4 prior to 4.13.16. Flaws in the registration-time coverage calculation and regular expression compilation within `RegExpRouter` cause wildcard middleware to be omitted under three specific routing conditions: parameter pattern equivalence mismatches, wildcard boundary collisions, and request paths containing percent-encoded line terminators. Because Hono's default `SmartRouter` selects `RegExpRouter` for most standard web applications, unauthenticated remote clients can bypass authentication, authorization, or security middleware registered on wildcard paths to directly access protected route handlers or the application's not-found handler.
CVE-2026-126357 (GHSA-4m76-xfj5-7975) is an authentication bypass vulnerability in the Hono web application framework prior to version 4.13.16. The flaw resides in the prefix-stripping and URL reconstruction logic of `app.mount()` and the `mount()` middleware. Two distinct path transformation errors—static route-pattern length slicing on dynamic prefixes and URL normalization of decoded pathnames—create a routing discrepancy between the outer Hono router and the mounted sub-application. An unauthenticated attacker can exploit these discrepancies to bypass outer authentication or authorization middleware and access protected inner routes directly.
A parser differential vulnerability exists in the Hono web application framework versions 4.5.1 prior to 4.13.16. The built-in form validation middleware (`validator('form')`) utilizes an overly restrictive regular expression to evaluate the HTTP `Content-Type` header for `multipart/form-data` payloads. When a client supplies additional valid MIME parameters (such as `charset=utf-8`) or multiple whitespace characters following a semicolon delimiter, the regular expression fails to match. Consequently, the validator passes an empty object to the validation callback instead of the parsed form fields. If the validation logic permits empty objects or only checks for disallowed values on optional properties, the request passes validation, allowing downstream route handlers calling `c.req.parseBody()` or `c.req.formData()` to process unvalidated user input.
CVE-2026-126355 (GHSA-46wx-v44x-9hh2) is a Cross-Site Request Forgery (CSRF) validation bypass in Hono, a web application framework for JavaScript runtimes. Prior to version 4.13.16, Hono's built-in csrf() middleware only evaluated origin headers for requests matching standard HTML form MIME types (application/x-www-form-urlencoded, multipart/form-data, and text/plain). By leveraging the HTML anchor ping attribute in Chromium-based browsers, an attacker can initiate an unprompted, credentialed cross-origin HTTP POST request with Content-Type: text/ping without triggering a CORS preflight request. Because text/ping was omitted from the middleware regular expression, requests bypassed Origin and Sec-Fetch-Site verification, allowing unauthorized state-changing operations.
CVE-2026-128067 is a memory corruption vulnerability in Pillow (versions 2.3.0 through 12.3.0) occurring when saving compressed TIFF images via the underlying libtiff encoder. By supplying crafted image geometry tags through exif=, tiffinfo=, or a source TIFF IFD, an attacker can override the scanline dimensions configured in libtiff while Pillow allocates the internal row buffer based strictly on the physical image dimensions. This mismatch induces an out-of-bounds heap read during scanline encoding, and escalates to an out-of-bounds heap write when TIFF Predictor 2 (horizontal differencing) is enabled.
CVE-2026-128066 (GHSA-wqgw-9xfh-qf2g) is a resource allocation vulnerability (CWE-770) in the Python Pillow imaging library affecting versions 1.0 through 12.3.0. The flaw resides in the ImageFileDirectory_v2.load() method within src/PIL/TiffImagePlugin.py, which processes Tag Image File Format (TIFF) structures and Exchangeable Image File Format (EXIF) metadata across multiple container formats. By supplying an image with thousands of IFD tag entries that point to overlapping or identical file offsets, an attacker can trigger quadratic memory amplification (O(N * filesize)). Because the vulnerability occurs during metadata parsing rather than pixel decoding, it bypasses Pillow's built-in decompression bomb protections (Image.MAX_IMAGE_PIXELS).