Repository navigation
Conversation
Size Report
Startup median (7 runs, lower is better):
|
|
I found two confirmed gaps in the new ancestry rule at 02cfd69, and one docs claim that is wrong. CI is failing on the CodeQL alert described below, and there are no conflicts. The ancestry rule and the docs need to change before this can merge. The rule trusts a directory from its mode bits and group only. A symlink component can also bypass the rule. When the link's own parent is private, line 230 stats only the final target, and the walk continues up the lexical chain, so the ancestors of the real target are never checked. With The docs misstate sticky semantics. replay-e2e.md:75 says a sticky team directory is safe, but the directory's owner can still rename and remove entries. Line 74 and Not blocking, take or leave: the local writer runs The CodeQL alert on the quadratic Before merge, the ancestry rule should trust only directories owned by you or root, follow the resolved chain of any symlink, and the docs and hint should match. The CodeQL alert should be cleared too. |
3f17db5 to
450a915
Compare
|
Thanks for the update. At 450a915 the CodeQL alert on the trailing-slash regex is gone, and all 21 checks pass. Two defects remain in the destination checks, and there are no conflicts. Both are traced from the source. The new rule no longer judges every directory the path traverses, so atomic-file.ts:278 accepts destinations that the earlier revision refused. The spelled walk skips every component that is not a link, and the realpath walk covers only the final resolved chain. For example, take The remote client refuses a path the local writer accepts. session-script-destination.ts:206 runs assertPrivateScriptDestination before the missing parent is created at :207. For Not blocking, and you can take or leave these: the test at atomic-file-ancestry.test.ts:661 is named 'admits it with root named among its members' but asserts The code-scanning thread on the trailing-slash regex no longer applies, because the regex is gone at this head, so please resolve it: #4584 (comment) |
|
Head Traversed directories. Remote ordering. The remote client judged the chain before Groups. Scope of the claim. No ACL code. ADR 0016, the guide, and the remote page now name macOS and POSIX ACLs, network filesystems and mounts as outside the guarantee, and the unconditional confidentiality line is gone: the file is written Hardening. The source-text check for the publisher entry point is deleted; the writer tests drive a real write and expect the typed refusals, so they cover dispatch by behaviour. The Checks: |
|
Thanks for the update. At 546303c the link to a last-component target such as First, Second, link stability is asked only by Third, Could one component walker replace The The github-advanced-security thread on the trailing-slash regex no longer applies: Not blocking, take or leave: the four-line comment at The shapes above were probed against the head Before merge, the two link walks need to become one kernel-lookup walk that judges every looked-up directory and every followed link, with the three regression shapes added and the Fallow audit passing. |
7041497 to
4964b44
Compare
|
Yes — one walker replaces all five, and it is now the only thing that resolves a destination. Head: The one loop, and what it cost.
The three shapes, at all three levels. Each is refused at
Two hardening items rode along: the hop count is refused as The group exception fails closed. It is admitted only where The unused configurable Fallow. Checks. CI is green at Reverting only |
|
Thanks for the update. At 4964b44 the Fallow failure from the earlier round is fixed and all 21 checks are green. The quadratic trailing-slash regex is also gone from
Not blocking, take or leave: the Shape 2 (a foreign-owned hop link in a sticky directory) was traced from the code only, because an unprivileged process cannot create it. The probe confirms that 546303c accepts shapes 1 and 3. The change is 715 net production lines, just over the usual size line. There is no smaller owner beyond the two cleanups above. Before merge, the relative-target walk must be fixed with regressions, and the duplicate lstat helpers must go. |
|
All five are in. Head: 1. The relative target. 2. Staging escaped the judged directory. Two consequences worth naming. The parent identity is compared against 3. 4. A bare destination. 5. Judged once. Also folded in: One thing the first push broke, and a fourth shape it exposed.
Delta. Checks. Reverting the five production files to |
Apex Sentinel · ✅ ApproveSince the last review: 0 new · 0 still open · 1 no longer raised (1 marked fixed) No open findings. Reviewed with this repository's own Sentinel configuration ( 💬 Talking to SentinelIn a finding's thread, reply with:
On this conversation, comment Earlier reviewsReview of
|
| Where | Finding |
|---|---|
packages/daemon-contracts/src/daemon-registration-owner.ts:378 |
🆕 ADR 0016 claim that a root container with foreign sessions/ still has every command working is false for recordings |
2 findings below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (a30accf38081).
Review of 8cd5b8ac · 17.11.2026 01:13 UTC
Apex Sentinel · ✅ Approve
Since the last review: 0 new · 0 still open · 0 no longer raised
No open findings.
1 finding below minor hidden (user_settings.min_severity).
1 new finding away from what changed since 4b630c1 not shown. Comment @apex-sentinel-staging review for a full review.
Reviewed with this repository's own Sentinel configuration (a30accf38081).
Review of 4b630c1f · 17.11.2026 00:39 UTC
Apex Sentinel · ✅ Approve
Since the last review: 0 new · 0 still open · 3 no longer raised (1 marked fixed)
No open findings.
Reviewed with this repository's own Sentinel configuration (a30accf38081).
Review of 45d4eb97 · 16.11.2026 23:50 UTC
Apex Sentinel · ✅ Approve
Since the last review: 3 new · 0 still open · 0 no longer raised
3 finding(s): 3 minor.
🟡 Minor (3)
| Where | Finding |
|---|---|
packages/daemon-contracts/src/daemon-registration-owner.ts:295 |
🆕 ensurePrivateDaemonStateDir creates state levels through a recursive mkdir, crossing planted links |
packages/daemon-contracts/src/daemon-registration-owner.ts:355 |
🆕 Daemon startup now dies on a foreign-owned state dir it could previously write |
packages/daemon-contracts/src/daemon-registration-owner.ts:423 |
🆕 State-repair refusals pass an untyped reason: string, unlike the union the rule uses |
Reviewed with this repository's own Sentinel configuration (a30accf38081).
Review of 235d0db4 · 16.11.2026 20:55 UTC
Apex Sentinel · ✅ Approve
Since the last review: 0 new · 0 still open · 0 no longer raised
No open findings.
1 finding below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (ea414582b7fa).
Review of c852884d · 16.11.2026 19:44 UTC
Apex Sentinel · ✅ Approve
Since the last review: 0 new · 0 still open · 0 no longer raised
No open findings.
Reviewed with this repository's own Sentinel configuration (ea414582b7fa).
Review of d86ee29f · 16.11.2026 17:49 UTC
Apex Sentinel · ✅ Approve
Since the last review: 0 new · 0 still open · 1 no longer raised (1 marked fixed)
No open findings.
1 finding below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (cb335952017e).
Review of 7ed8e267 · 16.11.2026 16:35 UTC
Apex Sentinel · ✅ Approve
Since the last review: 1 new · 0 still open · 1 no longer raised (1 marked fixed)
1 finding(s): 1 minor.
🟡 Minor (1)
| Where | Finding |
|---|---|
packages/remote/src/session-script-destination.ts:372 |
🆕 Remote route still creates the entry through the unverified spelled destination |
Reviewed with this repository's own Sentinel configuration (244d1ff68344).
Review of 49ada505 · 16.11.2026 15:48 UTC
Apex Sentinel · ✅ Approve
Since the last review: 1 new · 0 still open · 0 no longer raised
1 finding(s): 1 minor.
🟡 Minor (1)
| Where | Finding |
|---|---|
packages/remote/src/session-script-destination.ts:201 |
🆕 Missing parent created before the ancestry rule judges it |
1 finding below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (cfe08502f0f6).
Review of 93156c82 · 16.11.2026 15:17 UTC
Apex Sentinel · ✅ Approve
No open findings.
Reviewed with this repository's own Sentinel configuration (cfe08502f0f6).
93156c8 to
49ada50
Compare
|
All six are in. Head: 1. The relative destination (blocker). 2. The test file is split. 3. The alias test now walks two routes. 4. The temp predicate compares directories, not spellings. Two things were wrong: it compared path text, and it used 5. The three writer tests ask about one directory. All three now call 6. Delta. This round is production Checks. |
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 49ada50. The verdict and the full list are in the summary comment.
49ada50 to
7ed8e26
Compare
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 7ed8e26. The verdict and the full list are in the summary comment.
|
All four review items plus both review threads are in. Head: 1. The two 2. The walk no longer trusts Node's remembered working directory, and both publishers create the entry in the judged directory.
Tests, all through the exported publisher: 3. 4. The hop test states its numbers. A 30-link chain publishes, a 31-link chain is refused naming 5. Missing parents are refused before they are created, on both routes, with the same walker. Remote entry path ( Wire ledger. One split rode along. The new host-kit cases pushed Delta. Production Checks. |
|
I reviewed d86ee29 and found two problems to fix before merge. Compared with the earlier review, the shared-ancestor and spelled-destination issues are fixed. The 20 CI checks pass at this commit, and there are no conflicts. The docs promise that a refused save leaves no directories behind (see replay-e2e.md and ADR 0016), but the code does not keep it. Both routes create the missing parent with no mode: session-script-writer.ts:144 and session-script-destination.ts:208. Under umask 002, the new directory is 0775. Without an admitted private group, the check that runs right after the mkdir refuses it as nameServiceListsOnlyFiles admits only Open threads: neither earlier inline thread still applies, so please resolve both. shared ancestor before mkdir is fixed by the prefix check before the mkdir (the leftover under umask 002 is the first problem above, a different mechanism). publish destination spelling is fixed because publishStaged now creates the file under the directory judged under the lock. The walk itself is justified, since a per-component O_NOFOLLOW open cannot carry the create without openat. Production code grew from about 715 to about 875 net lines across five files, and the growth is patches around the walk. Would these cuts make it smaller and better owned? (1) Both callers already resolve an absolute destination, so could host-kit refuse a non-absolute one at its entry and delete the cwd branch of Not blocking, take or leave: the relative-destination half of absoluteParent cannot fire from production because both callers pass absolute paths, and the publishScriptFileSync JSDoc at line 53 still documents the removed The Ubuntu case comes from tracing the code and a macOS umask-002 reproduction, not a live Linux run. Before merge, please create missing script parents at 0700 on both routes with the umask-002 regressions, and decide the private-group exception for stock Ubuntu. |
d86ee29 to
c852884
Compare
|
Redone as one smaller rule, with ADR 0016 amended to match in Blocker 1 — created directories now pass the rule they are judged by. Same sequence at this head: the save goes through and both new levels are Blocker 2 — the private-group exception is dropped, not widened to That is a project directory at The four smaller-design questions
Also from your not-blocking list: the stale Lines. Measured your way — net added over Checks. One thing to flag for your judgement, since it is a user-visible change I made under decision 3: a local Both inline threads were already resolved, so there is nothing to close there; I added a short note to each saying which change answers it. |
|
Thanks for the update. At c852884 the two earlier threads on the shared ancestor and the publish destination are fixed, but one new problem remains: a umask-002 daemon host now refuses its own default recordings. The daemon creates The rule to satisfy: every directory that agent-device creates on the chain of a script destination it chooses (state dir, Not blocking, and fine to take or leave: The finding above comes from a code trace plus a Node mode reproduction of the two daemon mkdir calls. No live umask-002 daemon run exists yet. The rule no longer reads account databases, so the Ubuntu outcome depends only on directory modes, which the test All 21 checks pass at c852884, but CI hosts use umask 022 and explicit 0700 test homes, so they do not reach this route. There are no conflicts. Before merge, The open inline threads on the shared ancestor before mkdir (#4584 (comment)) and on the publish destination spelling (#4584 (comment)) are fixed at this head, so they can be resolved. |
|
Head The daemon's own directories (your blocker). lstat versus stat (blocker 1). Every step is judged from the Recursive mkdir (your item 2). Pass-through. Delta. Net production across the five files this rule owns is +926 (was 735 at Checks. One caveat on that last test, so the count is not read as more than it is: eight of the nine new or rewritten tests go red at ADR 0016 and the guide now state one |
A publish resolved the destination by name, so a second local user who could write any directory on the way to it could replace that component, or leave a symbolic link there before the entry was created, and move the saved script wherever they chose. `publishScriptFileSync` now asks first: `assertPrivateScriptDestination` walks each component with `lstat` and refuses the chain under `script_ancestor_untrusted` when a directory is writable by other, or by a group that is not this user's own private group, unless the sticky bit cancels the exposure. A symbolic link whose own directory others can create entries in is refused whatever it points at. Ubuntu and Debian set up every home directory as group-writable and owned by the user's private group, so that shape is admitted, and `privateGroupIds` is exported so the membership rule is testable on its own. The caller also captures the parent's `dev:ino` before staging, and the publish compares it before the link or rename, so a parent swapped out by name while the file was written refuses under `script_ancestry_replaced` instead of receiving the script. Node exposes no `openat` or `renameat`, so publishing relative to a verified directory handle needs native code; this is the rule that closes the same window without it. Refs #4565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The writer now publishes with `publishScriptFileSync`, and hands it the identity of the directory it created, so a `--save-script` path with a directory another local user can write refuses instead of landing the recording there, and a parent replaced by name while the recording was staged never receives it. A refusal is reported with the reason the rule chose, and a refused destination is created by nothing. Refs #4565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A remote recording staged the version beside the destination and renamed it into place, so an ancestor another local user could write steered both the download and the entry. `allocateStaging` now asks the destination rule before it creates anything, so a refused path leaves no directory behind, and it reports the destination directory's identity. `publishStaged` re-asks under the record lock, immediately before the entry is created, so whoever could write an ancestor while the version was downloaded cannot move it now. The command keeps its success and carries the refusal's typed reason as the `scriptDeliveryFailure` cause, so a caller can tell an unsafe destination from a download that failed. Refs #4565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The replay guide states the destination rule for `--save-script`: every directory on the way must be one only the user and root can write, why a sticky shared team directory and a group-writable home of the user's own private group are accepted, and why a symbolic link inside a directory others can write is refused whatever it targets. Each surface's outcome is stated: a local `close` fails and keeps its bytes, a remote recording keeps its success and reports the reason as the `scriptDeliveryFailure` cause, and the next recorded action repeats the refusal. The remote proxy page points at that rule instead of repeating it, and ADR 0016 records the rule, the private-group exception, the parent-identity re-check, and why publishing relative to a directory handle was not available. Refs #4565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The daemon RPC manifest reached `PublishOutcome` through `publishScriptVersion` and could not place it, so the outcome type the client builds now carries a waiver naming the payload half it serializes, and `ScriptDeliveryFailure` — the field a peer actually parses — is listed with it. `publishScriptVersion`'s digest moves with the destination rule. The same-directory publisher guard read the shared atomic publish owner by name, so the script writer's new entry point failed it. The guard now accepts either owner and states separately that the session script uses the ancestry-owning one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three ways through the destination rule stayed open. Ownership was never asked, so a directory another user owned passed at 0755, and its owner could open it up or replace the subtree whenever they liked; the sticky bit excused a directory whatever its ownership. The rule now requires every directory on the chain to be owned by this user or by root, and keeps the writability rule on top of that. A sticky shared directory is still trusted for passing through, and the link rule requires a link there to be owned by this user or root; nothing is created inside a directory others can add entries to, so a shared parent no longer receives the entry. A symbolic link's target escaped the walk entirely: a link in the user's own home pointing at a world-writable directory was judged only as the link. The existing prefix is now resolved once and the whole resolved chain is judged, so the shared target is refused; root-owned system aliases such as macOS /tmp and /var keep working. The private-group exception assumed a membership it could not prove. It now fails closed: both database files must have been read, the group must be this process's primary group and carry this user's name, its member list may name nobody else, and no other passwd record may hold it as its primary group. A name service that can add a member without touching /etc/passwd is named as the limitation it is. A published script is created 0600 locally as well as remotely, so a recording is not world-readable in a directory that is merely shared. Refs #4565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three ways through the ownership rule stayed open, and the identity check was described as the thing that closes a race. Ownership is now asked before the mode. `othersCreateEntriesIn` treats a directory another user owns as theirs whatever its mode, so a link that stands in their private-mode component is refused: they can rename that component and leave one of their own there. A sticky bit excuses a directory only when this user or root owns it, because both the sticky bit and the group bits shield other users FROM an owner rather than the reverse. The chain keeps the `..` segments it was spelled with, so `<dir>/shared/work/../x` is judged as the walk the kernel performs, with the link named `work` in it, instead of the directory `path.resolve` names after folding the `..` away; the fold points at a directory that receives nothing. The documentation and the refusal hint now say what the rule does: a directory is accepted when this user or root owns it and its mode keeps its contents closed to others, and the destination is never created where others may add entries. The hint names ownership as well as writability. Three ancestry tests were macOS-only in effect: an assertion that the scratch root must differ from its real path cannot hold where `/tmp` is a real directory, and two identity checks passed only because the filesystem handed back a just-freed inode. The alias case now builds the alias it needs, and a replaced parent is replaced with a directory that really is another one. Refs #4565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…olds it A relative link target was joined onto the directory the walk stood in, which made it absolute, and the walk then continued from the link's own directory. The lookup missed the target and the walk stopped, so the target and the directories on the way to it were never judged: `ln -s ../team/rec rec` reopened #4565. `path.join` also folded a `..` inside a target away. Targets are now queued as RAW components, restarting at `/` for an absolute target and continuing from the directory that holds the link for a relative one. The same folding let a publisher escape the judged directory. Staging used `path.join` on the spelled destination, which answers a DIFFERENT directory wherever the walk turned aside, so the temp file was written into ground nobody judged and renamed into the judged one from outside it. `assertPrivateScriptDestination` now returns the physical directory it verified, and both the local publisher and the remote client stage inside it. The parent identity is taken from that directory too, so a `..` destination no longer reports a replacement that never happened, and the refusal names the directory the entry would really have been created in. A relative destination with no directory in it had the working directory as its parent rather than nothing, so the walk started there instead of at `/`. Each physical directory is judged once per walk and each path is read once, so an alias or a `..` back over ground already crossed costs nothing. The private-group exception also reads `initgroups:`, the database glibc answers SUPPLEMENTARY membership from: an explicit line has to be files-only, and an absent one inherits the verified `group` setting. `lstatIfPresent` is imported from the module that owns it, the two local copies are gone, and the message says what a link-loop or a non-directory refusal actually found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A script's temp file is created beside the destination AS THE FILESYSTEM RESOLVES IT, because that is the directory the entry is created in. So a destination spelled through a symbolic link -- any scratch path under `/var` on macOS -- has its temp file one directory over in TEXT, and `isAtomicPublishTemporaryPath` compared the two spellings as strings. It stopped recognizing temp files it had produced for its own destination: a fault injected at the write went unclaimed, and the cleanup that names those files left them behind. The two directories are now resolved and compared as directories. `lstatIfPresent` moves from `verified-file.ts` to `atomic-file.ts`, which the verified-file guards already sit behind. Importing it the other way round made 64 top-level statements of eager work load from the daemon's startup path, which the no-growth rule in `eager-closure-budgets` refuses: a module the merge-base tree already had cannot be made eager by a split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`cd /shared/mine` under a `/shared` at 0777 and not sticky, then save a script to `journey.ad`: the destination names no directory, so the walk started IN the working directory, judged it, and never looked above it. `mine` is a name in `/shared`, and anyone who can add an entry there can point it at a directory of their own between the check and the rename -- the swap this rule exists to refuse, reached through the exported publisher. A relative destination is now walked from `/` over the resolved working directory's components with the destination's own components following them raw, so every ancestor is judged. `isAtomicPublishTemporaryPath` resolved the destination's spelling to compare it with the temp file's directory, and a JS path resolution applies a spelled `..` lexically. For `home/work/../y` with `work` a link, that answers `home/y` while the entry is created in `priv/y`, so the real temp sibling was called someone else's and a look-alike beside `home/y` was called ours. Both directories are asked of the filesystem and compared as device and inode. `publishScriptFileSync` no longer takes a `parentIdentity`: it takes the identity from the directory the walk judged, so an outside caller cannot steer what the comparison is against, and only the remote client still passes one, captured before its download. The externally captured identity is tested against `assertPrivateScriptDestination`, which is what compares it. Three writer tests moved the caller's uid, which made the whole scratch tree foreign, so they could not tell a leaf refusal from a root refusal and did not run under root. They now report the ownership of the one directory at issue and assert the ancestor named. The alias test entered through one link and stopped, so it passed with the read cache removed: both names are now traversed, and the walk's own answer is asserted. `atomic-file-ancestry.test.ts` gained enough cases to pass its cap, so the ancestry cases for a remote publication move to `daemon-artifacts-script-ancestry.test.ts`, sharing the client and the fake daemon with the download suite through a support module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both routes created the missing parent before the ancestry rule was asked, so a destination under a world-writable directory left the directories its `mkdir -p` made standing in that shared ground, even though the publish that followed was refused. The same walk now runs over the prefix that already exists, refuses, and runs again after the `mkdir` once the directory the entry lands in exists. Only the second question asks whether others could create the name inside it, because below the first question the directories are the caller's own to create: that is what keeps `mkdir -p <sticky shared>/recordings` acceptable. A relative destination walked the working directory Node remembers, which is the path the first query after `chdir` returned. Move that directory and put another at its old path and the walk judges a directory the process is not in, while the kernel resolves the destination in the moved one. The remembered spelling is confirmed against `.` by `dev:ino`, and the entry is created in the directory the walk answered rather than by handing the kernel the destination back. `ground.judged` is gone: the once-per-inode judgment it held could be deleted with every test green, and only the per-path `stat` cache is observable. The hop test stopped deriving its inputs from the production constant, which let a limit of 29 pass as 30, and now builds a 30-link chain and a 31-link chain. Two tests that made a destination directory `0500` now fail the staging write directly: mode bits do not bind root, so those two reported the host's permission model instead of the writer's error handling under a root caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fied `open --save-script <home>/work/../y/journey.ad`, with `work` a link: the destination is judged, the version is downloaded and staged, and the chain is judged a second time before the entry is created. The last step then handed the spelled destination to the kernel, so the path was resolved once more and `home/work/../y` was answered through whatever `work` pointed at by then -- link or rename into a directory the rule had just refused to accept. The entry is now created in the directory that second judgment answers, spelled from it, which is what the local publisher already did. No state has to travel between staging and publishing: the judgment the publish already makes returns the directory. The ledger records the new digest of `publishScriptVersion` with a `compatibleChanges` entry: the call the declaration gained is one more destination check before the `mkdir`, so request, response and artifact framing are byte-for-byte what a released peer sends and parses.
Three shapes the destination-ancestry rule answered too generously: - `/etc/nsswitch.conf` now answers a database named on TWO lines with no sources, which refuses the private-group exception. glibc appends the sources of every line naming a database and consults them in order, so `group: files` above `group: files sss` really does consult `sss`, and holding to one line judged by a line the lookup never stopped at. - The walk reports whether it ARRIVED at the directory the entry is created in. `publishScriptFileSync` creates nothing, so it now refuses `root/missing/journey.ad` as `unreachable_parent` instead of publishing `root/journey.ad` — a file nobody asked for. - A `..` queued behind the first component that does not exist is refused as `unresolvable_parent` before either route's `mkdir` runs. The kernel cannot apply that step until the name before it exists, while `mkdir -p` resolves the same spelling as text and builds what stands on the far side of it, so `private/missing/../../shared/recordings` used to create a world-writable directory the rule never judged. A `..` over directories that all exist is applied one step at a time, as the kernel applies it. The walk's empty-queue exit moves to the loop that consumes the queue, the one place that sees a finished queue, and the unreachable branch inside a step is gone. The root-owned alias case now serves root for the alias and the directory that holds it: an alias owned by whoever runs the suite passed even if every root-owned link were refused, which is the macOS `/tmp` shape that must keep working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Amends ADR 0016 so the rule is smaller and sits in one owner. A script publish now creates every directory it makes at 0700, so a new directory passes the check a later recording judges it by instead of being refused at 0775 on a shared umask. host-kit owns the whole sequence as `prepareScriptDestination`: walk, refuse before creating anything, create what is missing inside the judged directory, judge again, answer with the judged directory. Both routes call it, and the exported prefix seam plus the two hand-sequenced copies are gone. Where nothing was missing, the first walk already judged the directory the entry is created in, so its answer is the answer and there is no second walk. The private-group exception is dropped. Membership cannot be proven on a host whose name service answers it from outside the account files, so a group-writable directory is refused on the mode alone and the hint names `chmod g-w`. No account database is read. A destination that is not absolute is refused at the entry, and the local publish keeps one walk instead of two. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four shapes the destination-ancestry rule still answered too generously, plus the daemon's own state directories under a shared umask: - Every step of the walk is judged from the `lstat` of the ENTRY, never re-read with `stat`: `stat` resolves a name a second time, and the name can answer a different entry by then, so a directory swapped for a link mid-walk was entered on the strength of its target. Where a walk returns to a name it judged, it re-reads that name only to recognize it and keeps the first judgment. Directory identities are read as BIGINT, because a 32-bit `ino` collapses two distinct large inodes onto one identity, and the answer is confirmed to hold the judged entry before a caller stages anything there. - A missing tail is created ONE LEVEL AT A TIME. A recursive `mkdir` resolves the whole tail as text, so a link another local user plants at one of the absent names while the walk runs carries the creation to its far side, where as root it creates with privileges. Each level is confirmed before the name below it is created, and a name that appeared between the check and the creation is refused (`entry_appeared`). - A destination that is not absolute is refused on every platform, Windows included, where no walk runs to catch it. - The daemon creates and repairs its state directory, `sessions/` and `remote-scripts/` at 0700 rather than through a mode-less `mkdir`, so a umask-002 host no longer gets 0775 `sessions/` and a refusal of the daemon's own default recordings and remote-delivered versions. `prepareScriptDestination` answers the judged directory WITH its identity, so the remote route stages each version where that answer points instead of walking the destination a second time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`repairStateMode` forced a mode by pathname, with no type and no ownership check. A root daemon starting against a legacy state directory another user could write can be handed a `sessions` that is a LINK, and the chmod travels through it to a directory that user owns. `ensurePrivateDaemonStateDir` now repairs each level it was asked for from its own `lstat` of the ENTRY: a link or a non-directory is refused (`state_dir_not_a_directory`), a level this process does not own is refused (`state_dir_foreign_owned`), and in both cases nothing is changed. What remains to repair is forced through a descriptor opened `O_DIRECTORY | O_NOFOLLOW`, whose `fstat` dev:ino is confirmed to be the entry the `lstat` judged, so the mode cannot be applied to a second entry behind the name. Ownership is asked only when a mode has to change, so the common startup is still one `lstat`, and no second rule is introduced. Coverage: the repair owner's refusals, and the same two shapes seen through the daemon's own state paths, with foreign ownership simulated as root state (serveHostOwnership); plus pre-existing owned 0775 `sessions` and `remote-scripts` repaired to 0700, which the previous test could not see because it started from 0700. ADR 0016 said remote delivery compares the judged identity ONCE. It asks the rule twice per version, because a download runs in between: prepare and allocate staging, then walk again and compare before the rename. What this branch removed is the THIRD walk the allocation used to run to be told a directory the call before it had already answered. The ADR, and the PR body, say that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the update. At 235d0db, the regex on the destination is gone, the walk now runs before any creation, and staging is allocated in the judged directory, so those parts of the earlier review (#4584 (comment)) are fixed. One finding remains. The remote route copies host-kit's refusal instead of calling it. Not blocking, and you can take or leave these: ADR 0016 :227 still says the remote pre-rename comparison is the only identity comparison, while :222 and the code re-check identity on every walk, so one of them needs to change; Could the change be smaller? The two fixes that carry the safety are judging every step from its single lstat, and creating each missing level with one non-recursive mkdir that judges an appeared entry by the same rule. The identity-compare and 'replaced' branch in The three earlier inline threads are fixed at this commit and can be resolved: the polynomial regex (#4584 (comment)), creation before the walk (#4584 (comment)), and staging outside the judged directory (#4584 (comment)). CI shows 20 checks with 0 not passing at 235d0db. The CI hosts run umask 022, so the umask route is covered only by the |
…e rest Host-kit now exports one confirmation: `confirmScriptDestination(destination, prepared)` walks the destination again, compares it with the identity `prepareScriptDestination` answered, and returns the directory to create the entry in. The remote route calls it after its download, under the record lock, so every `parent_replaced` refusal is built by `scriptAncestryFailure` and no route holds a copy of the reason, exposure, ancestor or hint. `destinationMoved` and the local identity compare are deleted, along with the hand-kept reason literals: the route reads the reason back through `scriptAncestryReason`. The recognition layer that grew around the walk is cut, because the ownership rule is what excludes anyone who could move a judged directory. The walk keeps no memory of ground it stood on, does not re-recognise a name it reached through a `..` or an alias, and runs no second identity check before a creation. What is kept per step is one `lstat` of that step, never a `stat`. `createMissingLevel` judges a name that appeared instead of refusing it: the same single `lstat`, the same rule. It adopts a private directory this user owns, refuses a foreign or writable one, and asks whether other local users could add the destination's own name inside it. Startup is pinned as the thing that repairs a state chain a legacy release or a shared checkout left at 0775, and a state repair that forces a mode through a descriptor is asserted as such. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
235d0db to
45d4eb9
Compare
|
Cut the recognition layer rather than defend it — head Blocking finding: routed through one exported host-kit call. One placement difference from your suggestion: the confirm runs after the download and before the rename, not in What was cut. Your ownership argument is the reason the layer is gone rather than the reason it stays, so it is gone — the whole thing, not a part:
I could not name an attack that layer caught which the ownership rule lets through, and I could not reproduce one against the pre-cut code. Every actor able to swap a judged directory had already been refused at it: a level the walk stands in is owned by this user or root with its contents closed to others, or is sticky, where this user's entry cannot be replaced. Nothing here was kept for a reproduced attack, and I found nothing whose removal reopens one. −96 production lines in this commit; What was kept, and the scenario each one answers.
Daemon state repair: yes to both, and named. Tests for it:
ADR 0016. The delta, reconciled. Our counts differ only in which files count as test files. Under the rule your numbers use (everything except
Why the total did not follow If the total still needs to come down, the honest split is by concern, not by deletion: the ancestry rule ( Red at Checks at Two things your comment names that this head does not claim to fix: CI still runs umask 022, so the shared-checkout route is covered by the |
There was a problem hiding this comment.
Apex Sentinel: 3 new findings on 45d4eb9. The verdict and the full list are in the summary comment.
|
Thanks for the update. At 45d4eb9 the host-kit changes close the earlier destination concerns, but one new problem remains: the daemon can now refuse to start on setups that work on main.
The rule the code must satisfy: a state-mode repair never decides whether the daemon starts. It forces 0700 only on a directory entry this uid owns, reached without following a link. Otherwise it changes nothing and emits Could the repair be the smaller design above? The host-kit cut helps: Not blocking, take or leave: the comment at atomic-file.ts:916 says the created level "would stand 0775" without the chmod, but The three earlier inline threads no longer apply, so please resolve them: no regex runs on the destination at 45d4eb9 (#4584 (comment)); Checks: 20 pass and one review check is still running; no failing job overlaps the diff. CI hosts run umask 022 as a uid that owns its temp dirs, so the symlink and foreign-owner shapes only run through the simulated-ownership test, which asserts the refusal. The startup problem comes from the code and the pinning test, not a run against a symlinked Separately, on main, |
…artup The repair forces 0700 through an O_DIRECTORY | O_NOFOLLOW descriptor only when the fstat of that descriptor says this uid owns the entry. Every other shape - a link, a name that is not a directory, a level another uid owns, EACCES/EPERM/EROFS from a mount it cannot force - changes nothing and emits daemon_state_mode_repair_skipped, so a symlinked state dir and a container whose sessions/ belongs to the mounted uid start as they did on main. The destination walk stays the only thing that refuses a recording. sameStateEntry, state_dir_entry_replaced, the duplicate ownership check and privateStateRefusal go with the refusal path they served. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot force The suites that pinned a state refusal are flipped to the rule: a level this uid does not own, a link, and a name the host will not open are all skipped with daemon_state_mode_repair_skipped, the daemon starts, and the destination walk is what refuses the recording under that tree with script_ancestor_untrusted. The unopenable case injects EACCES at the open seam rather than staging a 0000 mode, because a root process opens a 0000 directory it owns. serveHostOwnership now serves the ids through fstat as well, which is where a repair that forces a mode asks who owns the entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The paragraph that introduced the repair said the descriptor's fstat must match the lstat that judged the name. The lstat is now only the fast path, and ownership is answered by the fstat of the descriptor the chmod goes through, so the ADR says that instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45d4eb9 to
4b630c1
Compare
|
Folded in as three commits on top of the host-kit round: The rule, in the ADR before the code (
Both setups you named are pinned as startup tests, not unit tests: a Creation of missing state levels keeps the plain recursive The other cuts from the cross-check: ADR walk counts are stated: remote walks twice per version where the parent stands, three times where a level has to be created, one identity comparison either way; local walks once, twice with a missing parent, compares nothing. Net production is +1,022 (676 code, 380 comment; excluding tests, Disclosures carried over: the suites run under umask 022 and foreign ownership is a fixture uid (65534), so neither CI's umask nor a real second account is exercised on real ids; and |
|
This PR is ready at 4b630c1. The destination walk now refuses before it creates any level, the temp file is made inside the judged directory, and a foreign-owned state level is skipped with a diagnostic. The points from my earlier review are covered. All 21 checks pass at this commit, and the PR is still a draft, so it needs to be marked ready for review before merge. Not blocking: the fast path in daemon-registration-owner.ts returns on the lstat mode alone, so a symlink with its own 0700 mode (macOS gives this under umask 077) gets no daemon_state_mode_repair_skipped diagnostic, while ADR 0016 says every link shape emits one. Gating it on On evidence: Foreign ownership is simulated by rewriting the uid (65534) and EACCES is injected at openSync. No run used a real second uid, a root daemon, a read-only mount, or umask 002. One accepted trade-off: a user-owned symlinked ~/.agent-device whose target is 0775 is no longer chmod-ed through the link. Default recordings there are refused with shared_group_writable and a chmod g-w hint. Startup is unaffected. These earlier inline threads no longer apply, so you can resolve them: regex on the destination (no regex runs on it now), walk before level creation (the walk refuses first), mkdtemp location (it runs inside the judged directory), recursive mkdir through a planted level (pre-existing on main, and the chmod half is fixed via an O_NOFOLLOW fd), foreign-owned state level (now skipped with a diagnostic), and typed state_dir reasons (the untyped reasons are deleted). |
Two blockers in the best-effort state repair. A repair step that failed could still stop startup: the `lstat` stood outside the catch, unlisted errnos were rethrown, and the `close` that ends the repair could throw. Every step is now inside one catch, so `EACCES` on a level this user cannot read, `ENOENT` on one that disappears meanwhile, and `EIO` on the close are all reported as a skipped level and stop there. Creation keeps its own failures. `O_NOFOLLOW` guards only the LAST name of an open, so judging the requested level alone let an intermediate link redirect the repair: `sessions -> /etc` makes the leaf `sessions/ssh` resolve to `/etc/ssh`, and a root daemon forced that mode to 0700. The repair now walks DOWN from the state base, `lstat`s each level under its own name, and repairs a level only when every level above it passed. A link, a non-directory or a foreign-owned level stops the descent, and every level beneath it is left as it is. Callers pass the base they judge from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Correction to my note above: 4b630c1 is not ready. An independent security cross-check of this head found two blockers in the best-effort state repair in
The rule to satisfy: the repair never throws and never changes anything outside the state tree. It walks down from the state base and skips a linked, non-directory or foreign level and everything beneath it. I will review the next head. |
A link that carries its own mode answers the mode question with the private mode, so a repair that read the mode first passed an `lchmod 0700` link without judging it. The level-by-level repair already asks `isDirectory` before the fast path; this pins the order, and a skip is what such a link now reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Both blockers are fixed, each with a test that fails on 1. No repair error reaches startup. The whole repair —
2. The repair walks down from the state base. The reported shape is pinned directly: On the recursive The Head
Keeping this draft until the checks report, so the head under review is the head that was tested. |
Two blockers in the state repair. A remote version followed a state link the repair had skipped. The repair stops at a link, but the writer used the path the ensure call returned anyway, and the destination rule accepts a link standing in a parent others cannot write, so `sessions -> outside` and `remote-scripts -> outside` both published outside the state tree. Ensuring a state level now answers whether the whole chain from the state base is private ground, and a destination the daemon picked for itself — a remote version, or a default recording — is written only on such a chain. The write returns a typed refusal (`state_chain_untrusted`), the capability carries it as the `scriptDeliveryFailure` cause and keeps the action's success, and startup ignores the answer and still starts. A descriptor ownership rejection did not stop the descent: `forcePrivateStateDir` returned on a foreign uid while its caller returned `true` regardless, so the repair continued beneath a level it had just refused. The decision now travels out of the force step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Both blockers are fixed, each with a test that fails on 1. A remote version no longer follows a state link the repair skipped. Ensuring a state level now answers two things: the path, and whether every level from the state base down to it is private ground (a real directory, this uid's, standing 0700, reached without following a link). The two destinations the daemon picks for itself read the verdict: a remote version under The parameterized writer tests plant a link at 2. A descriptor ownership rejection now stops the descent. The new test injects a foreign uid through that descriptor only — Red at Head Disclosures carried over: these suites run under umask 022, and foreign ownership is a fixture uid (65534) — no real second account, root daemon, read-only mount, or umask 002 run. The recursive
|
A remote close dropped the typed reason. `remoteCloseScript` received only a boolean, so the close response's `scriptDeliveryFailure` said a version failed without saying which way it failed. The close write's AppError now travels into it, and its `details.reason` becomes the failure's `cause`, the same field the per-action route already fills. A level that disappeared before the repair reached it stopped the chain with no diagnostic: `lstat` answering `undefined` returned false silently, while every other stop reports itself. It reports now. The refusal hint names the host shape the cross-check found undocumented — a container or mounted volume that leaves the state tree to another uid — and its two fixes. The ADR and the two user docs say the same thing plainly: that host starts and answers every command, and loses only the recordings the daemon picks a path for; the refusal comes from the chain verdict, not the destination walk. State-level creation stays best-effort and happens before validation, so it can leave an empty directory beyond a rejected link, and that is stated too. Trimmed: the unchanged `prepared` value returned through `allocateStaging`, the one-use state-directory wrappers, the unused `gid` on `DirectoryAuthority`, and comments that repeated the same rule at every call site. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
All four items are in, plus the review thread. 1. The remote close keeps its typed reason. 2. A vanished level reports itself. 3. The ADR and the docs state the exception and the ownership consequence. ADR 0016 now says creation is best-effort and happens BEFORE any chain is judged — one recursive 4. Trimmed: Head The Disclosures carried over: suites run under umask 022, and foreign ownership is a fixture uid (65534). The recursive
|
Closes #4565.
open --save-script=<path>resolved the destination by name, so a second local user who could write any directory on the way could replace that component, or leave a link there before the entry was created, and move the recording wherever they chose. Both the local writer and the remote staging path had it.Node exposes no
openatorrenameat, so no re-check closes a race with a local attacker. The window is closed by permissions: a destination is accepted only where no other non-root local user can modify any directory the publish traverses. Then nobody can swap a component out or plant one, so the path the rule judged is the path the publish reaches.The walk resolves the parent as the kernel does, one component at a time, judging every directory it steps into rather than only the final real path. Each step rests on one
lstatof the ENTRY and never on astat, which would resolve the same name twice and answer whatever it points at by then: a link is judged as a link, against the directory that holds it, and the walk goes on to its target one component at a time. A..applies to the directory stood in, and a destination that is not absolute is refused on every platform.host-kit owns the sequence, and the surface is two calls.
prepareScriptDestinationwalks, refuses before creating anything, creates each missing level at0700with one non-recursivemkdirinside the judged directory, walks the completed chain, and answers with that directory and itsdev:ino.confirmScriptDestination(destination, prepared)is the one confirmation a caller that waits owes: it walks again, compares the identity, and returns the directory to create the entry in, so everyparent_replacedrefusal is built byscriptAncestryFailureand no route holds a copy of the reason, exposure, ancestor or hint. A missing level that exists by the timemkdirreaches it is judged by that samelstatrule rather than refused, which is where two processes saving into one new directory meet. Remote delivery walks twice per version where the parent already stands and three times where a level has to be created, and compares identity once, after the download and before the rename; the local publish walks once, twice with a missing parent, and compares nothing.Nothing recognises ground a walk already stood on. An earlier shape kept a per-walk memory of judged directories, re-compared an identity on every re-visit and before every creation, and refused
parent_replacedfrom inside the walk. That layer is cut: a directory the walk stands in is one this user or root owns that others cannot write in, or a sticky one where this user's entry cannot be replaced, so nobody the rule accepted is left to make the swap it defended against. The one retained comparison is the remote pre-rename one, and it is host-kit's.The daemon creates and repairs its own state directories at
0700, so a umask-002 host no longer refuses its own recordings. Startup is what forces a state chain a legacy release left at 0775, and that repair is best-effort on two counts. It judges the chain DOWN from the state base rather than the requested level alone, becauseO_NOFOLLOWguards only the last name of an open: each level islstated under its own name, and a level is repaired only when every level above it passed, so asessionsanother user left as a link to/etcstops the descent before anything below it is opened — a root daemon no longer reaches through it to force0700on/etc/ssh. And it catches every step it takes, soEACCES,ENOENTandEIOfrom thelstat, the open, thefstat, thefchmodor the closingcloseare reported and stopped rather than thrown. A link, a name that is not a directory, and a level another uid owns are each reported the same way, asdaemon_state_mode_repair_skipped; a level is asked what it IS before its mode, so a link carrying its own0700is reported too. Onlymkdirkeeps its own failures. A~/.agent-devicesymlinked to another disk, and a container whosesessions/belongs to the uid the volume was mounted with, therefore start exactly as they did before this change and answer every command. The repair never decides whether the daemon starts. What it ANSWERS is separate from what it forces: it reports whether the whole chain from the state base down to the level it was asked for is private ground — a real directory, this uid's,0700, reached without following a link — and a script the DAEMON picks for itself, a default recording or a remote version, is written only on such a chain, refused withstate_chain_untrustedotherwise. That refusal is the chain verdict's own, not the walk's: the walk judges ground and accepts a link standing in a parent others cannot write, so asessionsleft as a link would otherwise carry a remote version outside the state tree. So the host whose state tree belongs to another uid keeps a working daemon and loses its daemon-picked recordings, which is the decision here: a level somebody else owns can be replaced by them at any moment, so it is not ground to publish a recording on. The hint names that host shape and both fixes (chown, orAGENT_DEVICE_STATE_DIRat a directory the daemon owns), andreplay-e2e.mdandremote-proxy.mdsay the same to users. A caller's--save-script=<path>is unaffected on every one of those hosts: that destination stays the walk's alone, and a recording under ground the daemon does not own is refused there, per recording, withscript_ancestor_untrustedand its hint. Creation is best-effort too and happens BEFORE any chain is judged — one recursivemkdirbuilds the whole tail, which is what keeps a base that is a link working — so a chain the repair stops on can be left with an empty directory beyond the level it stopped at. Nothing is validated before that creation, and nothing is ever written into what it leaves.A group-writable directory is refused outright, with a
chmod g-whint: the private-group exception is dropped, since membership cannot be proven where a name service answers outside the account files. Scripts are0600. What sits outside the guarantee — ACLs, network mounts, a mount over a checked directory — is named in the ADR and the guide.