-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
uv suffers dependency confusion if user forgets to put username:password on internal index url #9429
Comments
Thanks. I'm not certain what we should change here if anything. Are you for I don't know if there's actually anything we can do about erroring if we fail to connect to your index, because indexes in general are so bad and so inconsistent in how they handle these cases. Some indexes return 403 when you provide valid credentials but request a non-existent package; some indexes return 404 when you provide invalid credentials. No matter what we do, we'll break something. We do show a dedicated hint if we fail to resolve and see (e.g.) a 403. I guess we could consider showing that warning even if the installation completes. |
We should probably at least warn when we fail to connect to an index. We may want to special-case the indexes that we know return 403 consistently. |
A warning would be helpful. Something in the docs to warn users would also be helpful. Speaking of the docs, I really hate putting credentials in the package index URL. I would much rather put them in environment variables. I saw the docs for UV_INDEX_{name}_PASSWORD and was wondering how on earth to set the name of an index given on the command line, given that configuring the index in a pyproject.toml file wasn't going to work for me. So I searched the source code (Thanks for writing |
I documented it here recently: https://docs.astral.sh/uv/configuration/indexes/#defining-an-index. Take a look at "When providing an index on the command line..." |
Thank you. The docs are good, I don't know why I missed that. :) |
What happens when a user configures
Should the variables |
Answering this previous question from @charliermarsh :
In my case I wanted |
I accidentally triggered a dependency confusion vulnerability in uv just by forgetting to add credentials to our company's internal package index URL.
Steps to reproduce:
example-component
(seriously, this is what I named it, I was testing!)Expected result:
Either
example-component
is installed from my internal Python package index, or else I get some kind of error message if something was wrong with the package index URL.Actual result:
As you can see from the command output above,
uv
silently and happily ignored my internal package index URL, gave no warning, and installs example-component from pypi! The only reason I knew something was wrong is thatuv pip list
reported an unexpected version number.Something was very wrong with my internal package index URL: It was missing the required credentials. So
uv
just silently ignored the error and went on to the default index URL, causing dependency confusion.(Fortunately the example-component from pypi.org does not seem to be any kind of malware.)
It seems from the uv docs about Packages that exist on multiple indexes that uv prides itself on being better than pip at avoiding dependency confusion. So I thought you would want to hear about this case where uv is easily vulnerable to it.
Operating system: Ubuntu 24.04
The text was updated successfully, but these errors were encountered: