CVE-2026-58425

CVE-2026-58425 is a medium-severity incorrect authorization vulnerability in code.gitea.io/gitea (go), affecting versions < 1.27.0. It is fixed in 1.27.0.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

Gitea: OAuth token introspection returns metadata of tokens issued to other clients (RFC 7662 section 4 violation)

Live reproduction against Gitea 1.26.1

Setup: Gitea 1.26.1 docker stack with two users (admin and victim) and two OAuth applications owned by different users:

Client A: id=5dda747d-7fdd-4694-85ff-ce4f893ce51e   owner=admin
Client B: id=588f778f-4a41-4914-ae01-85d776c369db   owner=victim

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:

$ curl -s -u "$B_ID:$B_SEC" -X POST http://localhost:3001/login/oauth/introspect \
       --data-urlencode "token=$CLIENT_A_ACCESS_TOKEN"
{
    "active": true,
    "username": "admin",
    "iss": "http://localhost:3001",
    "sub": "1",
    "aud": [
        "5dda747d-7fdd-4694-85ff-ce4f893ce51e"
    ]
}

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:

func IntrospectOAuth(ctx *context.Context) {
    clientIDValid := false
    authHeader := ctx.Req.Header.Get("Authorization")
    if parsed, ok := httpauth.ParseAuthorizationHeader(authHeader); ok && parsed.BasicAuth != nil {
        clientID, clientSecret := parsed.BasicAuth.Username, parsed.BasicAuth.Password
        app, err := auth.GetOAuth2ApplicationByClientID(ctx, clientID)
        if err != nil && !auth.IsErrOauthClientIDInvalid(err) {
            log.Error("Error retrieving client_id: %v", err)
            ctx.HTTPError(http.StatusInternalServerError)
            return
        }
        clientIDValid = err == nil && app.ValidateClientSecret([]byte(clientSecret))
    }
    if !clientIDValid {
        ctx.Resp.Header().Set("WWW-Authenticate", `Basic realm="Gitea OAuth2"`)
        ctx.PlainText(http.StatusUnauthorized, "no valid authorization")
        return
    }

    var response struct {
        Active   bool   `json:"active"`
        Scope    string `json:"scope,omitempty"`
        Username string `json:"username,omitempty"`
        jwt.RegisteredClaims
    }

    form := web.GetForm(ctx).(*forms.IntrospectTokenForm)
    token, err := oauth2_provider.ParseToken(form.Token, oauth2_provider.DefaultSigningKey)
    if err == nil {
        grant, err := auth.GetOAuth2GrantByID(ctx, token.GrantID)
        if err == nil && grant != nil {
            app, err := auth.GetOAuth2ApplicationByID(ctx, grant.ApplicationID)  // shadows the introspecting client's `app`
            if err == nil && app != nil {
                response.Active = true
                response.Scope = grant.Scope
                response.RegisteredClaims = oauth2_provider.NewJwtRegisteredClaimsFromUser(app.ClientID, grant.UserID, nil)
            }
            if user, err := user_model.GetUserByID(ctx, grant.UserID); err == nil {
                response.Username = user.Name
            }
        }
    }

    ctx.JSON(http.StatusOK, response)
}

The handler:

  1. Authenticates the introspecting client via HTTP Basic (app.ValidateClientSecret). The local variable app at this point references the introspecting client.
  2. Loads the grant for form.Token via auth.GetOAuth2GrantByID(ctx, token.GrantID).
  3. Reassigns app to auth.GetOAuth2ApplicationByID(ctx, grant.ApplicationID) (line 162). After this point, app is the token's issuing client, not the introspecting client.
  4. 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 #37704

The 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):

if grant.ApplicationID != app.ID {
    handleAccessTokenError(ctx, oauth2_provider.AccessTokenError{
        ErrorCode:        oauth2_provider.AccessTokenErrorCodeInvalidGrant,
        ErrorDescription: "refresh token belongs to a different client",
    })
    return
}

handleAuthorizationCode (routers/web/auth/oauth2_provider.go:640-647):

if authorizationCode.RedirectURI != "" && form.RedirectURI != authorizationCode.RedirectURI {
    handleAccessTokenError(ctx, oauth2_provider.AccessTokenError{ ... })
    return
}
// later in the same function:
if authorizationCode.Grant.ApplicationID != app.ID {
    handleAccessTokenError(ctx, ...)
    return
}

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.

Suggested remediation

A one-line fix matching the PR #37704 pattern:

 grant, err := auth.GetOAuth2GrantByID(ctx, token.GrantID)
 if err == nil && grant != nil {
+    if grant.ApplicationID != app.ID {
+        // do not reveal token metadata for tokens not issued to this client
+        ctx.JSON(http.StatusOK, response)  // response is zero-valued, active=false
+        return
+    }
     app, err := auth.GetOAuth2ApplicationByID(ctx, grant.ApplicationID)

Or, equivalently, replace the inner app reassignment with a check that uses the introspecting client's app.ClientID directly for the response claims.

Affected versions

Confirmed 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

Impact

Any 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:

  1. 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".
  2. 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.
  3. 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.

The application does not correctly enforce access controls, allowing a principal to access resources or operations beyond their granted permissions. Typical impact: unauthorized data access or execution of privileged operations.

CVE-2026-58425 has a CVSS score of 4.3 (Medium). The vector is network-reachable, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.27.0); upgrading removes the vulnerable code path.

Affected versions

code.gitea.io/gitea (< 1.27.0)

Security releases

code.gitea.io/gitea → 1.27.0 (go)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Upgrade code.gitea.io/gitea to 1.27.0 or later to resolve this vulnerability.

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2026-58425? CVE-2026-58425 is a medium-severity incorrect authorization vulnerability in code.gitea.io/gitea (go), affecting versions < 1.27.0. It is fixed in 1.27.0. The application does not correctly enforce access controls, allowing a principal to access resources or operations beyond their granted permissions.
  2. How severe is CVE-2026-58425? CVE-2026-58425 has a CVSS score of 4.3 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of code.gitea.io/gitea are affected by CVE-2026-58425? code.gitea.io/gitea (go) versions < 1.27.0 is affected.
  4. Is there a fix for CVE-2026-58425? Yes. CVE-2026-58425 is fixed in 1.27.0. Upgrade to this version or later.
  5. Is CVE-2026-58425 exploitable, and should I be worried? Whether CVE-2026-58425 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-58425 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2026-58425? Upgrade code.gitea.io/gitea to 1.27.0 or later.

Other vulnerabilities in code.gitea.io/gitea

Stop the waste.
Protect your environment with Kodem.