Repository navigation
Conversation
| &requirement.extras, | ||
| &groups, | ||
| &settings.build_options, | ||
| Some(HashCheckingMode::Verify), |
There was a problem hiding this comment.
[P2] Require hashes in packaged tool locks
HashCheckingMode::Verify only checks digests that exist, while the PEP 751 parser still accepts hashes = {} with a warning. Consequently an opt-in --locked install, run, or upgrade can consume a packaged lock with no digest for the selected dependency, allowing a dependency publisher or mutable origin to replace that artifact after the tool wheel was published and have the new code installed with developer or CI privileges. Require hashes here so missing digests fail; this one-line change plus an empty-hash regression test passed all five focused packaged-lock tests.
| Some(HashCheckingMode::Verify), | |
| Some(HashCheckingMode::Require), |
05a6998 to
374fd4e
Compare
3aa08e8 to
4a52c5a
Compare
374fd4e to
fe0d582
Compare
4a52c5a to
91b97f9
Compare
91b97f9 to
eefe4ad
Compare
33b84c0 to
d1b396c
Compare
eefe4ad to
dbab749
Compare
d1b396c to
8687c59
Compare
dbab749 to
793390f
Compare
| let build_hasher = HashStrategy::from_constraints( | ||
| build_constraints, | ||
| Some(&interpreter.to_resolver_marker_environment()), | ||
| HashCheckingMode::Verify, |
There was a problem hiding this comment.
[P2] Require hashes for locked tool build dependencies
HashCheckingMode::Verify only validates build artifacts present in optional build constraints, while BuildDispatch resolves an sdist's build-system.requires from current indexes. An independent build-dependency publisher can therefore upload a compatible malicious release after lock creation and have locked tool install, run, or upgrade install and execute it with the caller's privileges. Fail closed for unknown build artifacts; this change compiled with cargo check --locked -p uv, and the focused hash-policy tests passed.
| HashCheckingMode::Verify, | |
| HashCheckingMode::Require, |
8687c59 to
9b923ba
Compare
793390f to
a7e1a19
Compare
|
Why do we reject |
|
I think I'd also expect exclusions to work? |
Does this mean you've introduced a new tiny pre-solver? |
|
Have you also considered the source tree case? e.g., astral-sh#405 |
| let (dependencies, _) = resolve_pylock_toml( | ||
| lock, |
There was a problem hiding this comment.
[P3] Do not cache PyPI artifacts under publisher-supplied indexes
After checking each dependency URL against PyPI, this call passes the publisher-controlled lock through unchanged, so package.index becomes RegistryBuiltWheel.index and the public wheel is cached under WheelCache::Index(index). A malicious tool can name a victim's configured private index while using a valid PyPI URL and hash; a later unhashed install of the same package, version, and filename from that index can reuse the public wheel without comparing its original URL, substituting attacker bytes for the private package before the selected tool executes. This requires preview opt-in, a known index URL, an exact identity collision, the same cache, and no trusted hash. Normalize packaged-lock indexes to canonical PyPI or bind cache entries to the validated artifact origin before lowering the lock.
26b27b9 to
7c471ba
Compare
7c471ba to
e152ddf
Compare
d3f029c to
cfeaa9f
Compare
cfeaa9f to
a7c2568
Compare
e152ddf to
3fca949
Compare
| .map(|entry| { | ||
| serde::Serialize::serialize(entry, toml_edit::ser::ValueSerializer::new()) | ||
| }) |
There was a problem hiding this comment.
[P2] Preserve URL hashes in scoped override receipts
For a locked installation with a scoped override such as dep @ https://supplier.example/dep-1.0-py3-none-any.whl#sha256=..., this serializes the nested Requirement directly, whose wire format discards the URL hash. A later uv tool upgrade restores the unhashed override from the receipt, refreshes its URL, and excludes that replacement from the packaged lock. If the publisher changes the archive and no separate hash constraint protects it, different bytes can therefore be built or installed despite the original hash pin. Serialize and restore scoped dependencies through a hash-preserving receipt wrapper, as already done for global overrides.
Expose the active lock entries and their registry artifact filenames, along with the wheel metadata and resolution details needed to validate a packaged lock.
Allow resolution and source builds to require each applicable set of hashes, including hashes supplied by indexes and artifact URLs. Check cached archives against the same policy before using their metadata.
Allow tool receipts to retain archive URL hashes and additional constraint and override information so later operations can enforce the inputs supplied at installation.
Cover hash strength, index metadata, and Python compatibility before installing a locked artifact.
Check that override wheels and source distributions are verified before their metadata or build backends are used.
Cover independently supplied hashes and ensure invalid sources are rejected before their build backends run.
Adds
--lockedtouv tool install,uv tool run/uvx, anduv tool upgradebehind thelocked-toolspreview feature. Runtime dependencies come from the selected wheel's.dist-info/pylock.toml, with artifact hashes required and verified. Stacked on #22595, which extends lock export to PEP 517 builds.Retained locked dependencies must use wheel or source distributions listed by a configured package index for the locked name and version, with filenames matching the index. Their URLs and filenames are checked before dependency files are accessed, including files for other platforms or extras. Selected artifacts require a non-MD5 hash; uv also checks non-MD5 hashes supplied by the index and checks Python compatibility against the index and wheel metadata. Local paths, VCS sources, and direct archives are rejected for retained locked dependencies. Offline use requires cached index metadata. Build requirements for source distributions are resolved separately and are not pinned by the packaged lock. Lock, index, and explicitly supplied constraint and override hashes are checked before running a source build backend. Hashes discovered later in dependency metadata are checked when encountered; a backend may already have run.
Tool selection skips releases without a wheel compatible with the requested Python or platform before reading the lock. Git sources and source-only distributions are not supported for the tool itself. Once a wheel is selected, a missing, invalid, or incompatible lock fails the operation instead of searching older releases for a lock. The selected wheel is bound to its computed hash, including when an index supplies no hash. Installed tools remember locked mode for later upgrades;
--unlockedreturns to normal resolution. Locked runs use an environment built from the packaged lock. Existing packages are reinstalled during locked installation and upgrade because their archive hashes cannot be verified from the installed files.Overrides can replace locked packages and resolve their new dependencies. Exclusions omit named packages. Since a standard lock does not provide an installation dependency graph, uv retains every other selected locked package even if it becomes unnecessary. Constraints must be compatible with retained locked packages. Selecting extras for the tool,
--with, scoped exclusions, and overrides or constraints with extra markers are unsupported. Scoped overrides apply to the tool and retained locked packages, but not packages that are themselves replaced; scoped overrides introduced by a replacement cannot replace another locked package. When an override or constraint uses hashes, overrides must include package names.UV_TOOL_LOCKEDenables locked tool operations by default.