Skip to content

docs(sandbox): correct deps-cache isolation comment — per-repo key is load-bearing - #4356

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/deps-cache-isolation-comment
Jul 7, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/deps-cache-isolation-comment

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

What

Corrects a false and dangerous comment in depsCacheEnv (shipped in #4352).

The comment claimed:

Tampered cache entries are caught by bun's lockfile integrity check on install, not by this key.

This is false. Verified empirically: populate a bun cache, tamper a cached file, rm node_modules, reinstall — the tampered bytes land in node_modules unchecked. bun does not re-verify cached content on install; it trusts its cache.

>>> TAMPERING cache file (append `globalThis.PWNED=true`)
$ bun install
+ [email protected]
2 packages installed
node_modules/is-odd/index.js  ← contains PWNED

Why it matters

The cache dir is writable by the sandbox uid (1000). Combined with "bun doesn't re-verify," the per-repo cache key (sha256(cloneUrl)) is the only thing stopping one repo's untrusted sandbox code from overwriting a package that every other repo would then install — a cross-tenant RCE. The old wording framed the key as redundant, which would invite widening it to a shared cache "for better hit rate." That change would be a security hole, not an optimization. (I went looking for exactly that shared-cache win; this is why it's not being shipped.)

Neither --backend=copyfile nor hardlink closes it — the shared writable store is the hole.

Change

Comment only, no behavior change. Rewrites the doc to:

  • State the key is the sole cross-repo isolation boundary (load-bearing).
  • Record the "bun doesn't re-verify" finding so nobody re-derives it the hard way.
  • Warn that a shared cache is only safe if made read-only to tenants + populated out-of-band by a trusted process.
  • Keep the honest note that same-URL public/template repos remain a residual cross-tenant gap (key by org if it matters).

🤖 Generated with Claude Code


Summary by cubic

Fixes a misleading comment in packages/sandbox/daemon/setup/install.ts to clarify that the per-repo deps-cache key is load-bearing for cross-repo isolation. Documents that bun does not re-verify cached content on install, so a shared writable cache could enable cross-tenant package poisoning; docs only, no behavior change.

Written for commit 5db90e8. Summary will update on new commits.

Review in cubic

…y is load-bearing

The comment claimed "tampered cache entries are caught by bun's lockfile
integrity check on install, not by this key." That is false: bun does not
re-verify cached content on install — tampering a cached file and
reinstalling lands the tampered bytes in node_modules unchecked (verified).

Since the cache dir is writable by the sandbox uid, this makes the per-repo
key the ONLY thing preventing one repo's untrusted code from poisoning a
package that every other repo would then install (cross-tenant RCE). The old
wording invited the opposite conclusion — that the key is redundant and a
shared cache would be safe. Rewrite it to state the real model and warn
against widening to a shared writable cache.

No behavior change; comment only.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 7, 2026 18:27
@pedrofrxncx
pedrofrxncx merged commit 43fa006 into main Jul 7, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/deps-cache-isolation-comment branch July 7, 2026 18:31
decocms Bot pushed a commit that referenced this pull request Jul 7, 2026
PR: #4356 docs(sandbox): correct deps-cache isolation comment — per-repo key is load-bearing
Bump type: patch

- @decocms/sandbox (packages/sandbox/package.json): 1.10.1 -> 1.10.2

Deploy-Scope: both
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant