Skip to content

uv audit: pylock.toml support - #21601

Draft
woodruffw wants to merge 6 commits into
mainfrom
ww/audit-pylock
Draft

woodruffw wants to merge 6 commits into
mainfrom
ww/audit-pylock

Conversation

@woodruffw

@woodruffw woodruffw commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

WIP, not ready for review yet.

This adds uv audit -r pylock.toml support. I've elected for the same CLI design as uv pip install, i.e. an explicit -r option rather than a positional.

Note: I intentionally didn't include requirements file support in here, to make the diff (especially the tests) smaller. But adding it would be very easy in a follow-up.

Closes #18422. See #18506.

Test Plan

Added new integration tests.

@woodruffw woodruffw self-assigned this Sep 10, 2026
@woodruffw woodruffw added enhancement New feature or improvement to existing functionality preview Experimental behavior area:uv-audit Related to uv audit functionality labels Sep 10, 2026
Comment thread docs/concepts/projects/layout.md Outdated
Comment thread crates/uv/src/commands/project/audit.rs Outdated
@astral-sh-bot

astral-sh-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 6
  • Removed tests: 0
  • Changed suites: 1
uv::build: +6 / -0

Added:

  • uv::build::audit::audit_pylock_conflicts
  • uv::build::audit::audit_pylock_empty
  • uv::build::audit::audit_pylock_invalid_inputs
  • uv::build::audit::audit_pylock_project_status
  • uv::build::audit::audit_pylock_vulnerability
  • uv::build::audit::audit_pylock_whole_lock

Removed: none

Comment thread crates/uv/src/settings.rs Outdated
)?;
}
if !settings.upgrade.is_none() {
bail!("Package upgrades cannot be requested with `--requirements`");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message seems wrong for AuditSettings?

Comment on lines +371 to +375
if let Some(index) = package.index.as_ref() {
projects.insert((
package.name.clone(),
IndexUrl::from(VerbatimUrl::from_url(index.clone())),
));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Reject remote file indexes before Windows treats them as UNC paths

An on-path attacker who alters an explicitly selected plain-HTTP pylock can set package.index to a hosted file: URL. These lines now promote that untrusted URL into the project-status worklist; IndexUrl classifies every file: URL as a path, and the registry client ultimately calls read_to_string after Url::to_file_path. On Windows, file://attacker/share becomes a UNC path, so the audit can initiate SMB/NTLM authentication to the attacker-controlled host and expose a relayable or crackable challenge response for the invoking developer or CI identity. HTTPS, --no-index, and outbound-SMB policy mitigate the path, but this code should reject hosted file indexes.

Suggested change
if let Some(index) = package.index.as_ref() {
projects.insert((
package.name.clone(),
IndexUrl::from(VerbatimUrl::from_url(index.clone())),
));
if let Some(index) = package.index.as_ref()
&& (index.scheme() != "file"
|| index
.host_str()
.is_none_or(|host| host.eq_ignore_ascii_case("localhost")))
{
projects.insert((
package.name.clone(),
IndexUrl::from(VerbatimUrl::from_url(index.clone())),
));

woodruffw and others added 6 commits September 16, 2026 17:00
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
if let Some(index) = package.index.as_ref() {
projects.insert((
package.name.clone(),
IndexUrl::from(VerbatimUrl::from_url(index.clone())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Bind pylock project-status lookups to trusted indexes

When uv audit --requirements reads a pylock over plain HTTP, an on-path attacker can replace the response and choose packages[].index; project-status querying then issues a GET to that HTTP(S) origin, allowing blind requests to otherwise inaccessible loopback or private services from a developer or CI network. Authenticated HTTPS and --no-index prevent this path, but the default plain-HTTP flow does not bind embedded indexes or redirects to operator-authorized destinations.

@woodruffw

Copy link
Copy Markdown
Member Author

NB I'm deferring this while I think about a cross-cutting approach to tracking the provenance of remote -r inputs.

This branch was successfully deployed

1 active deployment
automations — 65bbd3f5 Deployed Sep 16, 2026 by woodruffw via review / report #46963
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:uv-audit Related to uv audit functionality enhancement New feature or improvement to existing functionality preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support passing pylock.toml files into uv audit

1 participant