Repository navigation
Description
Security-relevant (data integrity), severity: medium. Found in an adversarial review of #947, #962 and #970.
Runtime revision and environment
origin/main ba9f3204, Node 26.10, macOS.
What happens
A hermetic run (test, audit, MCP run_test, and the --local-review runs of validate and routes) gives the host context.data (a fresh temp dir) and context.hermetic: true, and tells the user so. The local_review event says extensions use "a fresh temporary data directory, never the site's data/". Core never checks that:
loadOperatorHost(packages/core/src/operator-host.ts~68–108) accepts whatever registrations the host composes.- The obligation to keep files under
context.datawas added in feat(core,auth,store,audit)!: hermetic test runs with declared seeds; expectJson; resolved captures in failures (#930) #947 without bumpingextensionContract(packages/core/src/addon-manifest.ts, still 1). So a contract-1 extension written before feat(core,auth,store,audit)!: hermetic test runs with declared seeds; expectJson; resolved captures in failures (#930) #947, a third-party one, or an older core copy'scomposeHostin a version-skewed install passescontractProblemand keeps resolving its database from the site.
Since #962, an MCP run_test with the operator's --host-file and no pin also activates such a host against the agent-edited revision. Before, it refused with revision-pin-required.
The current first-party auth, store and audit extensions do honour context.data. I only checked that by reading the code.
Minimal reproduction
host-legacy.mjs: a composeHost host with one contract-1 extension whose host(context) uses process.env.STORE_DATABASE ?? join(context.site, 'data', 'store.sqlite'), the same path logic as the store at f850492a~1, and appends a line there on each request. The project routes /demo/* to it and has one fixture, GET /demo/x.
rm -rf data; unset PROJECT_SHA256 URLCODE_POLICY URLCODE_ORIGIN
urlcode test --project app --host-file host-legacy.mjs --local-review
# {"event":"local_review",...,"note":"... extensions use a fresh temporary data directory, never the site's data/ ..."}
# {"total":1,"failed":0}
cat data/store.sqlite # WRITE by test /demo/x <- the site's live data/ was written
urlcode mcp --allow-authoring --project app --host-file host-legacy.mjs # tools/call run_test
cat data/store.sqlite # written again, with no operator pin
urlcode test --project app --host-file host-legacy.mjs # without the flag: revision-pin-required
Observed: all of the above, run on the revision named. Assumed, not tested: an actual skewed install (a global CLI with a site's older add-ons) behaves the same way.
Suggested fix
- Bump
extensionContractfor the hermetic obligation, so an older add-on is refused. - In a hermetic load, have
loadOperatorHostrefuse a host unless it confirms the data directory it was given. An oldercomposeHostcould not produce that confirmation. - Fix the related comment drift:
HostContext.data/hermetic(packages/core/src/extensions.ts~586) andLoadOptions.hermeticstill say only test, audit, benchmark and run_tests are hermetic, and that validate and routes use<site>/data.
Activity
jimhoyd commentedon Sep 30, 2026
Review of PR #987 (head af07d30): the hermetic confirmation passes a hand-made registration once any
composeHostresult is reused.SECURITY.md says the confirmation catches "version skew and hand-made registrations", and docs/EXTENSIONS.md and the RIM card say the same.
loadOperatorHost(packages/core/src/operator-host.ts around line 120) checks only that the host object carries the confirmation key with this run's directory. It does not check that each registration came from that compose.composeHostconfirms an empty compose too (host.ts around line 57), andObject.assignmakes the key enumerable, so a spread keeps it.Reproduced in the PR worktree with
loadOperatorHost(host, app, { hermetic: true }), using the PR test'slegacyRegistration(it writes<site>/data/store.sqlite). The host file was:Result:
R1 accepted; extensions: 1. A separate run through the real CLI (urlcode test --local-review) exited 0 and wrote the site's livedata/store.sqlite. Pushing a hand-written registration ontocomposeHost([...]).extensionsbehaves the same.Host code is trusted, so this is not a security boundary. But the docs claim more than the check does. Options:
composeHostresult, or an oldercomposeHost;result.extensionsagainst them.fix(core): confirm each hermetic registration; age the sweep by a dir…
jimhoyd commentedon Sep 30, 2026
Fixed in #987, commit 1d410c3. The hermetic confirmation is now checked per registration, so a hand-made registration that is spread, pushed or mixed in beside composed ones is refused. The docs now call it a correctness check, not a security boundary. Summary: #987 (comment)
fix(core): hermetic runs enforce the data handover and clean up their…
jimhoyd commentedon Sep 30, 2026
Fixed by #987 (merged), including the review follow-ups: per-registration hermetic confirmation and aging the sweep by a directory's newest entry.