Skip to content

Pushing to a mirror row publishes blobs the origin withholds #294

In review

Description

@beardthelion

A repo mirrored from a peer is stored with is_public = true and no visibility rules, and sync never replicates the owner's rules. The replication gate on the push path reads that row's own (rules, is_public) pair, so for a mirror with no canonical twin it resolves to allow against an empty rule set and the publish list is built with nothing withheld.

Observed

Running the real publish-list builder twice over the same on-disk repo, changing only the row state:

row state announce objects includes the blob under /secret/
mirror row, as upsert_mirror_repo creates it true 6 yes
same disk and refs, with a /secret/** deny rule true 5 no

The withholding itself is correct: with a rule present the blob is excluded. The mirror row's empty rule set is what lets it through. The control matters here, since without it a permissive result proves nothing.

Why the row is hollow

Db::upsert_mirror_repo (crates/gitlawb-node/src/db/mod.rs) binds is_public to true and inserts no rules, and crates/gitlawb-node/src/sync.rs contains no visibility-rule writes at all. Rules attach per physical repo.id, and a mirror's id is the slash form {owner_short}/{name}, so list_visibility_rules returns empty for it. There is no shared rule set to fall back to.

How a mirror comes to hold withheld bytes

resolve_mirror_mode selects a plain full clone when the origin reports no withheld paths. A repo that is fully public when first mirrored is therefore cloned whole, and git does not prune already-fetched objects when the origin later adds a deny rule. Later fetches switch to promisor mode and change nothing about what is already in the object store. The steady state is a mirror holding now-withheld blobs with an empty local rule set and is_public = true, which is exactly the input the gate reads.

Reachability

GITLAWB_ENFORCE_OWNER_PUSH defaults to false, so any authenticated DID can push, and a valid did:key signature is self-asserted. get_repo prefers a canonical row over a mirror, so the exposure needs a mirror with no canonical twin on the node.

Why this is worse than a read leak

The consumer publishes rather than serves. The bytes go to content-addressed networks on the push path, so a CID any peer has fetched cannot be withdrawn. Fixing the gate afterwards does not undo the disclosure.

Where

The receive-pack tail in crates/gitlawb-node/src/api/repos.rs, where list_visibility_rules(&record.id) feeds replication_withheld_set and the listable_at_root(rules, is_public, owner_did, None) decision inside it. Present on main today, so this is not specific to any open branch.

Fix direction

A consumer that publishes cannot re-apply the withholding projection locally, because the rules were never replicated. So it has to either skip mirror rows (the slash-form id test already used elsewhere in the codebase) or resolve the row to a canonical twin and fail closed when none exists. Replicating the owner's visibility state on sync, or defaulting mirrors closed until rules are known, would fix the data-model half instead and close this at the source.

Activity

  1. added
    crate:node
    kind:bug
    sev:high
    subsystem:replication
    subsystem:storage
    subsystem:visibility
    on Jul 31, 2026
  2. added
    kind:security
    on Sep 5, 2026
  3. beardthelion commented on Nov 17, 2026

    @beardthelion
    CollaboratorAuthor

    The reachability section needs updating.

    GITLAWB_ENFORCE_OWNER_PUSH now defaults to true (config.rs), so an arbitrary signed DID can no longer push to a mirror row. The pusher has to match the row's owner. That lowers the exposure, since the person pushing is the origin's owner, but they are pushing to a node where the origin's rules never arrived, so the publish list is still built with nothing withheld.

    The gap itself is unchanged. upsert_mirror_repo still binds is_public to true and writes no visibility rules, and sync still never copies the origin's rules. The only quarantine on the mirror path is the iCaptcha propagation gate, which does not look at withheld paths.

    I have not re-run the publish-list comparison from the issue body against this commit, and I have not checked what owner value a mirror row carries compared with the DID the push gate matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate:nodekind:bugkind:securitysev:highsubsystem:replicationsubsystem:storagesubsystem:visibility

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions