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. |
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>
Two shapes the rule has to refuse at the writer, not only in the rule itself: a directory its owner made sticky with `chmod 1777`, where the sticky bit shields other users from that owner rather than the reverse, and a shared directory somebody else created first under `mkdir -p`. Both run as a second local user, because handing a directory to another uid needs privileges a test does not have. Refs #4565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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) |
A destination was judged only along the real path of its deepest existing ancestor, so a plain directory under a shared one hid a link into a private destination, and one link into another link named none of the ground it crossed. Every existing prefix is now expanded link by link and each directory it steps into is judged. The remote route creates the missing parent before it asks, so both routes answer about the directory the entry is really made in. The private-group exception now reads every group record carrying that gid, because all of their members hold write. Access control lists, network filesystems and mounts are named as outside the guarantee. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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. |
The destination rule resolved each existing prefix with `realpathSync` and judged the chains it got back, so a directory the resolution stepped through could leave the answer: a link in the middle of a target hid its directory, a followed link's owner was never asked, and a `..` was applied to the spelling rather than to the link's target. `assertNoPlantedLink` covered only the links in the spelled path, so an expanded hop skipped the check. One walker now replaces `traversedDirectories`, `assertNoPlantedLink`, `resolvedDirectory`, `linkTarget`, `parentDirectory` and every `realpath` call. It starts at `/`, or at the process's resolved working directory for a relative spelling, and resolves the spelled components one at a time: `.` is skipped, `..` moves to the parent of the directory physically stood in, any other name is lstat'ed there. A directory is judged and entered; a link is judged itself against the directory that holds it, and its target's components go on the front of the queue. Hop count is refused as `link_loop_exceeded` below the kernel's own limit, so a walk that ran out of hops is a refusal, and a step that cannot be travelled through is refused as `not_a_directory`. The private-group exception now fails closed: it is admitted only when `/etc/nsswitch.conf` exists, is readable, and lists `files` as the only source for `passwd` and `group`, because a name service can hold a member the two files never show. `systemd` is refused for the same reason. The account name is read from the passwd database the rule judges rather than from a second host lookup, and the script file mode is fixed at `0600`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #4565.
open --save-script=<path>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 recording wherever they chose. Both the local writer and the remote staging path had it.Node exposes no
openat,renameat,linkatormkdirat, so a publisher cannot resolve a destination relative to a verified directory handle, and no re-check closes a race with a local attacker. The window is closed by permissions: a destination is accepted only when no other non-root local user can modify any directory the publish traverses. Once that holds, nobody can swap a component out or plant one, so the path the rule judged is the path the publish reaches.Every directory the kernel steps into is judged, not only the final real path. Each existing prefix of the spelled parent is expanded link by link, and the directory holding each link target is judged with it. One
realpathis not enough: a plain directory under a shared one can hold a link into a private destination, so the destination looks private while the ground it stands on is shared, and a link whose target is another link never names the directory crossed in between...stays in the path it was spelled with, so<dir>/shared/work/../xis judged as the walk the kernel performs, withworkin it.A destination is refused under
script_ancestor_untrustedwhen a traversed directory is owned by neither you nor root (foreign_owned); is writable by other (world_writable) or by a group that is not your own private group (shared_group_writable); is where the entry would be created while others may also add entries (shared_parent); or holds a link another user could have planted or could replace (planted_link).Root-owned system aliases such as macOS
/tmpand/varkeep working. The remote route creates the missing parent before it asks, so both routes answer about the directory the entry is really made in. The publisher also compares the destination directory'sdev:ino: defense in depth, not the thing that closes the window. Scripts are created 0600 locally as well as remotely.The private-group exception for the Ubuntu and Debian group-writable home now fails closed: both database files must be readable, the gid must be this process's primary group, and EVERY record carrying that number is read, since all their members hold write —
ada:x:1000:besideteam:x:1000:gracereaches grace.What sits outside the guarantee is named in the ADR and the guide: access control lists are consulted ahead of the mode bits and are not read, ownership on a network mount is the server's to give, and a mount can appear over a checked directory. The promise is that no other local user can steer where the recording is written; it is not a promise that nobody else can read it.
🤖 Generated with Claude Code