/

CVE-2026-101023

Severity:

CRITICAL RISK

(9.1)

OAuth Token Validation Bypass (CWE-287) in Gitea Server

CVE-2026-101023

Analyzed

Vulnerability type

Category:

Authentication Bypass

CWE:

CWE-287

Impact:

Unauthorized OAuth2 token renewal and prolonged authenticated access

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Gitea's OAuth2 token endpoint accepted an unexpired access token when a refresh token was required, provided the token belonged to the same application and grant. An attacker holding such an access token could obtain replacement access and refresh tokens, potentially extending access beyond the token's intended lifetime.

Gitea's OAuth2 token endpoint accepted an unexpired access token when a refresh token was required, provided the token belonged to the same application and grant. An attacker holding such an access token could obtain replacement access and refresh tokens, potentially extending access beyond the token's intended lifetime.

Affected context

The issue occurs in Gitea OAuth2 deployments when the token endpoint processes requests using the refresh_token grant type. The endpoint verifies the token's signature and application relationship but may fail to confirm that the submitted credential is specifically a refresh token rather than an access token.

The issue occurs in Gitea OAuth2 deployments when the token endpoint processes requests using the refresh_token grant type. The endpoint verifies the token's signature and application relationship but may fail to confirm that the submitted credential is specifically a refresh token rather than an access token.

Exploit preconditions

  • Attack surface: Gitea's OAuth2 token endpoint
  • Required access: Possession of a valid, unexpired access token issued for the relevant OAuth2 application and grant
  • Trigger point: A token request using the refresh_token grant type
  • Why exploitation is possible: Token validation confirms authenticity and application scope without enforcing the required token type
  • Attack surface: Gitea's OAuth2 token endpoint
  • Required access: Possession of a valid, unexpired access token issued for the relevant OAuth2 application and grant
  • Trigger point: A token request using the refresh_token grant type
  • Why exploitation is possible: Token validation confirms authenticity and application scope without enforcing the required token type

Why this happens

The underlying defect is incomplete credential-type validation in an authentication flow. The endpoint validates the submitted token's signature and association with the OAuth2 application but does not enforce that the credential is a refresh token before allowing token renewal. This behavior maps to CWE-287: Improper Authentication, because the system accepts a credential in a context where its intended authentication role has not been adequately verified.

The underlying defect is incomplete credential-type validation in an authentication flow. The endpoint validates the submitted token's signature and association with the OAuth2 application but does not enforce that the credential is a refresh token before allowing token renewal. This behavior maps to CWE-287: Improper Authentication, because the system accepts a credential in a context where its intended authentication role has not been adequately verified.

Potential impact

  • An attacker may extend access beyond the original access-token lifetime
  • A valid access token could be exchanged for a new access token and refresh token
  • Compromised credentials could support longer-lived unauthorized access
  • Applications and user resources could remain accessible until tokens are revoked or otherwise invalidated
  • An attacker may extend access beyond the original access-token lifetime
  • A valid access token could be exchanged for a new access token and refresh token
  • Compromised credentials could support longer-lived unauthorized access
  • Applications and user resources could remain accessible until tokens are revoked or otherwise invalidated

General mitigation guidance

Mitigation generally focuses on enforcing token-type and grant-type separation throughout OAuth2 token processing.

Common defensive patterns include:

  • Accepting only credentials explicitly classified as refresh tokens for refresh-token grants
  • Applying strict server-side validation for token type, issuer, client, grant, audience, and lifecycle state
  • Using secure-by-default OAuth2 library and framework validation behavior
  • Reducing token lifetime and refresh-token scope where operationally appropriate
  • Protecting refresh tokens through secure storage, transport, rotation, and revocation controls
  • Applying least privilege to OAuth2 applications and issued token scopes

Mitigation generally focuses on enforcing token-type and grant-type separation throughout OAuth2 token processing.

Common defensive patterns include:

  • Accepting only credentials explicitly classified as refresh tokens for refresh-token grants
  • Applying strict server-side validation for token type, issuer, client, grant, audience, and lifecycle state
  • Using secure-by-default OAuth2 library and framework validation behavior
  • Reducing token lifetime and refresh-token scope where operationally appropriate
  • Protecting refresh tokens through secure storage, transport, rotation, and revocation controls
  • Applying least privilege to OAuth2 applications and issued token scopes

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static and dynamic tests that submit access tokens to refresh-token endpoints and verify rejection
  • Code review checks for token validation logic that confirms signatures but omits credential type
  • Test coverage for mismatched grant types, token classes, clients, issuers, and audiences
  • Monitoring for unusual refresh activity involving access-token identifiers or repeated token exchanges
  • Policy enforcement requiring explicit token-type checks before any token renewal operation

Automated security testing and code review tools may help identify inconsistent OAuth2 validation paths.

Organizations can look for this class of issue through:

  • Static and dynamic tests that submit access tokens to refresh-token endpoints and verify rejection
  • Code review checks for token validation logic that confirms signatures but omits credential type
  • Test coverage for mismatched grant types, token classes, clients, issuers, and audiences
  • Monitoring for unusual refresh activity involving access-token identifiers or repeated token exchanges
  • Policy enforcement requiring explicit token-type checks before any token renewal operation

Automated security testing and code review tools may help identify inconsistent OAuth2 validation paths.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-28.1.0/
github.comgithub.com/go-gitea/gitea/pull/39501
github.comgithub.com/go-gitea/gitea/pull/39507
github.comgithub.com/go-gitea/gitea/releases/tag/v28.1.0
github.comgithub.com/go-gitea/gitea/security/advisories/GHSA-469m-x4mw-38r3

Frequently asked

questions

It can be exercised remotely through the OAuth2 token endpoint when that endpoint is reachable and the attacker possesses an eligible unexpired access token.

The attacker generally needs possession of an access token issued for the same OAuth2 application and grant. No separate administrative access is necessarily required.

Enforce strict token-type validation so that only refresh tokens can be used with the refresh_token grant, while also validating client, grant, issuer, audience, and lifecycle attributes.

Maintain separate handling for access and refresh tokens, add negative tests for credential-type confusion, limit token lifetimes and scopes, and monitor unusual token-renewal behavior.

It can be exercised remotely through the OAuth2 token endpoint when that endpoint is reachable and the attacker possesses an eligible unexpired access token.

The attacker generally needs possession of an access token issued for the same OAuth2 application and grant. No separate administrative access is necessarily required.

Enforce strict token-type validation so that only refresh tokens can be used with the refresh_token grant, while also validating client, grant, issuer, audience, and lifecycle attributes.

Maintain separate handling for access and refresh tokens, add negative tests for credential-type confusion, limit token lifetimes and scopes, and monitor unusual token-renewal behavior.

Find out what's already
exploitable in your codebase.