Skip to content

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
mainfrom
claude/projekt-browser-overview-sa847r
Draft

marcohost33-maker wants to merge 6 commits into
mainfrom
claude/projekt-browser-overview-sa847r

Conversation

@marcohost33-maker

@marcohost33-maker marcohost33-maker commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

APP-01 Browser Pull Request

Scope

  • This change belongs to APP-01 browser and does not move Engine/ENG-01 work into this repository.
  • Non-goals and affected trust boundaries are stated.

Affected boundaries: the account boundary of the activation-store spike (spike/activation-store/, ADR-007a section 6) and, since de2f764, 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. currentUserId of 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 fix c4d35dc, benchmark fix 3de499d, docs 64acf5a). The rule was right but sometimes applied to the wrong object:

# Gap Fix
F1 Store root judged on the requested path, canonical path adopted unchecked (a link above re-pointed during the check) root judged on the canonical path
F2 mkdir on an existing name is "nothing to do": in a sticky parent another account can plant root or link look again after mkdir
F3 Adapter without realpath skipped the ancestors silently (fail-open) INVALID_ARGUMENT; only the in-memory model skips
F4 objects/, tmp/, state/, STORE, state/CURRENT checked for type only; a replaceable commit record allows replaying an older one (rollback) same entry rule for all of them
F5 TUF client checked the metadata directory before canonicalising its ancestors only the parent is canonicalised; directory judged on the canonical path
F6 TUF initClient wrote after mkdir -p, which accepts a planted directory or a link to one (reproduced on Node 22) re-check after mkdir -p, before the first byte

Docs 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 in todo/.

Failure codes: STORE_ROOT_INVALID, STORE_LAYOUT_INVALID, INVALID_ARGUMENT (store); INSECURE_LOCAL_STATE, LOCAL_STATE_CHANGED (client).

Risk and privacy

  • Security and privacy impact assessed.
  • Untrusted input, credential, endpoint, storage and rendering paths reviewed where relevant.
  • No new telemetry, remote asset, persistent sensitive storage or broad network permission was introduced without an ADR.

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 after mkdir -p fails init with LOCAL_STATE_CHANGED. initClient and atomicWriteFile gained optional trailing parameters (test seam, afterMkdir hook); 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-scripts
  • npm run csp:check
  • npm test — 527 tests, 522 pass, 0 fail, 5 skipped (Linux, Node 22.23.5, as superuser); activation tests also as nobody (75 pass, 1 skipped) and under a symlinked TMPDIR (75/75, the macOS /var case)
  • Documentation lint passes (npm run verify:local: OK; external link check and audit:ci not run locally)
  • Workflow security audit passes when workflows changed — activation-store-ci.yml gained one step (zizmor runs on this PR)
  • Negative/regression tests demonstrate that the control fails closed.

CI (not reproducible locally): activation-store-ci green on Linux, Windows and macOS, the Linux job including the store mutation check (36/36, unprivileged); tuf-ed25519-differential at de2f764 ran 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 via currentUserId + 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 in c4d35dc: only the root appears foreign, the message is asserted; 36/36 as uid 0 and as nobody (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 in 3de499d (two significant digits below 1 MiB/s, unit test).

Evidence

Release and rollback

  • Compatibility and migration impact documented.
  • Rollback or safe disablement path documented. — revert of the six commits; no stored format changed.
  • Public-facing claims do not exceed verified behavior.

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

… 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
@marcohost33-maker marcohost33-maker changed the title security(activation-store): enforce the FIO15-C secure-directory rule for the store location security(spikes): FIO15-C secure-directory rule for the activation store; check and use the same path in store and TUF client Dec 2, 2026
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants