Skip to content

Prototype a signed checksum authority - #818

Draft
zaniebot wants to merge 20 commits into
mainfrom
agent/checksum-authority-prototype
Draft

zaniebot wants to merge 20 commits into
mainfrom
agent/checksum-authority-prototype

Conversation

@zaniebot

@zaniebot zaniebot commented Aug 19, 2026 •

Copy link
Copy Markdown
Collaborator

Ad hoc dependency resolution learns expected archive hashes from the package index itself, which leaves no independent check if that index is compromised. Add an optional checksum authority that signs explicitly admitted archive sizes and SHA-256 digests, identified by source and distribution filename. uv verifies those records with a separately configured Ed25519 public key and checks complete archive bytes before extraction, while retaining existing lockfile and requirements hash checks.

The new uv-checksum-authority-service crate provides a read-only Rust server and commands to generate a key and admit local archives. Authority mode reads metadata from complete verified wheels and reuses cached archives whose computed hashes and sizes match the authority. Source-build outputs are isolated by verification key and carry receipts that bind their bytes to the archive authorizations observed during the build. The crate README describes the protocol, configuration, and verification policy.

@astral-automations-bot
astral-automations-bot Bot force-pushed the agent/checksum-authority-prototype branch 5 times, most recently from 950a438 to 45a2f93 Compare August 27, 2026 21:17
@astral-automations-bot astral-automations-bot Bot added enhancement New feature or request preview Experimental behavior labels Aug 28, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the agent/checksum-authority-prototype branch from 45a2f93 to 67d98bb Compare August 28, 2026 19:37
@astral-automations-bot
astral-automations-bot Bot force-pushed the agent/checksum-authority-prototype branch 6 times, most recently from 480a990 to 8c43163 Compare September 4, 2026 21:55
@astral-automations-bot
astral-automations-bot Bot force-pushed the agent/checksum-authority-prototype branch 2 times, most recently from 9e0833d to eb3a02d Compare September 9, 2026 16:03
@zaniebot zaniebot added priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. size:5 Project-sized: too much semantic scope for a normal review; needs decomposition or design review. security labels Sep 9, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the agent/checksum-authority-prototype branch 3 times, most recently from 6911491 to a916ce9 Compare September 10, 2026 18:45
@zaniebot zaniebot added the risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. label Sep 11, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the agent/checksum-authority-prototype branch from a916ce9 to 96332c7 Compare September 11, 2026 20:08
@codspeed

codspeed Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 69 untouched benchmarks
⏩ 35 skipped benchmarks1


Comparing agent/checksum-authority-prototype (2a61edc) with main (64e2ac8)

Open in CodSpeed

Footnotes

  1. 35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment on lines 852 to 855
let mut dynamic =
match StaticMetadata::read(source, source_dist_entry.path(), subdirectory).await? {
StaticMetadata::Some(metadata) => {
return Ok(ArchiveMetadata {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Reauthorize backend-generated source metadata

An authority-enabled backend can write a complete PKG-INFO into this source tree during metadata preparation. If a later invocation uses the same authority key but the catalog no longer admits one of that backend’s build dependencies, uv pip compile can still accept the generated metadata here: url_revision() reauthorizes only the source archive, and this return bypasses read_authority_receipt(). The authority namespace isolates ordinary builds but remains mutable across authorized builds. Restrict this shortcut to metadata from a pristine verified extraction, or track and reauthorize the workspace’s build inputs before consuming generated metadata. Cover this transition with a backend that writes PKG-INFO and a subsequent catalog missing its build dependency.

@zaniebot
zaniebot deployed to automations October 13, 2026 17:13 — with GitHub Actions Active
@zaniebot
zaniebot deployed to automations October 13, 2026 17:21 — with GitHub Actions Active
Comment on lines 688 to 690
let (revision, _source_is_pristine) = self
.url_revision(source, ext, url, index, source_cache_shard, hashes, client)
.await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Authorize cached source workspaces before building wheels

url() discards the pristine-source flag and reuses any existing source directory when no wheel is cached. Unlike url_metadata(), this path never reauthorizes the workspace’s previous build inputs. For example, an authority-enabled uv lock can run a metadata backend that generates source files and changes subsequent build requirements. If its original build dependency is later removed from the catalog, uv sync --frozen reaches this path directly and can build from those generated files; the new receipt then omits that dependency. Before rebuilding, restore a pristine verified extraction or reauthorize evidence covering the existing workspace. Share this policy with the metadata path, and cover the lock-to-frozen-sync transition in the existing authority tests.

@zaniebot
zaniebot deployed to automations October 13, 2026 17:41 — with GitHub Actions Active
Comment on lines +27 to +29
if let Some(authority) = client.checksum_authority() {
// Unversioned namespaces can contain outputs from shared mutable source workspaces.
shard.shard(format!("authority-v2-{}", authority.public_key()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Update package cache cleanup for authority settings shards

For a direct-URL sdist built with authority mode and --config-settings, metadata now lives at <revision>/authority-v2-<key>/<settings>/metadata.msgpack. However, CacheBucket::remove identifies these packages using is_match, whose traversal stops at .max_depth(2). If no ordinary or default-settings build exists, uv cache clean <package> therefore leaves the source revision and built wheels cached. Extend that lookup to recognize the authority namespace while retaining the src exclusion, and cover this layout in the existing cache-clean tests.

));
let mut hasher = Sha256::new();
let mut remaining = record.size();
while let Some(chunk) = body.chunk().await? {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P3] Distinguish archive-transfer failures from authority failures

If the package download times out or its connection breaks, this ? converts the body error into Error::Http, displayed as Checksum authority request failed. The authority lookup and signature verification have already succeeded; the failing response comes from the package index or CDN. This misleading context directs troubleshooting toward the wrong service. Map archive-body failures to a separate error variant carrying the artifact identity and original cause, reserving the authority-request diagnostic for lookup failures.

Comment on lines 658 to 661
if hash_policy == ArchiveHashPolicy::Generate
|| self.client.unmanaged.has_checksum_authority()
{
let wheel = self.get_wheel(dist, hash_policy).await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P3] Guard the public metadata API in authority mode

This branch protects DistributionDatabase callers, but an authority-configured RegistryClient still exposes wheel_metadata(), which can return cached, PEP 658, or range-read metadata without consulting the authority. The current CLI route is checked, but other consumers must remember this external routing rule to uphold the configured policy. Add a guard rejecting unverified remote metadata reads in RegistryClient::wheel_metadata() when authority mode is enabled, or route that method through verified archive handling. The existing database path can continue providing cache reuse.

Comment on lines 797 to +800
write_atomic(metadata_entry.path(), rmp_serde::to_vec(&metadata)?)
.await
.map_err(Error::CacheWrite)?;
let _ = write_authority_receipt(client.unmanaged, &metadata_entry).await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P3] Reuse the receipt-aware metadata writer

This wheel-build path duplicates the metadata-and-receipt write sequence now owned by CachedMetadata::write, which all four writes in url_metadata() use. Maintaining both implementations makes changes to metadata persistence or receipt handling liable to diverge between wheel builds and metadata preparation. Replace this sequence with CachedMetadata::write(&metadata, &metadata_entry, client.unmanaged).await? so both paths share the same persistence policy.

Comment on lines +459 to +461
{
remote.push(dist.clone());
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Preserve authority identity across in-memory cache hits

Routing into remote does not guarantee authority verification: Preparer::get_wheel first checks in_flight.downloads, keyed by distribution_id(). For registry files, that ID is the first index-advertised hash, without the source or filename. A build dependency admitted from index A can therefore populate shared state that satisfies a later requirement from index B with the same name, version, and hash, without checking B's admission. The resolver metadata cache uses the same identity and can bypass its lookup too. Include the authority artifact identity in these cache keys, or reauthorize the requested identity before accepting either shortcut.

This branch was successfully deployed

1 active (outdated) deployment
automations — fa150143 Deployed Oct 21, 2026 by astral-automations-bot[bot] via review-code-quality / report #11245
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:skip-release Disable building release binaries for a pull request enhancement New feature or request preview Experimental behavior priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. security size:5 Project-sized: too much semantic scope for a normal review; needs decomposition or design review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants