Repository navigation
Registry: a pull no longer keeps a deleted image's blobs pullable - #907
Merged
Merged
Conversation
Every GET or HEAD of a blob renewed its link's grace period (serve_blob -> oci_dao::touch_link), so after an image, manifest or tag was deleted, anyone who could read the repository and knew a digest kept its config and layers pullable for as long as they fetched them once per docker.unreferenced_blob_ttl_seconds. The grace period is for uploads before their manifest. A fetch now records a use of the link only for a caller who may push the image the link is in (Registry::confirms_link): a credential a push is accepted from, a registry token whose scope has push, write permission on the repository the push would land in (the repository itself, or a group's writable member). That is the HEAD docker push sends before it skips a layer's upload. Every other fetch records nothing, so the sweeper releases an unreferenced blob at most that TTL after it was last pushed, mounted or confirmed by a pusher. docs/docker.md and the image page's delete dialog say what stays pullable after a delete and for how long. Fixes #576 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJbNZS4UTo7eDJvykUw
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJbNZS4UTo7eDJvykUw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #576
The problem
After an image, manifest or tag is deleted, its config and layers stay linked to the image until the registry sweeper finds the links unused for
docker.unreferenced_blob_ttl_seconds(24 h). EveryGETorHEADof such a blob renewed the link (serve_blob→oci_dao::touch_link), so anyone who could read the repository and knew a digest kept the content of a deleted image pullable for as long as they fetched it once a day.The change
Of the issue's two directions, this takes the first: a fetch does not renew a link, except for a client that is pushing.
Registry::confirms_link(crates/server/src/images/pull.rs) decides whether serving a blob records a use of its link. It does only for a caller who may push the image the link is in: a credential a push is accepted from, a registry token whose scope haspush, and write permission on the repository a push to that name lands in (the repository itself, or a group's writable member; never a proxy).docker pushasks with aHEADwhether the image has a layer, skips the upload, and names the layer in a manifest afterwards. Such a caller could push the blob again anyway, so the renewal gives it nothing new.Why not the second direction (purge the image's unreferenced links with a whole-image delete): it would also remove the layers of a push in progress to that image, whose manifest then fails with
BLOB_UNKNOWN; it covers only the whole-image delete, not a manifest deleted through the registry API or retention; and it changes the admin delete that #560 is reworking.What this does not change: a deleted image's blobs are still pullable by digest until the sweeper releases them (up to the TTL plus a sweep interval). The docs and the dialog now say so.
Docs and UI
docs/docker.md, Retention and garbage collection: who records a use, what stays pullable after a delete and for how long, and that a leaked secret is to be rotated.docs/changes/2.2.0/576.security.md. The issue was inBacklog; it is moved to the 2.2.0 milestone, the next release.No admin API changes, so no new admin screen.
Verification
Run locally, with Postgres and versitygw from testcontainers (pulled through
mirror.gcr.io):fetching_the_blobs_of_a_deleted_image_does_not_keep_them(crates/server/tests/registry.rs): after a manifest is deleted, a reader and a writerGET/HEADits layer and config, a reader also with a token requested forpull,push; the sweep releases both and they answer 404. The layer the other manifest names and that manifest still pull. A push in progress (a layer pushed before its manifest, a cross-repository mount) confirmed with a push-tokenHEADsurvives the sweep and its manifests are accepted. A layer nobody confirms goes after the TTL although it is read.confirming_a_blob_records_the_use_of_its_linkextended: a pull token'sHEADandGETrecord nothing, a push token'sHEADdoes (throttled as before), also through a group whose writable member holds the link.cargo xtask check(fmt, clippy-D warnings),cargo xtask changelog --check,cargo xtask docs --check,cargo xtask unused,cargo xtask doc-check.forge-serverunit tests and the integration binariesregistry,import,admin_retention,format_contract,workers,browse: all pass.pnpm run tsc,pnpm run knip,pnpm run test(635 tests).Not run locally:
forge-e2e(the session's disk did not hold a full workspace test build); CI'stestande2ejobs run them.oci-e2e(realdocker push, crane, helm, cosign and the conformance suite): crane, helm and cosign are not installed in the session. This is the check that real clients' pushes still confirm their layers, so its CI result matters.web-e2e(Playwright).Generated by Claude Code