-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: mod meta tag causes infinite loop in GOPROXY #31458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This seems like an implementation detail of the module server. The protocol for a server and a proxy is the same, but a server that is not a proxy fundamentally needs to know which paths it's serving. (Note that one option is for the server to run For the |
This is indeed an implementation detail of the module server. The |
@hyangah In this case it should be 100% safe to say that the only way a proxy server knows how to For example, if a user did:
And then my marwan.io server returned something like ~ Then my The only other way around my solution above, is that the proxy server has a way for that vanity import path to be populated outside of If all of my assumptions are correct, I'm happy closing the issue :) Thanks! |
@marwan-at-work a different approach to protect the public proxy from the infinite loop is to design the myproxy.com to avoid duplicate work. The subsequent request in the chain will then be classified as duplicate of pending operation, and not add additional work to the proxy but wait for the pending duplicate work to complete. Eventually some of the request in the chain will timeout (as most production service would do) and the chain will terminate. |
@hyangah I'm more focused on how it should work as opposed to the security vulnerability side of it. From a vulnerability stand point, your suggestion makes sense. Another one is that the proxy server can also issue its own However, from a feature perspective, I wasn't clear on how But I'd love a confirmation that the Thanks again :) |
@marwan-at-work One of the use cases where the For example, the module I agree that it becomes problematic if the |
Note that |
looks like the answer is clear: the proxy implementation should not invoke |
I'm stumped about how the
<meta content="<path> mod <url>"
tag would ever work.Let's say a user does a
go get marwan.io/moddoc
wheremarwan.io
is a vanity import server (which it is right now).Let's say,
marwan.io
wants to expose its modules via a GOPROXY and not viagit
Therefore, the meta tag that it returns will now be
<meta name="go-import" content="marwan.io/moddoc mod https://someproxy.com">
instead of
<meta name="go-import" content="marwan.io/moddoc git https://github.com/marwan-at-work/moddoc">
The
go
command will now start talking tohttps://someproxy.com
through the Download Protocol. And the first thing it will do is:The proxy, will now use
go list -m -versions -json marwan.io/moddoc@latest
to get the versions list (or even latest)The
go
command inside the GOPROXY will now actually pingmarwan.io/moddoc?go-get=1
one more time, and it will parse the meta tag again and then it will ping the samehttps://someproxy.com
that it is currently running on causing an infinite loop.Even if we hard code the
/list
and@latest
responses to the GOPROXY server to avoid the infinite loop, when the originalgo
command now requests a version say:GET https://someproxy.com/marwan.io/moddoc/@v/v1.2.3.zip
, the GOPROXY must usego mod download
to get the module contents which will also cause infinite loop.The only solution so far is to use
go mod download marwan.io/moddoc
before we deploy the change to the meta tag, then manually upload it to the GOPROXY server storage. But once we deploy the change, we'll never be able to upload the correct zip file of any new versions because those will cause infinite loops. We'll have to revert the meta tag response to begit
again, dogo mod download
locally, and redeploy the meta-tag change along with the new zip file (and friends) in storage.Even if the purpose of the "mod meta tag" is not for vanity imports to expose them, I fail to realize where they ever make sense. The vgo proposal mentions here that you can use this feature for directly injecting the storage url: https://research.swtch.com/vgo-module#publishing
But I still fail to see how this is maintainable for a couple of reasons:
@latest
is not compatible with thestorage.googleapis.com
go mod download
against the underlying git repository and upload it to storage on every new version or every new commit so thatgo
will never hit@latest
cc: @bcmills @rsc
The text was updated successfully, but these errors were encountered: