You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The structured-clone wire format currently serializes a retained SharedBufferStorage address as a raw u64. deserialize() and releaseSerialized() convert that field back to a pointer and dereference it without proving that the stream actually minted and owns a retained reference.
The normal Worker path only consumes engine-produced streams, but these helpers are public and malformed or replayed bytes must fail closed. A forged address can become an invalid pointer dereference; a replayed legitimate address can consume a reference more than once. Deserialization also accepts trailing bytes, which can hide unconsumed retained references.
Goal
Replace raw SAB addresses in structured-clone streams with opaque, unguessable, single-use transfer tokens backed by a thread-safe registry. Consuming or releasing a token must atomically remove it before returning the retained storage reference.
Acceptance criteria
Serialized SAB payloads contain no process pointer.
Arbitrary, unknown, and replayed tokens fail closed without dereferencing attacker-controlled addresses.
Successful deserialization consumes exactly one retained reference and transfers it to the wrapper.
releaseSerialized() consumes and releases each valid token at most once.
Wrapper-construction failure releases a token that was already consumed.
Deserialization rejects trailing bytes and does not silently strand valid trailing SAB tokens.
Accepted and complete in 285b534. Structured-clone SharedArrayBuffer references use opaque random single-use tokens with atomic consumption and failure-safe cleanup; focused coverage includes forgery, replay, concurrent consumption, trailing payload cleanup, wrapper allocation failure, Context round trips, and Worker sharing. The combined production gate is green: 31 jobs succeeded, 1 nightly-only job was skipped, and 0 failed: https://github.com/zig-utils/zig-js/actions/runs/29219914395
Activity
chrisbbreuer commentedon Jul 13, 2026
Implemented and pushed the #38 runtime slice in
285b534c(security: authenticate cloned SAB references).What changed:
SharedBufferStoragereference per token.Focused validation:
structuredClone: identity, cycles, types, SAB sharing, transfergit diff --checkCombined CI gate: https://github.com/zig-utils/zig-js/actions/runs/29219914395
I am keeping #38 open until that gate is green.
chrisbbreuer commentedon Jul 13, 2026
Accepted and complete in 285b534. Structured-clone SharedArrayBuffer references use opaque random single-use tokens with atomic consumption and failure-safe cleanup; focused coverage includes forgery, replay, concurrent consumption, trailing payload cleanup, wrapper allocation failure, Context round trips, and Worker sharing. The combined production gate is green: 31 jobs succeeded, 1 nightly-only job was skipped, and 0 failed: https://github.com/zig-utils/zig-js/actions/runs/29219914395