Repository navigation
security(spikes): FIO15-C secure-directory rule for the activation store; check and use the same path in store and TUF client - #68
Draft
marcohost33-maker wants to merge 6 commits into
Conversation
… for the store location The store refused only a world-writable root and a root owned by another account. A group-writable root, and a parent directory in which another account can rename entries, were accepted: whoever can write there can move the whole store away and put another one in its place. Every open now checks, before the first read or write: - the root is a real directory, belongs to the effective account and is not writable by group or others; - every directory above it belongs to that account or the superuser, and group/other write is accepted only together with the sticky bit; - directories are checked from the file-system root down and the store then uses the canonical path. The rule is implemented independently of the TUF client spike and compared with it over every type/owner/mode combination (655,360 comparisons). Ten new source-bound mutations (28/28 killed); crash-matrix report regenerated for the changed sources (58,078/58,078, 4/4 negative controls). Windows ACLs and POSIX ACLs are not inspected (documented limit). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_015cjLSvoGs28S18r5dFiJWz
…hing tests Two store tests count or disturb adapter calls by comparing paths with their own root. The store now works on the canonical path, so on macOS (/var is a link to /private/var) the comparison no longer matched and both failed in activation-store-ci. Reproduced locally with TMPDIR pointing at a link: 69 pass / 2 fail before, 71 / 0 after. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_015cjLSvoGs28S18r5dFiJWz
A critical self-review of the store trust boundary found four gaps where the secure-directory rule was right but applied to the wrong object, and two of them also in the TUF client: Activation store - the root rule is judged on the canonical path that all IO uses, not on the requested one (a link above the root re-pointed during the check could make the store approve one directory and use another); - after mkdir the root is looked at again: mkdir reports an existing name as "nothing to do", so in a sticky parent another account could plant the root or a link; - a POSIX adapter without realpath is refused (INVALID_ARGUMENT) instead of silently skipping the ancestors; only the in-memory model skips them; - objects/, tmp/, state/, STORE and state/CURRENT follow the same entry rule (a replaceable commit record allows replaying an older one). TUF client - secureMetadataDir canonicalises only the parent and judges the directory and its files on the canonical path; - initClient checks the location again after mkdir -p, before the first byte is written (mkdir -p accepts a planted directory or link). Evidence: 13 store boundary tests and 2 new client tests with seams at the exact windows; rule differential now 983,040 comparisons (directory, file and ancestor rules, 0 disagreements); store mutations 36/36 killed, TUF boundary mutants 16/16 killed locally (unit detector); crash-matrix report regenerated (58,078/58,078, 4/4 controls, 312/312 real-fs); npm test 522 pass / 0 fail; verify:local OK. The store mutation check now runs in activation-store-ci (Linux). Docs: FIO15-C is a recommendation, OpenSSH safe_path is stricter (no sticky exception) and walks upwards; the leaf-to-root order of the client is argued in its threat model. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015cjLSvoGs28S18r5dFiJWz
… running account The first CI run of the new mutation step (ubuntu, unprivileged) reported 35/36: "root ownership is not checked" survived. The test played a foreign account through currentUserId + 1; unprivileged, that also made the own workspace above the root foreign, so the ancestor rule refused first with the same error code and the root's owner check was never reached. As uid 0 the workspace belongs to the superuser and the root rule decided. Now only the root appears foreign (adapter lstat), and the test checks the message, not just the code. 36/36 as uid 0 and as nobody. NR updated; the todo row for #55-#59 gets the test-level evidence that their content is on main. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015cjLSvoGs28S18r5dFiJWz
The benchmark rounded MiB/s to one decimal. The 16 KiB smoke profile then reported 0 whenever staging with fsync took longer than about 0.31 s, which happened on Windows CI at c4d35dc and failed the "throughputMiBps.stage > 0" assertion (unrelated to the boundary change: the same test was green on Windows one commit earlier). Rates from 1 MiB/s keep one decimal; smaller rates keep two significant digits. Unit test added. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015cjLSvoGs28S18r5dFiJWz
The tuf-ed25519-differential workflow at de2f764 ran the mutation study with every detector and --require-all: 54/54 killed, clean baseline; the three new directory-rule mutants were killed by the unit detector. todo row closed, status and changelog updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015cjLSvoGs28S18r5dFiJWz
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.
APP-01 Browser Pull Request
Scope
browserand does not move Engine/ENG-01 work into this repository.Affected boundaries: the account boundary of the activation-store spike (
spike/activation-store/, ADR-007a section 6) and, sincede2f764, the location check of the TUF client spike's trusted state (spike/tuf-offline-metadata/client/). Non-goals: no installer wiring, no package format, no Windows ACL inspection.Change
1. Store location rule (
833b307). The store refused only a world-writable root and a root owned by another account. It accepted a group-writable root, and a parent directory in which another account can rename entries. Whoever can write there can move the whole store away and put another one in its place, whatever the root's own mode says. Every open now follows the SEI CERT FIO15-C "secure directory" recommendation before the first read or write: the root is private to the effective account; every directory above it belongs to that account or the superuser and is group/other-writable only with the sticky bit; directories are checked from/down and the store then works on the canonical path.currentUserIdof the Node adapter is now the effective uid. Fix for macOS (0ff07be): two tests compared adapter paths with a non-canonical temp root.2. Hardening after a critical self-review (
de2f764, test fixc4d35dc, benchmark fix3de499d, docs64acf5a). The rule was right but sometimes applied to the wrong object:mkdiron an existing name is "nothing to do": in a sticky parent another account can plant root or linkmkdirrealpathskipped the ancestors silently (fail-open)INVALID_ARGUMENT; only the in-memory model skipsobjects/,tmp/,state/,STORE,state/CURRENTchecked for type only; a replaceable commit record allows replaying an older one (rollback)initClientwrote aftermkdir -p, which accepts a planted directory or a link to one (reproduced on Node 22)mkdir -p, before the first byteDocs corrected: FIO15-C is a recommendation, not a rule; OpenSSH
safe_path()is stricter (no sticky exception) and walks upwards. The client's leaf-to-root order is argued in its threat model (for fixed canonical paths the order does not change the verdict), which closes the P3 item intodo/.Failure codes:
STORE_ROOT_INVALID,STORE_LAYOUT_INVALID,INVALID_ARGUMENT(store);INSECURE_LOCAL_STATE,LOCAL_STATE_CHANGED(client).Risk and privacy
Behaviour changes to check in review: a store below a group- or world-writable directory without the sticky bit, with a group-writable root, layout directory, marker or commit record, or opened through an adapter without
realpath, no longer opens. A TUF metadata directory whose name resolves elsewhere aftermkdir -pfails init withLOCAL_STATE_CHANGED.initClientandatomicWriteFilegained optional trailing parameters (test seam,afterMkdirhook); existing calls are unchanged. Neither spike has a consumer yet, so nothing is migrated.Limits (README and threat model): Windows ACLs and POSIX ACLs are not inspected; the rules are evaluated at open, not continuously; objects and temp files are not checked one by one (objects are content-addressed); same-account tampering stays out of scope.
Verification
npm ci --ignore-scriptsnpm run csp:checknpm test— 527 tests, 522 pass, 0 fail, 5 skipped (Linux, Node 22.23.5, as superuser); activation tests also asnobody(75 pass, 1 skipped) and under a symlinkedTMPDIR(75/75, the macOS/varcase)npm run verify:local: OK; external link check andaudit:cinot run locally)activation-store-ci.ymlgained one step (zizmor runs on this PR)CI (not reproducible locally):
activation-store-cigreen on Linux, Windows and macOS, the Linux job including the store mutation check (36/36, unprivileged);tuf-ed25519-differentialatde2f764ran the full mutation study with every detector and--require-all: 54/54 killed, clean baseline.Two CI findings on the way, both fixed with a commit, no comment needed:
de2f764, ubuntu: the new mutation step reported 35/36. The root-owner test faked a foreign account viacurrentUserId + 1; unprivileged, the ancestor rule then refused first with the same code, so the root's own owner check went untested (as uid 0 it did not show). Fixed inc4d35dc: only the root appears foreign, the message is asserted; 36/36 as uid 0 and asnobody(pr_nr/NR/suite-as-superuser-hides-ownership-mutant.md, recurrence section).c4d35dc, Windows: the benchmark rounded MiB/s to one decimal, so the 16 KiB smoke profile reported 0 when staging with fsync took more than about 0.31 s. Pre-existing, unrelated to the boundary; fixed in3de499d(two significant digits below 1 MiB/s, unit test).Evidence
tests/activation/trust-boundary.test.js, 13 tests, including races simulated through the adapter: a link re-pointed insiderealpath()(F1), a link planted insidemkdir()(F2), an adapter withoutrealpath(F3), group-writable/foreign-owned layout entries and commit record (F4).tests/tuf/tuf-client-trust-boundary.test.js: two new tests with seams at the exact windows (probes.directory.afterCanonicalize,initClient(..., probes).beforeWrite) for F5 and F6, each with a control case.harness/mutation-check.mjs: 18 boundary mutations, 36/36 killed; now also a step ofactivation-store-ci(Linux).client-leaf-checked-through-requested-path,client-init-trusts-mkdir,client-init-recheck-ignores-location); the boundary subset 16/16 killed locally with the unit detector, each new mutant also by its targeted test alone.results/crash-matrix-report.jsonregenerated for the changed sources: 58,078/58,078 consistent, 0 durability violations, 4/4 negative controls; real-filesystem process crashes 312/312 over 8 scenarios (Linux).pr_nr/NR/judged-on-another-name-than-used.md,pr_nr/PR/race-seams-make-toctou-testable.md.main: evidence per issue at test level intodo/README.md(the heads of fix(tuf): reset targets rollback floor on snapshot/timestamp key rotation (#57) #58/fix(tuf): crash-safe #57 reset + pinned targets.json (#55), keyid-to-role guard (#56) #59/fix(tuf): consolidate #58/#59 on main, close P2-BR59-01 (secure-directory boundary), fix C5, add C6 #64 are not ancestors ofmain; the content came consolidated through test(tuf): real process kills before every refresh step; bounded fresh re-read (BR64-04, BR64-02) #66/test(tuf): crash matrices for download and its target cache; stateful rollback differentially (R8) #67). Closing them stays an owner decision.Release and rollback
Open: a cross-family security review of the trust-boundary code on
main(todo/, P1).https://claude.ai/code/session_015cjLSvoGs28S18r5dFiJWz
Generated by Claude Code