Skip to content

Re-sanitise leaked home path in Codex fixture; fix Codex manifest version/description drift (#467, #470) - #472

Merged
fdaviddpt merged 4 commits into
mainfrom
fix/467
Aug 29, 2026
Merged

fdaviddpt merged 4 commits into
mainfrom
fix/467

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #467
Closes #470

Two release-blocking issues from the round-1 v0.24.0 audit, one lane, closing both.

#467 -- fixture leaked a real home directory and username

tests/fixtures/codex-rollout.jsonl, a committed real (sanitised) Codex capture, carried the maintainer's real home directory and OS username in two nested JSON-string blobs (originally lines 6-7) that the original field-keyed sanitisation never walked -- it replaced cwd/git/turn_context at the top level, not a path embedded inside a serialised string value. Because .agents/plugins/marketplace.json declares a local install source, tests/ ships into every install, so this would have reached every 0.24.0 user, not just this repo's own history.

Both occurrences are replaced with the fixture's existing sanitized-user placeholder convention. tests/test_codex_upsubmit_stdout_451.py had its own, unrelated occurrences of the same literal username as hand-authored test data and is fixed the same way.

The durable half: tests/test_no_real_home_paths_467.py, a new guard that fails the build if any file under tests/fixtures/ names a /Users/<x>/ or /home/<x>/ segment other than the sanitised placeholder. Deliberately scoped to tests/fixtures/ rather than the whole tree -- /Users/ and /home/ already appear legitimately throughout this repo's hand-authored test parametrize data (tests/test_hooks_json.py's adversarial path list, tests/slug_vectors.py, docs/slug-vectors.json) and documentation (README.md's worked examples), none of which can leak a real credential the way a real capture can. The scoping argument is in the test file's own docstring.

Test-first: watched the guard fail (1 failed, 2 passed) against the un-sanitised fixture via git stash, then pass (3 passed) after the fix.

#470 -- .codex-plugin/plugin.json unmaintained

Two defects in one file, both misreports:

A cross-manifest version-match guard already existed (tests/test_codex_manifest_410.py::test_codex_plugin_manifest_version_matches_claude_manifest) and needed no change -- it already fails whenever .codex-plugin/plugin.json and .claude-plugin/plugin.json disagree, which is the recurrence #470 asked a guard for.

Self-review (Explore + oss:auditor, both against the first commit)

Both spawns returned real findings, both fixed in a follow-up commit:

Below-bar finding, recorded here rather than filed (no reachable caller): the auditor separately named _fixture_files() in the new guard test as non-recursive (Path.iterdir(), not rglob()), which is not currently a gap since tests/fixtures/ is flat, but is worth naming so a future nested fixtures directory is not silently assumed covered.

Follow-up: coordinator caught a defect in the guard before push

Before pushing this branch the coordinator declined to push and asked for a second look at the new guard rather than deferring to their own read. Two claims, both verified correct:

  1. The guard's docstring argued hand-authored .py literals "can never carry a real person's real credentials by the mechanism that produced Test fixtures ship the maintainer's home directory and OS username into every install #467" -- but Test fixtures ship the maintainer's home directory and OS username into every install #467 shipped in TWO files, and the second, tests/test_codex_upsubmit_stdout_451.py, is exactly a hand-authored .py literal carrying a real credential pasted from live probe output. The premise was falsified by the issue's own evidence.
  2. That second leak ("[10:54 CEST -- floriandavid]") is a bare username, not a /Users/<x>/ or /home/<x>/ path -- so the existing path-shaped regex would not have matched it at any scope, tree-wide included.

Fixed in a follow-up commit: a second, independent, tree-wide detector keyed on getpass.getuser() (the account running the suite) rather than a path pattern. Fires when a contributor's own real username appears verbatim in any tracked file -- exactly the shape #467's second file shipped. Explicitly honest about its own limit, in the test's own docstring: under a CI runner account this is near-vacuous (the runner's login name is not a contributor's real identity), and a green CI leg here must not be read as coverage -- the real guard is a contributor running the suite locally, under their own username. Has its own positive control and was watched red (planted an occurrence in a working-tree-only copy of README.md, reverted immediately after) then green.

Test plan

  • pytest tests/test_no_real_home_paths_467.py -- red (1 failed, 2 passed) against the un-sanitised fixture via git stash, green (3 passed) after
  • pytest tests/test_codex_manifest_410.py tests/test_codex_upsubmit_stdout_451.py tests/test_extract.py tests/test_codex_hook_transcript_465.py tests/test_summarizer_routing_460.py tests/test_config_contract.py -- all pass
  • python3 scripts/assemble_changelog.py --check (or .oss/assemble_changelog.py --check) -- both fragments recognised and folded without error
  • git grep -n floriandavid -- . -- no remaining occurrences anywhere in the tree

fdaviddpt and others added 4 commits August 29, 2026 16:16
… Codex manifest's stale version/description (#467, #470)

Two defects the round-1 v0.24.0 release audit found blocking the tag.

#467: tests/fixtures/codex-rollout.jsonl carried the maintainer's real
home directory and OS username in two nested JSON-string blobs the
field-keyed sanitiser never walked. Since .agents/plugins/marketplace.json
declares a local install source, tests/ ships into every install, so this
would have reached every 0.24.0 user. Re-sanitised to the fixture's own
placeholder convention, plus a new guard
(tests/test_no_real_home_paths_467.py) that fails the build if any
tests/fixtures/* file names an un-sanitised /Users/<x>/ or /home/<x>/
segment, scoped to fixtures (real captures) rather than the whole tree,
where /Users/ and /home/ already appear legitimately in hand-authored
test data and docs.

#470: .codex-plugin/plugin.json was missing from .oss.json's
version_sites (so tagging would have shipped it one version behind,
correctable only by another release) and its description still claimed
the Codex layer was unverified, false since #443/#460/#463/#465. Fixed
both; a version-match guard already existed
(tests/test_codex_manifest_410.py) and needed no change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…s sibling hooks/hooks.codex.json's stale #410 description (#470)

Self-review (two independent spawned reviewers) caught two follow-on
defects in the previous commit's own #470 fix:

- The new .codex-plugin/plugin.json description claimed "per-turn
  capture is still broken (#444), not fixed yet" -- #444 was already
  fixed and merged to main (163bc51, PR #446) before this branch was
  even cut, so the sentence this fix wrote was wrong the moment it
  landed. Corrected to list #444 among the verified/fixed issues.
- hooks/hooks.codex.json carries the exact same "not verified against
  a running Codex install (#410)" sentence .codex-plugin/plugin.json
  had, in the same subsystem, and was missed by the original commit.
  Brought in line with the same corrected wording.

changelog.d/470.fixed.md updated to match. Not in the file list the
brief named for this lane, but same subsystem, one sentence, and the
same misreports defect class #470 was filed for -- fixed rather than
filed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…leaked file shipped

The coordinator caught a defect in the previous commit's own #467 guard
before pushing, and asked for a second look rather than taking their word
for it -- confirmed correct.

The guard's docstring argued hand-authored .py literals "can never carry
a real person's real credentials by the mechanism that produced #467".
That premise is false: #467 shipped in TWO files, and the second,
tests/test_codex_upsubmit_stdout_451.py, is exactly a hand-authored .py
literal carrying a real credential -- pasted from live probe output. It
is also a BARE username, not a /Users/<x>/ or /home/<x>/ path, so the
existing path-shaped regex would not have matched it even scoped
tree-wide.

Two different shapes need two different detectors. The existing
fixtures-scoped path check (Detector 1) is unchanged and its scoping
argument still holds for PATHS specifically -- /Users/ and /home/ have a
flood of legitimate hits in this repo's hand-authored test data that a
username search does not.

New: Detector 2, tree-wide, keyed on getpass.getuser() -- the account
name of whoever runs the suite. Searches every git-tracked file for a
verbatim occurrence of the current machine's own OS username. Fires
exactly when a contributor has pasted their own identity into the tree,
which is when it matters. Explicitly honest about its own limit, in the
test's own docstring rather than left implicit: under a CI runner account
this is near-vacuous (the runner's login name is not a contributor's real
identity) and must not be read as coverage from a green CI leg -- the real
guard is a contributor running the suite locally. Short/generic account
names (root, admin, runner, ...) are skipped loudly via pytest.skip rather
than searched, to avoid false-positive noise across ~300 tracked files.
Has its own positive control (a detector keyed on a name that never
appears cannot fail) and was watched red (planted an occurrence in
README.md, reverted after) then green.

changelog.d/467.fixed.md updated to describe both detectors and the
username check's honesty clause.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…unt names (#472)

The coordinator caught a real false positive before pushing: PR #472 went
red on windows-latest/3.10, tests/test_no_real_home_paths_467.py's new
username detector flagging 'runneradmin' (the Windows runner's actual
account) inside tests/test_stale_config_sweep_362.py's own deliberate
Windows path fixtures.

Explicitly declined the easy fix: adding "runneradmin" to
_GENERIC_USERNAMES would only fix this one CI image. Every CI image has
its own account name, discovered the same way this one was -- a red build
on somebody else's release -- and a skiplist that grows one entry per
incident costs more than it catches.

Read tests/test_case_divergence_298.py's _origin_main_should_be_resolvable
(#442) before deciding, per the coordinator's pointer, since it is the
same shape of question (should a guard fail or skip on CI) answered the
opposite way. The two differ in kind: #442's precondition (origin/main
resolvable) is something CI's own checkout step is supposed to guarantee,
so its absence is a real infrastructure defect worth failing loudly over.
This detector's precondition -- running under a contributor's own account
-- is never true on CI by design, not by a setup failure, so there is no
defect for a loud failure to surface; asserting against the runner's
account name only ever manufactures false positives.

Added _username_check_should_run(env), returning False whenever CI or
GITHUB_ACTIONS is set, pinned by two tests mirroring #442's own
test_origin_main_unavailable_outcome_fails_loudly_on_ci /
_skips_locally shape so neither arm (always-run, reintroducing #472;
always-skip, a guard nobody runs) can silently regress. The real check
skips loudly there, via pytest.skip with the full reasoning in the skip
message (visible under pytest -rs, reported distinctly from a pass in
pytest's own summary line -- verified: `CI=true pytest ... -rs` shows
"1 skipped" naming the reason). Verified the fix directly: with the
scanner mocked to see username 'runneradmin', the check still fails
locally (no CI signal) and skips loudly under GITHUB_ACTIONS=true --
confirming this is a principled CI/local discriminator, not a disguised
skiplist entry for one more name.

The fixtures-scoped path guard, the re-sanitisation, and the .oss.json /
.codex-plugin work are untouched, as instructed -- git status confirms
only this file and its changelog fragment changed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@fdaviddpt
fdaviddpt merged commit eb60b7c into main Aug 29, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/467 branch August 29, 2026 15:06
fdaviddpt added a commit that referenced this pull request Sep 28, 2026
…tial) (#840)

* fix(#835): add a CI-safe recurrence guard for previously-leaked values

`tests/test_no_real_home_paths_467.py`'s username detector (detector 2)
is deliberately skipped on CI (#472) because there is no general,
CI-safe way to tell a contributor's real leaked username apart from a
CI provider's own runner account name. #835 reports the side effect:
this class of regression can merge to main with a fully green CI run,
and #822's own fix (PR #824) demonstrated it -- it scrubbed the file
the issue named but reintroduced the same real value into two other
files the same commit added, with CI green throughout; #825 repeated
the identical shape.

Add detector 3: an unconditional, CI-safe hash-based regression guard.
`_KNOWN_LEAK_HASHES` holds the SHA-256 hex digest of any value already
confirmed to have leaked (never the plaintext); `_known_leak_offenders`
scans every git-tracked file for a token matching one of those hashes.
It carries none of detector 2's false-positive risk because it depends
on neither `CI`/`GITHUB_ACTIONS` nor `getpass.getuser()`, so it runs
everywhere, including CI, and would have caught #822's reintroduction
into a different file.

This does not solve #835's general question -- a genuinely new leak,
never seen before, has no hash on the list yet and stays invisible to
this detector by construction, so the general problem detector 2
exists for remains open. The module docstring's new "Detector 3"
section documents the rationale and how to add an entry after a
future incident.

Ships with `_KNOWN_LEAK_HASHES` empty; two new tests
(`test_known_leak_hash_detector_fires_on_a_planted_leak` and its
must-not-fire pair) exercise the real matching function directly so
the empty-list state cannot be mistaken for an untested one.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(#835): review round -- validate leak-hash granularity, scope claims

Self-review (Explore + oss:auditor, both against 248e9d9) found a
consequential gap: _KNOWN_LEAK_HASHES entries were documented as
"hashlib.sha256(leaked_value.encode()).hexdigest()" with no constraint
on what "the leaked value" means, but _known_leak_offenders only ever
hashes the tokens _LEAK_TOKEN extracts (runs of [A-Za-z0-9_.-]). A
maintainer following the old wording literally for a path-shaped leak
(exactly what #822 leaked, e.g. "/Users/realname/project") would build
an entry that can never match anything -- the tokenizer only ever sees
"Users", "realname", "project" as separate tokens, never the whole
string -- with no error to say so. That silently defeats the detector's
whole purpose for the input shape its own commit message cites as
motivation.

Add `_leak_hash(token)`, the only supported way to build an entry now:
it hashes the token like before but raises ValueError up front when the
token is not already a single bare _LEAK_TOKEN unit, turning the
mistake into a loud failure at add-time instead of a permanent silent
no-op. Two new tests pin both directions
(test_leak_hash_rejects_a_value_that_is_not_a_bare_token,
test_leak_hash_accepts_a_bare_token); the existing positive/negative
controls are rewired through _leak_hash so normal use exercises it too.

Also: softened the "forever, on every platform" wording in the
unconditional guard test's docstring and the module docstring's
Detector 3 section to state the real, narrower scope precisely (exact,
case-sensitive, separator-delimited recurrence only -- not a substring
or case-variant match), and updated the file's stale opening summary
line to mention the new detector's scope alongside the pre-existing
path/username ones.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant