Skip to content

Commit d6815f0

Browse files
sirtimidclaude
andcommitted
fix(ocap-kernel): harden makeAllowedGlobals output in VatSupervisor
Defense-in-depth restoration of the harden() call the pre-snaps constructor used to apply to `allowedGlobals`. `createDefaultEndowments` already hardens its output, but `makeAllowedGlobals` is a public seam (see the exported `VatEndowments` type) — a custom factory returning unhardened globals would hand a vat mutable references to its own endowments, defeating attenuation. `harden` is idempotent and deep, so this is a no-op on the default path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1620287 commit d6815f0

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

packages/ocap-kernel/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Swap raw `setTimeout`/`clearTimeout` and `Date` for attenuated versions from `@metamask/snaps-execution-environments`
1515
- Wire factory `teardownFunction`s into `VatSupervisor.terminate()` so pending timers and other resources are released on vat termination
1616
- Replace exported `DEFAULT_ALLOWED_GLOBALS` constant with `createDefaultEndowments()` factory and `VatEndowments` type; `VatSupervisor` now accepts `makeAllowedGlobals` in place of `allowedGlobals`
17+
- Harden the `makeAllowedGlobals` output inside `VatSupervisor` as defense-in-depth against custom factories that may skip hardening
1718
- Make vat global allowlist configurable and expand available endowments ([#933](https://github.com/MetaMask/ocap-kernel/pull/933))
1819
- Export `DEFAULT_ALLOWED_GLOBALS` with `URL`, `URLSearchParams`, `atob`, `btoa`, `AbortController`, and `AbortSignal` in addition to the existing globals
1920
- Accept optional `allowedGlobals` on `VatSupervisor` for custom allowlists

packages/ocap-kernel/src/vats/VatSupervisor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ export class VatSupervisor {
155155
this.#platformOptions = platformOptions ?? {};
156156
this.#makePlatform = makePlatform;
157157
const { globals, teardown } = makeAllowedGlobals();
158-
this.#allowedGlobals = globals;
158+
// Defense in depth: custom `makeAllowedGlobals` factories may skip hardening.
159+
this.#allowedGlobals = harden(globals);
159160
this.#endowmentsTeardown = teardown;
160161

161162
this.#rpcClient = new RpcClient(

0 commit comments

Comments
 (0)