fix(js): require branded token for filesystem external imports#1602
fix(js): require branded token for filesystem external imports#1602
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 040ea3a | Commit Preview URL | May 08 2026, 09:16 AM |
39e6486 to
c870e71
Compare
c870e71 to
040ea3a
Compare
|
This PR's branded-token approach breaks the documented public ABI interop with downstream NAPI consumers. The fixture Even setting interop aside, the JS-layer brand check is bypassable: an attacker who can pass a value through this code path can equally well call Closing pending a redesign. Generated by Claude Code |
Motivation
Externalimport path accepted arbitrary N-APIExternalvalues and then interpreted their raw pointer as a bashkit filesystem ABI handle, allowing non-bashkit externals to reach unsafe native import code.Description
WeakSetandFileSystemExternalTokeninterface to mark provenance incrates/bashkit-js/wrapper.ts.createFileSystemExternalTokenandisFileSystemExternalTokenand use them soFileSystem.toExternal()returns a branded frozen token andFileSystem.fromExternal()rejects any value not created bytoExternal().FileSystem.externalcached type to the branded token and unwrap the native external only after JS-level validation.crates/bashkit-js/__test__/vfs.spec.tsto assert the new explicit provenance error message.Testing
cargo check -p bashkit-js, but the invocation failed in this environment while fetching/compiling unrelated dependencies; the change is TypeScript-only and does not touch the native import path.avais not installed in this environment so the test run could not be executed here.fix(js): require branded token for filesystem external imports.Codex Task