Repository navigation
fix: detach claimed drafts from agent-held inodes - #12
Merged
Merged
Conversation
The watcher renamed the agent-owned inbox inode into pending/. An agent that kept a hard link or an open descriptor to its submission could rewrite the pending draft after preview, and after approval: the bot rewrites the same inode, renames it to approved/, and the executor re-reads it after an awaited Telegram call without rechecking the hash. The watcher now opens the inbox entry with O_NOFOLLOW, requires the opened inode to match the inspected entry, captures a bounded snapshot, writes it to a new exclusive 0600 service-owned file in pending/, and only then removes the unchanged inbox entry. Failure evidence is written exclusively, and the inbox source is preserved if it cannot be. Startup isolation checks now also require service ownership of the inbox and private state directories, a root-owned real draft root, and treat a failed draft-root stat as an error. The draft root's group is not checked, so existing root:root installs keep starting. Salvaged from #11 without its deployment-profile and privilege-detector changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvages the watcher and startup-check portion of #11, without its deployment-profile and privilege-detector changes.
Bug on master: the watcher
renames the agent-owned inbox inode intopending/. An agent that keeps a hard link or an open descriptor to its own submission can rewrite the pending draft. The hash check catches a change before approval, but after approval the bot rewrites the same inode, renames it toapproved/, awaits a Telegram edit, and the executor then re-readsapproved/without rechecking the hash. That leaves a window to swap an approved email's content.Fix:
The watcher opens the inbox entry with
O_NOFOLLOW | O_NONBLOCK, requires the opened inode to match thelstat'd entry, and reads a bounded snapshot (max + 1 bytes).It writes the snapshot to a new exclusive
0600service-owned file inpending/, then removes the inbox entry only if it is still the same inode.Failure evidence is written exclusively (
wx). If it can't be written, the inbox source is preserved instead of being lost.Startup isolation checks (
enforceProductionPermissions) now also require:A failed draft-root
statis now an error, not a warning.Unlike feat: add deployment isolation modes #11, the draft root's group is not checked, so existing
root:rootinstalls from master's installer keep starting without a reinstall.README / deployment / Hermes docs now describe the detached copy instead of "moves it to pending".
Tests
pending/must keep the original content. Both fail on master's watcher (pending shows the agent's rewrite) and pass here.start(). A fresh chokidar polling watcher can miss a file created right afterreadyuntil the next directory change, which made per-test watchers flaky on Node 20. A single long-lived watcher was checked separately: 8/8 sequential drafts were seen even with identical inode reuse.npm test158/158 andnpm run buildpass on Node 20 and 22, in containers withrsyncandacllikeubuntu-latest.Not included from #11
The
standard/strictprofiles and--acknowledge-agent-host-admin-riskdetector were left out. A live run against real sudo 1.9.13p3 and opendoas found missed root-equivalent policies and false aborts; details are on #11.🤖 Generated with Claude Code