Write prewarm secret files under the data root, not Dir.tmpdir - #173
Conversation
On macOS + colima the VM shares $HOME and /Users/Shared but not /var/folders (Dir.tmpdir), and docker turns a bind mount from an unshared host path into an empty directory — the prewarm container read an empty /run/secrets/WWISE_TOKEN and failed far from the cause. Secret temp files now live under <data-root>/tmp, which is VM-visible on every supported layout. The dir is sticky world-writable (the data root is shared between the human and agent users); files stay 0600 and are deleted by the caller as before. Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Audit finding on the data-root move: a shared 1777 dir's owner can unlink and replace anyone's secret files between write and bind mount (sticky only stops non-owners), and on an unprovisioned machine /Users/Shared is world-writable, so any local user can pre-own the tree. Replace the shared dir with secrets-<uid> directly under the data root (no world-writable parent that could rename it post-check), created 0700 and lstat-verified: a real directory, owned by the current uid, or SecretDirCompromisedError — never a fallback. Also sweep day-old dev-secret-* leftovers (SIGKILL strands them; macOS never purges the data root). Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed the security audit in 2a0adc1. Went with the per-identity dir, with one design change from the audit's recommendation: the dirs live directly under the data root (
Severity context for the record: on a provisioned machine the original attack required being inside the trust boundary already ( |
Agent-isolation and emulated-Mac fixes: install-deps failure isolation with typed errors (#170), brew escalation to the prefix owner + AgentBootstrap sudoers edge (#171), BuildKit secret files in a verified per-uid dir under the data root — colima-visible and substitution-proof (#173), build-watcher guest-load liveness signal + 15m stall window (#174), sigpending ulimit for Rosetta signal-queue aborts (#175), and brew trust before tap in docker-install-build-deps (tap-rot fix).
On macOS + colima the VM shares
$HOMEand/Users/Sharedbut not/var/folders(Dir.tmpdir) — and docker silently turns a bind mount from an unshared host path into an empty directory. The prewarm container then reads an empty/run/secrets/WWISE_TOKENand fails far from the cause (hit for real in snappy's image rebuild today; probe: mounting amktempfile into alpine yields an empty dir, mounting files under the data root works).Secret temp files now live under
<data-root>/tmp, VM-visible on every supported layout. Sticky world-writable dir (data root is shared between human and agent), files stay 0600, caller still deletes them. Test-first: the new test pins files underDev::DataRoot.pathand offDir.tmpdir.Made with Cursor