Skip to content

uv add leaks credentials to tool.uv.index when UV_DEFAULT_INDEX is set #8483

@kwaegel

Description

@kwaegel

I have a project that uses a private JFrog Artifactory repository to host internal packages, and as a proxy for PyPi. I just noticed that calling uv add internal_package==specific_version when overriding with UV_DEFAULT_INDEX will leak credentials into the pyproject.toml file, even if the lockfile isn't modified.

Original index entry (company name redacted):

# Set JFrog Artifactory as the default index.
[[tool.uv.index]]
name = "internal"
url = "https://repos.internal.com/artifactory/api/pypi/internal-pypi/simple"
default = true

Command (a no-op, since the package version already exists as a dependency):

$uv add internal_package==version
Resolved M packages in 2ms
Audited N packages in 0.87ms

After running that command, the tool.uv.index section has removed the name = internal line, inserted the full repo URL, including authentication tokens, and removed the comments:

[[tool.uv.index]]
url = "https://USERNAME:[email protected]/artifactory/api/pypi/internal-pypi/simple"
default = true

Summary:

  • I was not expecting credentials to get saved to pyproject.toml
  • I was not expecting that setting UV_DEFAULT_INDEX before running uv add would modify pyproject.toml at all (including removing comments).

uv version 0.4.25

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions