Skip to content

Sync worker peer DNS pin is ignored on libcurl older than 7.59 #639

Backlog

Description

@beardthelion

The sync worker pins a hostname peer's validated addresses with http.curloptResolve, but on older libcurl the entry it writes is rejected and git resolves the peer's hostname again at connect time. That reopens the DNS rebinding window the pin exists to close. #619 is the same defect in the upstream mirror and is fixed by #638; this is the sync path, which builds its own pin.

Where

resolve_pin in crates/twigpine-node/src/sync.rs returns one entry: every validated address comma-joined, each IPv6 address in brackets. For example:

  • two IPv4 answers: peer.example:443:198.51.100.9,203.0.113.7
  • IPv6 only: peer.example:443:[2001:db8::1],[2001:db8::2]
  • one IPv6 answer: peer.example:443:[2001:db8::1]

peer_git_config sets that one entry at the generic and URL-scoped keys, and persist_peer_git_config writes the same string into the mirror's repo config with --replace-all, where later lazy fetches read it.

libcurl before 7.59 rejects a comma-separated address list, and libcurl before 7.57 rejects a bracketed IPv6 address. In both cases it logs found illegal!, drops the entry, and resolves the host through DNS. The only version floor on this path is Git 2.37 (MIN_CURL_OPT_RESOLVE_GIT), which says nothing about the linked libcurl: Ubuntu 18.04 with the git-core PPA ships git 2.50.1 on libcurl 7.58.

Reachability

require_signed_peer_writes defaults to false, so /api/v1/peers/announce and /api/v1/sync/notify accept unsigned requests (per-IP rate limit only). Anyone can register a hostname peer and trigger a fetch. If that hostname has two or more public A records, or only AAAA records, the fetch runs unpinned on an affected host, and the peer's DNS can answer the connect-time lookup with an internal address after the worker validated a public one.

Evidence

Run against the exact config peer_git_config produces (generic and scoped reset, then the pin at both keys, through GIT_CONFIG_*), and separately with the pin in a bare repo's config as persist_peer_git_config writes it. peer.invalid has no DNS answer, so Could not resolve host means the pin was dropped.

Pin git 2.50.1, libcurl 7.58.0 (Ubuntu 18.04) git 2.43.0, libcurl 7.29.0 (CentOS 7)
peer.invalid:9:127.0.0.2 pinned pinned
peer.invalid:9:127.0.0.2,127.0.0.3 found illegal!, then Could not resolve host same
peer.invalid:9:[::2],[::3] found illegal!, then Could not resolve host same
peer.invalid:9:[::2] pinned found illegal!, then Could not resolve host

The env-config and repo-config runs gave the same result in every row. On libcurl 7.61.1 (Rocky Linux 8) the same strings are honored.

Each row is one fetch of this shape:

GIT_CONFIG_COUNT=4 \
GIT_CONFIG_KEY_0=http.curloptResolve GIT_CONFIG_VALUE_0= \
GIT_CONFIG_KEY_1=http.http://peer.invalid:9/owner/repo.curloptResolve GIT_CONFIG_VALUE_1= \
GIT_CONFIG_KEY_2=http.curloptResolve GIT_CONFIG_VALUE_2='peer.invalid:9:127.0.0.2,127.0.0.3' \
GIT_CONFIG_KEY_3=http.http://peer.invalid:9/owner/repo.curloptResolve GIT_CONFIG_VALUE_3='peer.invalid:9:127.0.0.2,127.0.0.3' \
GIT_CURL_VERBOSE=1 git ls-remote http://peer.invalid:9/owner/repo 2>&1 | grep -E 'illegal|resolve host|Trying'

Fix direction

Build the sync pins with the same entries #638 uses for the mirror (full list, the lowest address unbracketed, full list again), ideally from one shared builder so the two paths cannot drift again. The persisted config then has to carry every entry: NetworkGit::pin() currently returns only the first curloptResolve value and persist_peer_git_config writes a single value with --replace-all, so porting the builder alone would persist one entry. The three-entry format was checked on libcurl 7.29, 7.59 and 7.61.1 for #638; the persistence change has not been written or tested.

A real-git test that fetches pin.invalid through the generated pins (as #638 adds for the mirror) would catch the pins being ignored on CI's libcurl. It cannot catch the old-libcurl cases above, since CI runs one modern libcurl.

Activity

  1. added
    sev:medium
    kind:security
    crate:node
    subsystem:replication
    on Nov 28, 2026
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:securitysev:mediumsubsystem:replication

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions