git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 14/16] promisor-remote: trust known remotes matching acceptFromServerUrl

From
Christian Couder <christian.couder@gmail.com>
Date
Apr 27, 2026, 12:45 UTC
Message-ID
<CAP8UFD1dvys9nEF6tRudWaeHmmEFH0NGPqK5YM_mk5RQa2=ujw@mail.gmail.com>
In-Reply-To
<acUk0vTuj8COlvgf@pks.im>
On Thu, Mar 26, 2026 at 1:21 PM Patrick Steinhardt <ps@pks.im> wrote:
>
> On Mon, Mar 23, 2026 at 09:05:17AM +0100, Christian Couder wrote:
Show 38 quoted lines
> > To enable such targeted updates for trusted URLs, let's use the URL
> > patterns from `promisor.acceptFromServerUrl` as an additional URL
> > based whitelist.
> >
> > Concretely, let's check the advertised URLs against the URL glob
> > patterns by introducing a new small helper function called
> > url_matches_accept_list(), which iterates over the glob patterns and
> > returns the first matching allowed_url entry (or NULL).
> >
> > (Before matching, the advertised URL is passed through url_normalize()
> > so that case variations in the scheme/host, percent-encoding tricks,
> > and ".." path segments cannot bypass the whitelist.)
> >
> > Let's then use this helper at the tail of should_accept_remote() so
> > that, when `accept == ACCEPT_NONE`, a known remote whose URL matches
> > the whitelist is still accepted.
> >
> > To prepare for this new logic, let's also:
> >
> >  - Add an 'accept_urls' parameter to should_accept_remote().
> >
> >  - Replace the BUG() guard in the ACCEPT_KNOWN_URL case with an
> >    explicit 'if (accept == ACCEPT_KNOWN_URL) return' and a new
> >    BUG() guard in the ACCEPT_NONE case, so url_matches_accept_list()
> >    is only called in the ACCEPT_NONE case.
> >
> >  - Call accept_from_server_url() from filter_promisor_remote()
> >    and relax its early return so that the function is entered when
> >    `accept_urls` has entries even if `accept == ACCEPT_NONE`.
> >
> > Let's then properly document `promisor.acceptFromServerUrl` in
> > "promisor.adoc" as an additive security whitelist for known remotes,
> > including the URL normalization behavior, and let's mention it in
> > "gitprotocol-v2.adoc".
>
> I feel like the description is steering a bit too strongly into the
> direction of a step-by-step instruction of how to implement the change
> rather than explaining what's done and why it's done this way.
I have added the following:
"With this, many organizations may only need something like:
  git config set --global \
          promisor.acceptFromServerUrl "https://my-org.com/*"

to accept only their own remotes. And if they need to accept additional remotes in some specific repos, they can also set:

  git config set promisor.acceptFromServer knownUrl

and configure the additional remote manually only in the repos where they are needed."

Show 48 quoted lines
> > +promisor.acceptFromServerUrl::
> > +     A glob pattern to specify which URLs advertised by a server
> > +     are considered trusted by the client. This option acts as an
> > +     additive security whitelist that works in conjunction with
> > +     `promisor.acceptFromServer`.
> > ++
> > +This option can appear multiple times in config files. An advertised
> > +URL will be accepted if it matches _ANY_ glob pattern specified by
> > +this option in _ANY_ config file read by Git.
> > ++
> > +Be _VERY_ careful with these glob patterns, as it can be a big
> > +security hole to allow any advertised remote to be auto-configured!
> > +To minimize security risks, follow these guidelines:
> > ++
> > +1. Start with a secure protocol scheme, like `https://` or `ssh://`.
> > ++
> > +2. Only allow domain names or paths where you control and trust _ALL_
> > +   the content. Be especially careful with shared hosting platforms
> > +   like `github.com` or `gitlab.com`. A broad pattern like
> > +   `https://gitlab.com/*` is dangerous because it trusts every
> > +   repository on the entire platform. Always restrict such patterns to
> > +   your specific organization or namespace (e.g.,
> > +   `https://gitlab.com/your-org/*`).
> > ++
> > +3. Don't use globs (`*`) in the domain name. For example
> > +   `https://cdn.example.com/*` is much safer than
> > +   `https://*.example.com/*`, because the latter matches
> > +   `https://evil-hacker.net/fake.example.com/repo`.
> > ++
> > +4. Make sure to have a `/` at the end of the domain name (or the end
> > +   of specific directories). For example `https://cdn.example.com/*`
> > +   is much safer than `https://cdn.example.com*`, because the latter
> > +   matches `https://cdn.example.com.hacker.net/repo`.
> > ++
> > +Before matching, the advertised URL is normalized: the scheme and
> > +host are lowercased, percent-encoded characters are decoded where
> > +possible, and path segments like `..` are resolved.  Glob patterns
> > +are matched against this normalized URL as-is, so patterns should
> > +be written in normalized form (e.g., lowercase scheme and host).
> > ++
> > +Even if `promisor.acceptFromServer` is set to `None` (the default),
> > +Git will still accept field updates (like tokens) for known remotes,
> > +provided their URLs match a pattern in
> > +`promisor.acceptFromServerUrl`. See linkgit:gitprotocol-v2[5] for
> > +details on the protocol.
>
> Given that there's a bunch to process here, would it make sense to give
> users an example for how to do it properly?

I can give an example like the one I added to the commit message (see above), but it might be too lax for some use cases. Perhaps in many organizations only a single repo will ever require to accept promisor remotes, so giving an example with the `--global` flag like:

  git config set --global promisor.acceptFromServerUrl "https://my-org.com/*"
could make everyone's config a bit more vulnerable than necessary.

I think it's better to nudge people to think through the four steps above, rather than to encourage them to copy-paste something that might not be very well suited to their needs.

> I also wonder why we require a new config entry instead of extending
> `promisor.acceptFromRemote` to have for example a new "url:https://..."
> setting. Are there cases where you would ever want to use the new
> URL-based schema with a different setting than "all"?
Yes, I think the example in the commit message shows why having both:
- `promisor.acceptFromRemote` that you can set for example to
"knownUrl" only in some specific repos where you accept external
promisor remotes that you configure manually, and
- `promisor.acceptFromRemoteUrl` that you can set for example to
"https://my-org.com/*" globally
can be relatively simple and quite powerful:
- all internal remotes (with URLs in https://my-org.com/) are
automatically accepted in all the repos,
- in certain specific repos, some external remotes (with names and
URLs that are manually configured in the repos) are also accepted.
Show 6 quoted lines
> I guess the case with "none" is exactly that, where you may auto-update
> configured remotes. But I wonder whether it would be more sensible to
> split out behaviour of accepting and updating promisors into separate
> configuration variables. These are ultimately different concerns, and
> the interaction as layed out in this commit is somewhat non-obvious to
> me.

Let me know if there are things I could clarify more in the above explanations. I am also open to concrete suggestions.

Thanks.
Previous: Patrick SteinhardtNext: Christian Couder
Message 41 of 47 in “Auto-configure advertised remotes via URL whitelist”
  1. 00/16 Auto-configure advertised remotes via URL whitelistChristian Couder, Mar 23, 2026
  2. 01/16 promisor-remote: try accepted remotes before others in get_direct()Christian Couder, Mar 23, 2026
  3. Patrick SteinhardtMar 26, 2026
  4. Christian CouderApr 2, 2026
  5. 02/16 urlmatch: change 'allow_globs' arg to boolChristian Couder, Mar 23, 2026
  6. 03/16 urlmatch: add url_is_valid_pattern() helperChristian Couder, Mar 23, 2026
  7. Patrick SteinhardtMar 26, 2026
  8. Christian CouderApr 27, 2026
  9. 04/16 promisor-remote: clarify that a remote is ignoredChristian Couder, Mar 23, 2026
  10. Patrick SteinhardtMar 26, 2026
  11. Christian CouderApr 2, 2026
  12. 05/16 promisor-remote: refactor has_control_char()Christian Couder, Mar 23, 2026
  13. 06/16 promisor-remote: refactor accept_from_server()Christian Couder, Mar 23, 2026
  14. 07/16 promisor-remote: keep accepted promisor_info structs aliveChristian Couder, Mar 23, 2026
  15. Patrick SteinhardtMar 26, 2026
  16. 08/16 promisor-remote: remove the 'accepted' strvecChristian Couder, Mar 23, 2026
  17. Patrick SteinhardtMar 26, 2026
  18. Christian CouderApr 2, 2026
  19. 09/16 promisor-remote: add 'local_name' to 'struct promisor_info'Christian Couder, Mar 23, 2026
  20. Patrick SteinhardtMar 26, 2026
  21. Christian CouderApr 27, 2026
  22. 10/16 promisor-remote: pass config entry to all_fields_match() directlyChristian Couder, Mar 23, 2026
  23. Patrick SteinhardtMar 26, 2026
  24. Christian CouderApr 2, 2026
  25. 12/16 t5710: use proper file:// URIs for absolute pathsChristian Couder, Mar 23, 2026
  26. Patrick SteinhardtMar 26, 2026
  27. Christian CouderApr 2, 2026
  28. 13/16 promisor-remote: introduce promisor.acceptFromServerUrlChristian Couder, Mar 23, 2026
  29. Patrick SteinhardtMar 26, 2026
  30. Christian CouderApr 27, 2026
  31. 11/16 promisor-remote: refactor should_accept_remote() control flowChristian Couder, Mar 23, 2026
  32. Patrick SteinhardtMar 26, 2026
  33. Christian CouderApr 2, 2026
  34. 14/16 promisor-remote: trust known remotes matching acceptFromServerUrlChristian Couder, Mar 23, 2026
  35. Junio C HamanoMar 23, 2026
  36. Junio C HamanoMar 23, 2026
  37. Christian CouderMar 27, 2026
  38. Junio C HamanoMar 31, 2026
  39. Christian CouderApr 1, 2026
  40. Patrick SteinhardtMar 26, 2026
  41. Christian CouderApr 27, 2026
  42. 16/16 doc: promisor: improve acceptFromServer entryChristian Couder, Mar 23, 2026
  43. 15/16 promisor-remote: auto-configure unknown remotesChristian Couder, Mar 23, 2026
  44. Patrick SteinhardtMar 26, 2026
  45. Christian CouderApr 27, 2026
  46. Patrick SteinhardtMar 26, 2026
  47. Christian CouderApr 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.