Parents: #493, #486, #495 Related: #864
Problem
The process-global private Wasm streaming compiler registry issues sequential
integer tokens and stores them in std.AutoHashMapUnmanaged(usize, ...).
JSC__Wasm__StreamingCompiler__addBytes is a revision-pinned void ABI with no
Context/VM argument, so the opaque token is its only authority boundary. A
misbehaving native caller can predict another live feed's token and append bytes
to it, while chosen arbitrary handles retain predictable registry placement.
The boundary already rejects null, stale, forged, and foreign-VM handles without dereferencing them, but sequential issuance does not make a live handle an unguessable capability.
Required design
- Issue nonzero opaque capability tokens from secure host entropy, with no counter, address, clock, constant, or deterministic fallback.
- Replace default integer hashing with a separately keyed exact registry context derived from secure host entropy.
- Install the registry context only after the first backing allocation succeeds. Token entropy failure, context entropy failure, or allocation failure must return no handle and leave empty state retryable.
- Retry an exact live-token collision without replacing or exposing the existing entry. Preserve locked concurrent feeds, same-VM sibling finalization, foreign-VM refusal, finalization stickiness, explicit release, and Context teardown retirement.
- Keep arbitrary inputs lookup-only and never dereference opaque tokens.
No-workaround rules
- No predictable fallback token/seed, token truncation, address-derived capability, hash-only equality, global lock removal, lifetime cap, leaked tombstone set, blind acceptance of collision, ABI signature change, or relaxed foreign/stale/teardown checks.
Acceptance
- Deterministic tests prove zero and live-token collisions retry to a unique nonzero capability without mutating the existing entry.
- A legacy integer-hash collision family disperses under the keyed exact context with exact lookup/removal.
- Token/context entropy failure and first allocation failure publish no handle, context, or table; exact retry succeeds.
- Concurrent feed/finalize/release, same-VM siblings, foreign/stale/forged handles, and Context teardown retain the pinned lifecycle contract.
- Focused tests pass in Debug, ReleaseSafe, and TSan; Wasm streaming/API/spec, full units, public C API, and pinned Home/Bun ABI audits/runtime remain exact.