-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The gate is on `linkedBlobStore.Delete`, not on the driver\n\nThe OCI Distribution Spec lets an API client say \"remove this manifest\" two ways. Either the URL ends in a digest (`DELETE /v2/alpine/manifests/sha256:abc...`) or the URL ends in a tag (`DELETE /v2/alpine/manifests/3.23`). The Distribution registry forks on the difference inside the same handler. The two branches land in two different storage methods. CVE-2026-41888 is what the two methods disagree about.\n\nThe digest branch flows through `linkedBlobStore.Delete` in `registry/storage/linkedblobstore.go`. That method's first statement is the gate operators expect when they set `storage.delete.enabled: false`:\n\n```go\nfunc (lbs *linkedBlobStore) Delete(ctx context.Context, dgst digest.Digest) error {\n\tif !lbs.deleteEnabled {\n\t\treturn distribution.ErrUnsupported\n\t}\n\t// Ensure the blob is available for deletion\n\t_, err := lbs.blobAccessController.Stat(ctx, dgst)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = lbs.blobAccessController.Clear(ctx, dgst)\n\t...\n}\n```\n\nThe `deleteEnabled` field is set at registry construction time, from the `EnableDelete` functional option that `NewApp` only appends when the operator's config has `storage.delete.enabled: true`. If the operator omits the option or sets the flag to `false`, the field stays at its zero value, and every digest-based delete through this method returns `ErrUnsupported` before any storage I/O happens.\n\nThe tag branch flows through `tagStore.Untag` in `registry/storage/tagstore.go`. Pre-patch, the entire body of that method was four executable lines, none of which consulted `deleteEnabled`:\n\n```go\n// Untag removes the tag association\nfunc (ts *tagStore) Untag(ctx context.Context, tag string) error {\n\ttagPath, err := pathFor(manifestTagPathSpec{\n\t\tname: ts.repository.Named().Name(),\n\t\ttag: tag,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ts.blobStore.driver.Delete(ctx, tagPath)\n}\n```\n\n`pathFor(manifestTagPathSpec{...})` resolves to `/v2/repositories//_manifests/tags//`. The call to `ts.blobStore.driver.Delete` reaches the storage driver directly. Where `linkedBlobStore.Delete` is the wrapper that holds the `deleteEnabled` check, `driver.Delete` is the wrapper's underlying writer with no concept of the configuration flag. The operator's deletion policy is encoded one layer up, on a method this call path never touches.\n\n## The handler forks on `imh.Tag` and walks down two different storage subtrees\n\n`registry/handlers/manifests.go` is where the routing decision is made. Pre-patch:\n\n```go\nfunc (imh *manifestHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(imh).Debug(\"DeleteImageManifest\")\n\n\tif imh.App.isCache {\n\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n\t\treturn\n\t}\n\n\tif imh.Tag != \"\" {\n\t\tdcontext.GetLogger(imh).Debug(\"DeleteImageTag\")\n\t\ttagService := imh.Repository.Tags(imh.Context)\n\t\tif err := tagService.Untag(imh.Context, imh.Tag); err != nil {\n\t\t\tswitch err.(type) {\n\t\t\tcase distribution.ErrTagUnknown, driver.PathNotFoundError:\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t\tdefault:\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tw.WriteHeader(http.StatusAccepted)\n\t\treturn\n\t}\n\n\tmanifests, err := imh.Repository.Manifests(imh)\n\t...\n\terr = manifests.Delete(imh, imh.Digest)\n```\n\nTwo branches, written next to each other. The first ends at `tagService.Untag`. The second ends at `manifests.Delete`, which dispatches into the manifest store and eventually reaches `linkedBlobStore.Delete`. The branches read as siblings; their storage paths are not siblings. One of them passes through the wrapper that owns the operator's deletion config. The other goes around it.\n\nA registry started with this config file from the advisory:\n\n```yaml\nversion: 0.1\nstorage:\n delete:\n enabled: false\n filesystem:\n rootdirectory: /var/lib/registry\nhttp:\n addr: :5000\n```\n\nanswers the two delete shapes differently. With a manifest digest, the request stops at the storage gate and returns the registry's standard \"unsupported operation\" error. With a tag reference, the same handler walks into `tagStore.Untag`, the tag's index directory is removed from the filesystem driver, and the response is `202 Accepted`:\n\n```\n$ curl 'http://localhost:5000/v2/alpine/tags/list'\n{\"name\":\"alpine\",\"tags\":[\"3.23\"]}\n\n$ curl -X DELETE 'http://localhost:5000/v2/alpine/manifests/3.23'\n\n$ curl 'http://localhost:5000/v2/alpine/tags/list'\n{\"name\":\"alpine\",\"tags\":null}\n```\n\nNo authentication is configured in the advisory's reproducer. None is required by the code. The `DeleteManifest` handler has no caller-identity check beyond the one supplied by the operator's auth layer; the gate that the operator believed was disabling deletion entirely is, for this path, advisory at the storage layer and absent at the handler layer.\n\n## The 2021 commit removed the gate that was a rejection\n\nBefore May 27, 2021, the handler did not have two branches. It had one, and a rejection. Commit `6ae6df7d` (\"Add tag delete API,\" signed off by João Pereira) is where the second branch was added. The diff against the prior `DeleteManifest`:\n\n```diff\n-// DeleteManifest removes the manifest with the given digest from the registry.\n+// DeleteManifest removes the manifest with the given digest or the tag with the given name from the registry.\n func (imh *manifestHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) {\n \tdcontext.GetLogger(imh).Debug(\"DeleteImageManifest\")\n\n-\tif imh.Tag != \"\" {\n+\tif imh.App.isCache {\n \t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n \t\treturn\n \t}\n\n+\tif imh.Tag != \"\" {\n+\t\ttagService := imh.Repository.Tags(imh.Context)\n+\t\tif err := tagService.Untag(imh.Context, imh.Tag); err != nil {\n+\t\t\tswitch err.(type) {\n+\t\t\tcase distribution.ErrTagUnknown:\n+\t\t\tcase driver.PathNotFoundError:\n+\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown)\n+\t\t\tdefault:\n+\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown)\n+\t\t\t}\n+\t\t\treturn\n+\t\t}\n+\t\tw.WriteHeader(http.StatusAccepted)\n+\t\treturn\n+\t}\n```\n\nThe removed block, `if imh.Tag != \"\" { errors = append(errors, ErrorCodeUnsupported); return }`, was the entire reason the storage-layer gate worked. It was not labeled as a security check. It was the handler refusing to do something it could not yet do. The deletion gate at `linkedBlobStore.Delete` was correct in that earlier world because the handler did not accept tag references and so could not reach a non-gated storage method.\n\nThe 2021 commit reads as a feature commit. The body of the commit message is one sentence (\"Add tag delete API\"). The diff touches eight files. None of those files is `registry/storage/linkedblobstore.go`, the file the operator's config flag was attached to. The new branch wires the tag delete to `tagStore.Untag`, which exists in the codebase for several years before this and was previously only invoked by the digest-delete handler's tag-cleanup loop (when a manifest was deleted, the handler enumerated tags pointing to it and untagged them). That tag-cleanup loop only ran after `manifests.Delete` had already succeeded, which meant the loop only ran when `deleteEnabled` was already true. `tagStore.Untag` therefore had never been called along a code path that reached it with `deleteEnabled` false. The 2021 commit introduced the first one.\n\nCVE-2026-41888 is the [parallel-implementation-gap](/patterns/parallel-implementation-gap) shape the catalog has been collecting: a capability implemented twice in the same file, where the gate is wired through one branch and not the other. The closest sibling exhibits are [Axios's CVE-2026-42036](/posts/axios-maxcontentlength-was-inside-the-buffered-loop) (the `maxContentLength` cap rode inside the buffered branch's chunk counter, and the streaming branch had no counter for it to ride), [Next.js's CVE-2026-44577](/posts/nextjs-cve-2026-44577-cap-wired-to-one-branch-of-the-ternary) (the response-size cap was threaded into the external branch of a ternary and not the internal branch), and [NocoBase's CVE-2026-41641](/posts/nocobase-cve-2026-41641-checksql-two-of-three-actions) (a `checkSQL` middleware was wired to two of three actions on one object literal). The Distribution case is the across-handler-branches variant of the same shape, plus a temporal precondition: the gate at the storage layer had been the only gate because the handler had been refusing the divergent shape on its own. Removing the handler's refusal made the storage-layer gate's coverage incomplete in the same diff that made the divergence reachable.\n\n## The test that shipped with the bug asserted the bug\n\nFive files changed in commit `6ae6df7d`. One of them was `registry/handlers/api_test.go`, which added the test suite for the new tag-delete API. The test setup function it called was `newTestEnv(t, deleteEnabled bool)`:\n\n```go\nfunc newTestEnv(t *testing.T, deleteEnabled bool) *testEnv {\n\tconfig := configuration.Configuration{\n\t\tStorage: configuration.Storage{\n\t\t\t\"inmemory\": configuration.Parameters{},\n\t\t\t\"delete\": configuration.Parameters{\"enabled\": deleteEnabled},\n\t\t\t...\n```\n\nThe second argument flows into the registry config as `storage.delete.enabled`. The test that the 2021 commit added, `TestManifestAPI_DeleteTag`, called it like this:\n\n```go\nfunc TestManifestAPI_DeleteTag(t *testing.T) {\n\tenv := newTestEnv(t, false)\n\tdefer env.Shutdown()\n\t...\n```\n\n`false`. The test that asserted tag delete worked was run against a registry the test had explicitly configured with deletions disabled. It passed for nearly five years. It had to pass; the bug was the only reason it could.\n\nThe April 25, 2026 fix diff includes this change to that test file:\n\n```diff\n func TestManifestAPI_DeleteTag(t *testing.T) {\n-\tenv := newTestEnv(t, false)\n+\tenv := newTestEnv(t, true)\n \tdefer env.Shutdown()\n```\n\nTwo characters. The fix had to flip the test from `false` to `true` because the test was verifying legitimate tag-delete functionality, and after the patch, legitimate tag-delete functionality requires deletions to be enabled. A new test, `TestManifestAPI_DeleteTag_DeleteDisabled`, was added alongside it:\n\n```go\nfunc TestManifestAPI_DeleteTag_DeleteDisabled(t *testing.T) {\n\tenv := newTestEnv(t, false)\n\tdefer env.Shutdown()\n\t...\n\tresp, err := httpDelete(u)\n\tmsg := \"deleting tag with delete disabled\"\n\tcheckResponse(t, msg, resp, http.StatusMethodNotAllowed)\n\tcheckBodyHasErrorCodes(t, msg, resp, errcode.ErrorCodeUnsupported)\n\n\tmsg = \"checking tag exists after rejected delete\"\n\tresp, err = http.Get(u)\n\tcheckResponse(t, msg, resp, http.StatusOK)\n}\n```\n\nThe new test is the test the 2021 commit should have written. It uses the same `newTestEnv(t, false)` the original test used, and asserts the opposite outcome. Side by side, the diff makes the inversion explicit: the original test in 2021 sent a DELETE to a registry with deletes disabled and checked the tag was gone; the new test in 2026 sends the same DELETE to a registry with deletes disabled and checks the tag is still there. Both tests run against the same config. The change between them is which behavior the project is willing to commit to in writing.\n\nThe test that shipped with the bug-introducing commit was not written wrong. It was written to verify the feature its commit introduced. The feature's behavior was the bug. The test's `false` is the receipt.\n\n## The fix wires `deleteEnabled` to three places\n\nThe April 25, 2026 patch (commit `8baf3e0`, \"fix: prevent tag deletion when storage.delete.enabled is false,\" same author as the original commit five years earlier) does not put the gate in one place. It puts it in three.\n\nFirst, the `App` struct gains a `deleteEnabled` field that the handler layer can read without descending into the storage configuration:\n\n```diff\n type App struct {\n \t...\n \t// readOnly is true if the registry is in a read-only maintenance mode\n \treadOnly bool\n+\n+\t// deleteEnabled is true if the registry is configured to enable deletions.\n+\tdeleteEnabled bool\n }\n```\n\n`NewApp` sets it in the same conditional that installs the `EnableDelete` storage option. Second, `DeleteManifest` consults the new field at the top of the handler, before either branch of the `imh.Tag` fork is reached:\n\n```diff\n+\tif !imh.App.deleteEnabled {\n+\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n+\t\treturn\n+\t}\n+\n \tif imh.Tag != \"\" {\n \t\tdcontext.GetLogger(imh).Debug(\"DeleteImageTag\")\n \t\ttagService := imh.Repository.Tags(imh.Context)\n```\n\nThe fix at this layer alone would close CVE-2026-41888. The handler refuses every delete the operator disabled, before the fork happens. Third, `tagStore` itself gets the flag wired in, and `Untag` rejects the operation at the storage layer too:\n\n```diff\n type tagStore struct {\n \trepository *repository\n \tblobStore *blobStore\n \tconcurrencyLimit int\n+\tdeleteEnabled bool\n }\n```\n\n```diff\n // Untag removes the tag association\n func (ts *tagStore) Untag(ctx context.Context, tag string) error {\n+\tif !ts.deleteEnabled {\n+\t\treturn distribution.ErrUnsupported\n+\t}\n \ttagPath, err := pathFor(manifestTagPathSpec{\n```\n\nThe handler-layer fix is sufficient. The storage-layer fix is what tells you the author had counted the callers. `tagStore.Untag` is reachable from `proxyTagService.Untag` (pull-through proxy mode delegates to a local tag store) and from the manifest-delete handler's tag-cleanup goroutines, which untag every tag pointing to a digest after the digest's manifest has been deleted. The fix at three layers exists because at least one of those other callers might, in some future commit, be reachable from a route the handler-layer check does not cover. The patch author wrote the gate three times because the bug existed in the first place by being written zero times where it was needed.\n\n## Distribution v2 was never patched\n\nThe advisory lists two affected packages. `github.com/distribution/distribution/v3` is fixed in 3.1.1. `github.com/distribution/distribution`, the v2 line that ships as the Docker `registry:2` image, is listed as vulnerable in `<= 2.8.3` with `first_patched_version: null`. There is no v2 fix. Operators running `registry:2` who configured `storage.delete.enabled: false` because they wanted their registry immutable are running an unpatched registry against a CVE-2026-41888 reproducer that ships in the GitHub advisory. The route forward for those operators is to upgrade to v3, which has been GA since April 2025 but is a major version bump with configuration migration. The bug class lives in both lines, the fix lives in one.\n\n## What `storage.delete.enabled: false` meant, against what it did\n\nAn operator setting `storage.delete.enabled: false` was making a registry-level statement about destructive operations. The flag's documentation describes deletion of manifests and blobs at the API surface. The implementation placed enforcement at the storage layer's blob-and-manifest wrapper. When tag deletion was added in 2021, the operator's intent (`no destructive API on this registry`) and the implementation's enforcement model (`gate the storage method the digest-delete path happens to flow through`) drifted apart. Tag deletion is destructive at the API surface. It is not destructive at the blob layer (the underlying manifest data stays on disk until garbage collection runs, if it ever does). The gate sat where the blob layer was, and the new API didn't reach the blob layer.\n\nThis is the gap operators routinely fall into when a vendor's config option names a verb (delete) and the implementation places the gate at a noun (blob storage). The verb has at least two referents in the OCI Distribution Spec. The noun has one.\n\nPoC: [github.com/advisories/GHSA-6pjf-3r9x-m592](https://github.com/advisories/GHSA-6pjf-3r9x-m592)","closing_line":"The 2021 commit replaced one rejection with one acceptance. The 2026 patch restores the rejection in three places, in case the next tag-shaped feature does not look up.","hook_md":"Before commit `6ae6df7d` on May 27, 2021, the first executable statement of Distribution's `DeleteManifest` handler was an unconditional rejection of every tag-shaped request. The handler refused tag references. The `storage.delete.enabled` gate at the storage layer was correct because nothing reached past it that the gate did not cover. The 2021 commit removed the rejection, added a tag-delete branch, and routed it through a sibling storage method nobody had thought to gate. The test that shipped in the same commit ran with `delete: { enabled: false }` and asserted the tag was gone afterward. CVE-2026-41888 was codified by the same diff that introduced it.","post_id":435,"slug":"distribution-cve-2026-41888-tag-delete-bypassed-storage-gate","title":"CVE-2026-41888: Distribution Added Tag Deletion in 2021. The Storage Gate Was Three Functions Away.","type":"initial","unreadable_sentence":"The test that shipped in the bug-introducing commit ran with `delete: { enabled: false }` and asserted the tag was gone afterward. The bug shipped with a passing test that codified it."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCamT7EAAKCRDeZjl4jgkQ JsisAQDVieyV77TfjFu8IlyJc42ENxaWCE9eko49efZFoMf2LQD9FESYtfEpdqgT kZnaRKU2ahiOdlj+MmdLoYcA6vHQHg0= =CqQh -----END PGP SIGNATURE-----