Isolate sandbox buffers from Node's shared pool
fix(GHSA-fcqc-726x-5wfc): isolate sandbox buffers from Node's shared pool
Isolate sandbox buffers from Node's shared pool4f2508-fix-isolate-sandbox-buffers-from-node-s-cve-2026-92947fixisolate sandbox buffers node shared pool
Committed by patriksimek-bot
commit message
fix(GHSA-fcqc-726x-5wfc): isolate sandbox buffers from Node's shared pool
Node serves small Buffer allocations out of one shared backing ArrayBuffer
of Buffer.poolSize bytes, and a pooled buffer's `.buffer` getter returns the
whole pool rather than the buffer's own slice. Sandbox code could therefore
take `Buffer.from([0]).buffer` (a 64 KiB ArrayBuffer), build a full-width
view with the `Buffer.from(arrayBuffer, 0, len)` sharing overload, and both
read and overwrite every host-realm buffer that happened to share the pool —
a confidentiality and integrity escape, distinct from the bufferAllocLimit
allocation-size class (Categories 23/36), whose caps this leaves untouched.
lib/setup-sandbox.js now enforces a backing-store ownership invariant: a
buffer handed to sandbox code must own its entire backing store (byteOffset
0 and buffer.byteLength === length), so `.buffer` can never reveal a byte the
buffer does not itself contain. `depoolBuffer` returns a conforming buffer
unchanged and otherwise copies it into a standalone, non-pooled, zero-filled
LocalBuffer.alloc(n) via the raw host Buffer.prototype.copy primitive. It is
applied at every sandbox-facing pooling factory: `bufferFrom` (non-ArrayBuffer
overloads), `concat`, `copyBytesFrom`, a new `bufferOf` wrapper, and the
deprecated `Buffer(...)` / `new Buffer(...)` forms, which BufferHandler now
routes through `bufferFrom`. The documented `Buffer.from(arrayBuffer |
sharedArrayBuffer, byteOffset, length)` sharing overload is preserved, keyed
off a spoof-proof brand test that applies the captured ArrayBuffer /
SharedArrayBuffer `byteLength` getter (internal-slot check the sandbox cannot
fake). The alloc trio was already non-pooled.
Restores Defense Invariant #1 (no host-realm state reachable from the sandbox)
at the Buffer backing-store level.
Tests: test/ghsa/GHSA-fcqc-726x-5wfc/repro.js (host-secret disclosure,
host-buffer corruption, exact-size `.buffer` across every factory, and
preserved ordinary Buffer semantics).
docs/ATTACKS.md: new Category 41, renumbered from the branch's 39 (taken on
main by GHSA-647f-g98j-qq25); adds a How The Bridge Defends row.
package.json version unchanged.Editor assessment
This commit patches CVE-2026-92947. The body explains Node's shared Buffer pool, how .buffer exposes the whole pool, and the backing-store ownership invariant enforced at every pooling factory through depoolBuffer and a spoof-proof brand check. The fix type and subject are precise. The scope is the sole formal problem: a GHSA id is not a codebase area, so the message is capped at 3 despite a clear, tested explanation. The distinction between the allocation-size class and the pool-sharing class is worth one sentence, because the existing bufferAllocLimit does not cover this escape.