The vulnerability lies in how zot handles bearer token authentication and authorization for different HTTP methods. The root cause is in the api.bearerAuthHandler function located in pkg/api/authn.go. This function incorrectly categorizes any non-GET/HEAD request as a 'push' action. Consequently, an HTTP DELETE request is treated as a 'push' operation.
The vulnerability is compounded by two other factors mentioned in the advisory:
- The
DistSpecAuthzHandler middleware, which could perform more granular checks, is bypassed for bearer token authentication.
- The actual handler functions that perform the deletion,
api.DeleteManifest and api.DeleteBlob, do not have their own authorization checks. They trust the result of the upstream bearerAuthHandler.
As a result, a user with a bearer token that only grants 'pull' and 'push' scopes can successfully execute DELETE requests on manifests and blobs, leading to unauthorized data deletion and potential disruption of services relying on the container registry.