Close NESTING_OVERRIDE resolver for falsy/omitted require
fix(GHSA-m4wx-m65x-ghrr): close NESTING_OVERRIDE resolver for falsy/omitted require
Close NESTING_OVERRIDE resolver for falsy/omitted require01a755-fix-close-nesting-override-resolver-for-falsy-cve-2026-44007-cve-2026-47137fixclose nesting override resolver falsy omitted
Committed by patriksimek
commit message
fix(GHSA-m4wx-m65x-ghrr): close NESTING_OVERRIDE resolver for falsy/omitted require
Patch bypass of GHSA-8hg8-63c5-gwmx. The original guard tested
`options.require === false` on the raw constructor input, but the
destructuring default `require: requireOpts = false` ran immediately
after and produced the same insecure value whenever `require` was
omitted, `undefined`, `null`, `0`, or `''`. `makeResolverFromLegacyOptions`
then short-circuited on `if (!options)` and built a NESTING_OVERRIDE-only
resolver whose sole builtin was `vm2` — a pure escape primitive
(`require('vm2')` -> inner `NodeVM` with attacker-chosen `require` config
-> `child_process` RCE).
Structural fix in `lib/nodevm.js`: destructure first, then check
`nesting === true && !requireOpts`. The guard now runs on the value that
actually drives `makeResolverFromLegacyOptions`, so every falsy/omitted
shape collapses to the same construction-time `VMError`. The escape
hatch (`nesting: true` + an explicit `require` config object, including
`{}`) is preserved — the developer's intent is now visible at the call
site. Restores the GHSA-8hg8 Defense Invariant ("configurations that
produce a NESTING_OVERRIDE-only resolver must fail loudly at
construction") for the full falsy class, not just the literal-`false`
shape.
Folded into the unreleased 3.11.4 patch alongside the other five
advisories already stacked on main.
- lib/nodevm.js: destructure first, then check `!requireOpts`; SECURITY
comment rewritten to enumerate every falsy path and the supersession.
- test/ghsa/GHSA-m4wx-m65x-ghrr/repro.js: full PoC + variants
(undefined / null / 0 / false / omitted) + escape-hatch acceptance
tests (`require: {}`, `require: { builtin: [] }`).
- test/ghsa/GHSA-8hg8-63c5-gwmx/repro.js: prior "accepts `{ nesting: true }`
alone" case was the literal loophole; updated to assert rejection.
- test/nodevm.js: nesting-NodeVM happy-path now passes explicit
`require: { builtin: [] }`.
- docs/ATTACKS.md: Category 25 rewritten — now covers the entire
falsy-require configuration class, not just `require: false`.
- README.md: nesting-escape-hatch paragraph rewritten to require an
explicit `require` config object.
- CHANGELOG.md: appended as sixth fix under the existing [3.11.4]
section, with a dedicated upgrade note for embedders.Editor assessment
This commit patches CVE-2026-44007 and CVE-2026-47137. The analysis is excellent: it shows the guard tested options.require === false before a destructuring default, so omitted, undefined, null, 0 and empty string all produced the insecure NESTING_OVERRIDE resolver, and that require('vm2') then yielded child_process RCE. It records the structural fix—destructure, then check nesting and !requireOpts—the preserved escape hatch, a file-by-file summary, and the version context. The header is the weak spot: GHSA-m4wx-m65x-ghrr as scope is not a codebase section, and the message closes with a bullet list of touched files that reads like a changelog. Capped for framing, not substance.