GHSA-vxv2-8j6r-pcpg Gitea: OAuth token introspection returns metadata of tokens issued to other clients (RFC 7662 section 4 violation)
Live reproduction against Gitea 1.26.1Setup: Gitea 1.26.1 docker stack with two users (`admin` and `victim`) and two OAuth applications owned by different users:`admin` runs an OAuth flow against Client A and obtains an access token. `victim` (acting through Client B's credentials) calls the introspection endpoint with Client A's access token in the body:Note the `aud` claim: the server explicitly states the token's audience is Client A, yet returns the full metadata to Client B. Per RFC 7662 section 4 ("The authorization server SHOULD also limit the information it discloses about each token to the resources that are authorized to receive it") the introspection result must not be disclosed to clients other than the token's audience.Full reproduction script attached as `poc.sh`. Full session log attached as `live_run.log`.Root cause`routers/web/auth/oauth2_provider.go:130-175` `IntrospectOAuth`:The handler:Authenticates the introspecting client via HTTP Basic (`app.ValidateClientSecret`). The local variable `app` at this point references the introspecting client.Loads the grant for `form.Token` via `auth.GetOAuth2GrantByID(ctx, token.GrantID)`.**Reassigns** `app` to `auth.GetOAuth2ApplicationByID(ctx, grant.ApplicationID)` (line 162). After this point, `app` is the token's issuing client, not the introspecting client.Populates `response` from the reassigned `app` and the grant.There is no comparison between the introspecting client's id and `grant.ApplicationID`. The endpoint will return metadata for any token whose JWT signature validates, regardless of which client is asking.Patch parity with PR #37704The same file contains two recently-hardened handlers in commit `7e54514316` ("fix(oauth): bind token exchanges to the original client request", PR #37704, 2026-05-15) that added exactly this missing check:`handleRefreshToken` (routers/web/auth/oauth2_provider.go:561-568):`handleAuthorizationCode` (routers/web/auth/oauth2_provider.go:640-647):`IntrospectOAuth` shares the same problem space (it consumes a token bound to a grant whose application may differ from the requesting client) but did not receive the parallel patch.ImpactAny authenticated OAuth client can call `/login/oauth/introspect` with another client's access or refresh token in the body and learn:`active` (true or false). A token-validity oracle that survives across application boundaries without consuming or "using" the token.`scope`. The scope of the token.`username`. The user the token belongs to.`iss`, `sub`, `aud`. Standard JWT registered claims. `aud` reveals the issuing client_id, making it obvious to the introspecting client that the token does not belong to them. The server returns the data anyway.Practical scenarios:**Stolen-token validation oracle.** An attacker who exfiltrates an access token from logs, traffic capture, browser memory, or a leaked dump can verify the token is still active before using it for higher-noise actions like API calls. The probe does not consume the grant counter, so it does not appear in audit trails of "actual token use".**Cross-tenant metadata enumeration.** Any user can register their own OAuth application on a Gitea instance (web UI: /user/settings/applications). The attacker uses their own valid credentials to introspect tokens belonging to other tenants' clients. They learn which user/scope each token corresponds to without ever using it.**Token-confusion reconnaissance.** Before chaining a separate vulnerability (e.g., a future token-replay or session-fixation bug), the attacker can use introspection to map the token universe.Suggested remediationA one-line fix matching the PR #37704 pattern:Or, equivalently, replace the inner `app` reassignment with a check that uses the introspecting client's `app.ClientID` directly for the response claims.Affected versionsConfirmed at Gitea v1.26.1 (latest release, 2026-04-24, docker image `gitea/gitea:1.26.1`). The vulnerable code path has been in place since the introspection endpoint was introduced; the recent PR #37704 / #37706 OAuth hardening landed in master May 15-16 2026 but did not touch this endpoint.Attachments[poc.sh](https://github.com/user-attachments/files/28182098/poc.sh): Full reproduction script.[live_run.log](https://github.com/user-attachments/files/28182115/live_run.log): Full session log.
CVSS v3.1 score: 4.3