Repository navigation
Conversation
The node's cache repository can hold an object that no registered pack holds (a cache that was copied or edited out of band, or a registry that was rolled back). git reads such an object, so three entry points stored a ref at it: POST branches/create and POST tags resolved the base or the target in the cache, and a push update with an empty pack passed git's connectivity check. Every other node hydrates from the registered packs alone, so each such ref wedged the repository. The two REST routes now answer 404 for a commit that no registered pack holds, and the update hook refuses the update, both by object state against a view of the cache that links only the packs that the registry lists. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: Ia072c3e1bd28cbd9b2a4441250dae1d810a2d150
…arget check Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I89f3a475d656e81fd175b9b8f2c4c980c2409bfd
Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I868869117ec8447c2206cf6ffea5cfc051631500
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c8007fd81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if new != ref.ZeroSHA { | ||
| if err := unregisteredTargetCheck(ctx, st, repo, refName, new); err != nil { | ||
| return err |
There was a problem hiding this comment.
Reject unregistered targets before atomic update hooks
For a multi-ref --atomic push where an earlier command targets a registered object and a later command targets a cache-only object, the earlier update hook commits its authority CAS before this later per-ref check rejects. Git then aborts the local atomic ref transaction and reports the entire push as failed, while the earlier authority update remains committed. The registered-target check needs a whole-push pre-receive gate for atomic pushes, before any update hook can run.
Useful? React with 👍 / 👎.
| kinds, err := ParseObjectKinds([]string{new}, out.String()) | ||
| if err != nil { | ||
| return fmt.Errorf("update: %w", err) | ||
| } | ||
| if kinds[new] == "missing" { | ||
| return refusef("update: %s is at %s, which no pack of this repository's registry holds", refName, new) |
There was a problem hiding this comment.
Validate the registered object closure, not only the tip
When a crafted incoming pack contains the new commit or tag object but omits a referenced tree, parent, or tag target that exists only in this node's cache, receive-pack's connectivity check succeeds and the pack is registered. Since kinds[new] is then non-missing, this check accepts the ref even though a fresh node hydrating only registered packs cannot traverse it. Validate connectivity using the registered-pack-only view rather than checking only the direct object's type.
Useful? React with 👍 / 👎.
| if heal == nil || attempt > 0 { | ||
| return nil, fmt.Errorf("%w: the cache of %s lacks the registered pack %s", ErrPackMissing, repo, missing) | ||
| } | ||
| if err := heal(ctx); err != nil { | ||
| return nil, fmt.Errorf("fetch the registered packs of %s: %w", repo, err) | ||
| } |
There was a problem hiding this comment.
Retry healing when the refreshed listing adds packs
On a fleet node whose cache is missing a listed pack, heal can download the snapshot returned by its own ListPacks while another node concurrently registers another pack. The subsequent outer listing then sees that new healthy pack missing locally, but attempt > 0 returns ErrPackMissing instead of healing again, so an otherwise valid branch/tag creation or push is transiently rejected during normal concurrent writes. Retry this list-and-heal cycle with a bounded race budget, as HydratePacks does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 3c8007fd81
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| if new != ref.ZeroSHA { | ||
| if err := unregisteredTargetCheck(ctx, st, repo, refName, new); err != nil { | ||
| return err | ||
| } |
There was a problem hiding this comment.
🛡️ Codex Security Review
Security: Batch registered-target checks across push refs
With a git:write token and default-off rate limiting, an attacker can send one allowed no-pack push containing very many refs at an already registered commit. Git runs update once per ref, and this new call rebuilds a registered-pack view, calls ListPacks, creates two symlinks per pack, and launches git cat-file each time. The repository has no command-count cap, and receive-pack has no work slot or server deadline, so an N-ref push buys N backend reads, temp views, and Git children. Concurrent pushes can exhaust a node or shared store. Batch the SHAs in pre-receive or impose a strict command/work budget.
Useful? React with 👍 / 👎.
Why
The node's cache repository can hold an object that no registered pack holds: a cache that was copied or edited out of band, or a registry that was rolled back. git reads such an object without complaint. Every other node, and this node after it loses its cache, hydrates from the registered packs alone and cannot write a ref at that object (
update-ref ... trying to write ref ... with nonexistent object), so a ref at it wedges the repository: reads, clones and later writes answer500.A write-path audit of main found no product path that puts such an object into the cache (every writer registers its pack before the ref move), but three entry points trust the cache and not the registry, so one drifted cache is enough to store the wedging ref. I reproduced each on a live node and in tests by planting a loose commit in the cache directory:
POST /repos/branches/createresolvesbase_refandpreferred_basein the cache, and moves the ref without publishing a pack.POST /repos/tagsdoes the same forref.What changed
githttp.RegisteredPackViewis a temporary object directory that links exactly the pack files that the registry lists (ListPacks) from the cache. A git child withGIT_OBJECT_DIRECTORYset to it, and no alternates, reads an object only when a registered pack holds it. A registered pack that the cache lacks (a fold replaced the packs since the cache was hydrated) is downloaded first. With no way to download it, the view refuses withErrPackMissingand never reads "missing" for an object that a pack holds.gitread.RegisteredKindsasks the view for the type of each id.POST /repos/branches/create(base_ref,base_branch,preferred_base) andPOST /repos/tagsaccept the commit only when a registered pack holds it. A commit that only the cache holds answers404like one that does not exist, and a base that names no usable commit still falls back topreferred_base.docs/reference/http-api.mdsays so.denyUnregisteredTarget), before the compare-and-swap, per ref, like a policy denial:update: <ref> is at <sha>, which no pack of this repository's registry holds. A push that carries its objects is unaffected, because pre-receive registers its pack before this hook runs and git has moved the pack into the cache. A delete has no new value and is not checked.TestRefWritesRefuseACommitThatOnlyTheCacheHolds(5 request shapes, pg and sqlite: 404, no ref written, a fresh node still hydrates, and the same request at a registered commit still answers 200) andTestUpdateHookRefusesATargetThatNoRegisteredPackHolds(branch, tag and notes, with an empty pack, plus a registered commit) fail onmain.TestRegisteredKindsReadsTheRegisteredPacksOnlycovers the view, including a cache that lost its pack files.updateHookis a covered function. The model does not describe the check. The S3-WAL push census budget for a steady push goes from 21 to 22 round trips: the check lists the registered packs once, one manifest read (I could not run that lane here: it needs docker, so CI confirms the exact count).Limits
Verification
mainand pass here. The fullinternal/apirace lane (sqlite subtests, 332 s) and the fullinternal/githttprace lane (local backend) pass, with the two hook tests fixed through the seam.gofmt, golangci-lint 2.15.0 (0 issues), the gitlimit lease audit, the darwin test build, the doc-link gate and both fingerprint gates pass. The PostgreSQL and S3-WAL lanes run in CI.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh