Repository navigation
Merged
Conversation
git-backup no longer stages or commits a slug's config.json -- a documented home for a live haiku.oauth_token -- excluding it in $GIT_COMMON_DIR/info/exclude alongside logs/tmp, and untracking it on the next backup for a store that committed one before this fix existed (#719). git-restore's detached fetch, and the mirroring push call in git-backup, now separate their remote/branch operands with `--` and validate git_restore.remote/git_backup.remote and their branch equivalents as plain names before use. Those values are read from config.json, which is git-tracked and fast-forwarded FROM the very remote it configures, so without the separator and validation a `-`-leading value reached git's own option parser rather than an operand (#723). Co-Authored-By: Max <noreply>
Self-review (oss:auditor) found that the #723 branch-name guard only checked for a leading '-', while the sibling remote-name guard also rejects ':' and '/'. `--` stops git's OPTION parsing but not its own src:dst REFSPEC grammar, so a colon-bearing branch value (e.g. "main:refs/heads/some-other-branch") still let a poisoned config.json pick an arbitrary local destination ref on fetch or push, past the existing guard. Extended both git_restore.branch and git_backup.branch validation to reject a colon too, with a test on each side proving the poisoned refspec no longer creates/overwrites a ref. Also (from the same review): added push-side injection tests mirroring the fetch-side ones, updated the external-storage-mode.md history-purge section to cover a previously-committed config.json (not just logs/tmp), and logged a non-blocking finding (a pre-existing silent mkdir failure that would silently skip the config.json exclusion) to trap.d/ rather than fixing it in this lane. Co-Authored-By: Max <noreply>
Second review pass (Explore + oss:auditor) over the prior follow-up commit found the two new colon-refspec regression tests each had one assertion that could pass for the wrong reason: - fetch-side test checked refs/remotes/origin/some-other-branch, a ref the attack never touches -- `git fetch -- origin "main:refs/heads/some-other-branch"` writes directly to refs/heads/some-other-branch locally. Fixed to check the ref the attack actually creates. - push-side test checked only that the poisoned ref never appeared on the remote, with no assertion that the fallback push itself still reached the remote -- an unrelated total push failure would make "the poisoned ref does not exist" trivially true. Added the same before/after _remote_head assertion its sibling tests already use. Co-Authored-By: Max <noreply>
PR #730's CI run found two real, unrelated guard failures introduced by this lane, caught only by CI: - The history-purge section heading in docs/external-storage-mode.md was renamed to "Logs (or a credential) in a backup you made before this version", tripping test_readme_reference_move_505.py's #505 interior-heading-continuity pin, which hardcodes the original heading text as part of verifying the #505 doc move landed intact. Reverted the heading itself; the body text already covers config.json without needing the heading to say so. - Three new test modules (test_git_backup_config_json_719.py, test_git_backup_remote_injection_723.py, test_git_restore_fetch_injection_723.py) carry a module-level win32 blanket skip but were never added to docs/windows-skip-triage.md, tripping test_windows_skip_triage_497.py. Added all three rows, verdict not-convertible, following the existing convention for their sibling git-backup/git-restore test modules. Co-Authored-By: Max <noreply>
fdaviddpt
added a commit
that referenced
this pull request
Sep 26, 2026
* fix(#748,#759): log silent config-layer/exclusion drops #748: when sanitizing the untrusted project config layer failed (mktemp, an unreadable project file, or jq/the no-jq Python fallback itself), the whole project layer was correctly dropped (fail closed) but nothing was logged anywhere -- a project's own settings (e.g. handoff_mode) vanished with no explanation. Both the jq path and the Python fallback now report the drop via report_error where it is in scope, falling back to a plain stderr line where it is not (lib-memory-dir.sh is sourced by log.sh before log.sh defines log/report_error). #759: a failed `mkdir -p "$BACKUP_COMMON_DIR/info"` had no else branch, so the config.json exclusion rule in git's info/exclude was silently never written on a read-only filesystem or permissions error, letting `git add -- "$SLUG/"` stage config.json (which can carry a live haiku.oauth_token) exactly as before the #719 fix, with the caller seeing an ordinary success line either way. The mkdir failure now reports a WARNING via report_error, matching every other failure path in this hook. #749 (composition of #730/#719's untrack commit with git-restore's fast-forward) is already fixed by #741 (changelog.d/741.fixed.md) -- 50-git-restore.sh already detects and restores a config.json a fast-forward removed from tracking, logging loudly on both success and failure. No code change needed; reported as already-shipped rather than reopened. Co-Authored-By: Claude Sonnet 5 <[email protected]> * test(#748): re-derive the sanctioned-divergence allowance the review found broken Self-review (Explore) found that the #748 fix to scripts/lib-memory-dir.sh broke tests/test_case_divergence_298.py::test_the_per_tool_call_path_is_not_touched -- its byte-parity guard against origin/main has no allowance for the new lines, so the test failed against real origin/main. Extends _SANCTIONED_DIVERGENCE's existing lib-memory-dir.sh entries in place rather than nesting new chained pairs inside them: composing directly on top of an already-landed pair (the #757 steady state) the same way, re-deriving each affected pair's old_code to be that steady state rather than the long-superseded #744/#726 forms it used to start from -- the same "fold, don't stack a third pair" precedent the file's own #757 comments already document for this exact site. A first attempt nesting new pairs inside the existing ones passed the real guard test but broke tests/test_sanctioned_divergence_state_440.py's own synthetic canary (a chained pair's old_code duplicating verbatim inside an earlier pair's own already-landed new_code, corrupting it under the synthetic test's naive concatenate-then-substitute construction); re-deriving in place instead passes both. Co-Authored-By: Claude Sonnet 5 <[email protected]> * chore(#748): log auditor's compound mktemp-failure finding to trap.d/ Non-blocking, ranked fails-to-preserve, "can ship behind a trap.d fragment" per the findings table -- see the fragment for the mechanism and what would settle it. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
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.
git-backup staged and pushed a slug's config.json (a documented home for haiku.oauth_token, a live claude.ai OAuth credential) alongside memory. This adds /$SLUG/config.json to the store's per-clone .git/info/exclude (same mechanism as the existing logs/ and tmp/ rules) and extends the existing legacy-untracking mechanism to untrack a config.json a store committed before this fix existed. History already pushed is left alone -- rotate the token if a config.json carrying one was ever committed.
Closes #719
git-restore's detached fetch and git-backup's push passed the remote/branch read from git-tracked config.json as leading positional args with no double-dash separator -- a dash-leading value could be parsed as a git option (for example an upload-pack option against a local-transport target, yielding local command execution). Both call sites now insert a double-dash separator before the operands and validate the remote/branch as plain names: a leading dash is rejected, and a colon or slash in the remote name is rejected; the branch value additionally rejects a colon, since a double-dash stops git's OPTION parsing but not its own src:dst REFSPEC grammar, and a colon-bearing branch value is a valid refspec that can still redirect the fetch/push to an attacker-chosen ref. An invalid remote falls back to the existing safe default (origin, or the branch's own push target); an invalid branch is cleared.
Closes #723
A non-blocking, pre-existing silent-mkdir-failure gap was logged to trap.d/719.silent-exclude-mkdir-failure.md rather than fixed in this lane, since the diff inherited rather than introduced it -- see the report for the full disposition. Self-review (two rounds, Explore + oss:auditor in parallel) also fixed a stale-docs gap (config.json missing from the history-purge remediation section), added missing push-side test coverage, fixed a colon-refspec bypass the first pass of the #723 fix missed, and fixed two vacuous-assertion bugs in the new colon-refspec tests.
Test plan
[AI-generated]