From: Christian Couder Date: Sun, 12 Jul 2026 09:06:47 GMT Subject: Re: [PATCH 0/3] Introduce a 'fromAccepted' option to GIT_NO_LAZY_FETCH Message-ID: In-Reply-To: On Fri, Jul 10, 2026 at 9:50 PM brian m. carlson wrote: > > On 2026-07-10 at 08:51:34, Christian Couder wrote: > > Since 7b70e9efb1 (upload-pack: disable lazy-fetching by default, > > 2024-04-16), lazy fetching has been controlled by the > > `GIT_NO_LAZY_FETCH` environment variable. This is currently an "all or > > nothing" boolean that is set to 'true' by default when calling `git > > upload-pack` for security reasons. > > > > Recently the "promisor-remote" capability was added to protocol v2, > > allowing servers and clients to agree on the promisor remotes they > > can safely use. > > > > This series leverages that capability to implement a pragmatic middle > > ground. By setting `GIT_NO_LAZY_FETCH` to 'fromAccepted', lazy > > fetching is allowed only when fetching from promisor remotes that are > > both advertised by the server and accepted by the client. > > > > Note that using an environment variable for this is probably not the > > best from a usability perspective. An `upload-pack.allowLazyFetch` > > configuration variable would likely be better. > > > > Unfortunately the `GIT_NO_LAZY_FETCH` environment variable is the way > > things currently work. It would be a much bigger and more invasive > > change to implement `upload-pack.allowLazyFetch` in a way that is > > compatible with `GIT_NO_LAZY_FETCH` which has to stay anyway for > > backward compatibility. Therefore, transitioning to a configuration > > variable is left for future work. > > I don't think this is a good idea. We get a lot of reports on the > security list involving various tooling that isn't within the scope of > our threat model. This substantially increases the amount of code which > is now subject to that threat model and therefore our security > guarantees and I don't think we should do that as it stands, very > especially while so much of our network-facing code is written in C. This small series doesn't change any defaults, especially GIT_NO_LAZY_FETCH is still set to 1 when calling `git upload-pack` by default. And the new option is more restrictive than the GIT_NO_LAZY_FETCH=0 option which already exists. So I don't think it's fair to say that this _substantially increases_ the amount of code subject to some threat model. I agree that client acceptance of some promisor remotes doesn't make the served repo trusted. It's a real concern, but I think it's addressable by different mechanisms. See below. > The fetch code by default reads lots of configuration information from > the repository, including remote settings and information and we really > want absolutely none of that code running in the context of an untrusted > repository. When a promisor remote has been accepted, it means both the client and the server trust it, so at least the promisor remote is not untrusted. Now the main security issue on the server side is making sure the served repo itself is also trusted. And I agree that the operator of the server should decide and mark that trust, not the client. I also agree that on GitLab/GitHub-style multi-tenant hosts most repositories shouldn't be marked as trusted. However note that: - The operator of the server is the only actor which can set GIT_NO_LAZY_FETCH on the server (where it matters). - In the case of corporate/self-hosted repos, the operator also controls the repos. - Different features could be developed (in future work) to improve on the current state: - a way for lazy fetching to work without reading config files, triggering hooks, or doing potentially sensitive things, - an explicit way for operators to mark trusted repos (like perhaps a server-side config the operator sets per-repo), - operator-defined allow/deny rules, or maybe - some ways/scripts/commands to scan repos and check configuration information, remote settings and everything potentially sensitive to decide if a repo looks safe enough to allow lazy fetching or not. I would be happy to hear opinions about those potential features or any other ways to address the issue. So I agree that this series doesn't fix all the problems on the server side, but I think it's still valuable to be able to restrict lazy fetching to accepted promisor remotes. Also I definitely agree that the current series should have better documentation about this, and I plan to improve on that in the v2 of this series. Thanks for your insightful comments.