/

CVE-2026-26247

Severity:

CRITICAL RISK

(9.1)

OAuth2 PKCE S256 Bypass (CWE-284) in Gitea Auth Flow

CVE-2026-26247

Deferred

Vulnerability type

Category:

Authorization and Access Control

CWE:

CWE-284

Impact:

Authorization Bypass and Token Misuse

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 implementation fails to correctly persist the PKCE S256 challenge method, allowing an authorization code to be exchanged for a token without enforcing the expected verifier check.

In deployments that rely on PKCE for additional authorization protection, this flaw can let an attacker bypass the intended proof-of-possession step and gain tokens under certain conditions.

Affected context

The vulnerability appears in Gitea instances that act as an OAuth2 authorization server and advertise support for PKCE with the S256 method.

It is most relevant where clients and operators assume that PKCE is correctly enforced as a second layer of defense beyond client secrets, particularly for public or mobile clients.

The issue manifests during the OAuth2 authorization code flow, where the PKCE method is not reliably persisted or enforced between the authorization request and the token exchange.

Exploit preconditions

  • Attack surface: OAuth2 authorization and token endpoints exposed by a Gitea server.
  • Required access: Ability to initiate OAuth2 authorization code flows against the affected Gitea instance (e.g., as a legitimate or semi-trusted client).
  • Trigger point: The attacker completes an authorization request with PKCE parameters and later performs a token exchange that is processed without the expected S256 verifier validation.
  • Why exploitation is possible: The PKCE challenge method is not consistently stored or re-applied, so the server may accept a token request without correctly validating the code verifier, weakening or bypassing the intended proof-of-key possession requirement.

Why this happens

This flaw stems from incomplete enforcement of authorization controls in the OAuth2 PKCE implementation.

Instead of treating the PKCE S256 challenge method and verifier as mandatory, coupled state that must be validated throughout the entire authorization code flow, the server fails to reliably persist or re-check the declared challenge method at token exchange time.

Conceptually, this maps to CWE-284: Improper Access Control, because the system assumes PKCE-based proof-of-possession but does not consistently enforce it, allowing tokens to be issued under weaker or missing verification constraints.

Potential impact

  • An attacker may obtain access tokens without presenting a valid PKCE verifier when the flow is mis-enforced.
  • OAuth2 clients that rely on PKCE for protection of public clients may experience reduced security guarantees.
  • Session hijacking or impersonation may become more feasible if authorization codes can be exchanged by parties that did not prove possession of the correct key material.
  • Broader compromise of Gitea-hosted resources may occur if tokens issued under weak verification are used to access repositories or APIs.

General mitigation guidance

Mitigation generally focuses on strengthening and simplifying authorization flows and access control enforcement.

Recommended patterns include:

  • Treat PKCE challenge method and verifier as required, immutable state across the authorization and token exchange steps.
  • Design authorization servers so that any declared PKCE parameters are always validated before issuing tokens, failing closed on inconsistent or missing values.
  • Adopt a defense-in-depth approach, combining PKCE with robust client identification, scoped tokens, and least-privilege access policies.
  • Minimize trust in user-controllable OAuth2 parameters by validating them against whitelisted or server-controlled expectations.
  • Regularly review and test authentication and authorization flows, including edge cases and error-handling paths, to ensure controls are consistently applied.

How teams detect issues like this

Detection often involves reviewing both configuration and implementation of OAuth2 flows:

  • Perform code audits or static analysis focused on authorization and token issuance paths, ensuring that PKCE parameters and access control checks are enforced consistently.
  • Introduce automated tests that simulate OAuth2 flows with and without valid PKCE verifiers, verifying that token issuance fails when proof-of-possession is missing or malformed.
  • Use logging and monitoring to capture details of OAuth2 exchanges, including presence of PKCE parameters, and alert on anomalous patterns such as tokens issued without corresponding verifier checks.
  • Employ security testing tools or manual penetration testing targeted at the OAuth2 endpoints to discover inconsistencies in PKCE handling and authorization enforcement.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-1.25.5/
github.comgithub.com/go-gitea/gitea/pull/36462
github.comgithub.com/go-gitea/gitea/pull/36477
github.comgithub.com/go-gitea/gitea/releases/tag/v1.25.5

Frequently asked

questions

Yes. Any attacker who can reach the OAuth2 authorization and token endpoints can attempt to exploit the inconsistent PKCE enforcement, subject to how the Gitea instance and clients are configured.

The attacker generally needs the ability to initiate OAuth2 authorization code flows against the affected Gitea server. In many deployments, this can be done as an unauthenticated or low-privilege client, depending on how OAuth2 applications are exposed and registered.

The safest pattern is to enforce strict, consistent validation of PKCE parameters across the entire OAuth2 flow: persist the declared challenge method, require the corresponding verifier during token exchange, and reject any token request that lacks a matching verifier or presents inconsistent PKCE state.

Prevention relies on robust design and testing of authentication and authorization mechanisms: follow well-established OAuth2 and PKCE reference implementations, treat access control checks as centralized and mandatory, add automated tests for edge cases, and perform regular security reviews of authorization flows before deployment.

Find out what's already
exploitable in your codebase.