The vulnerability lies in the improper handling of access token scopes within Gitea's package registries. The root cause is that the scope of an access token was not correctly propagated and enforced during the authentication process for package operations.
Specifically, the services/packages.CreateAuthorizationToken function would generate a new JSON Web Token (JWT) for package access without embedding the scope of the original access token. Concurrently, the services/packages.ParseAuthorizationToken function would only extract the user ID from this JWT, completely ignoring any scope information.
This flaw was exploited in the authentication middleware for the Conan and Container registries (auth.Verify methods). These methods would use the vulnerable parser, effectively authenticating the user but failing to check if their token was actually permitted to access the package registry. The Authenticate functions for these registries also failed to perform the necessary scope checks.
The patch addresses this by modifying the JWT creation and parsing functions to include and extract the token scope. It also adds explicit scope validation checks in the Authenticate and Verify functions across the affected package registries (Conan, Container, and NuGet) to ensure that the user's token has the required read:package or write:package permissions.