/

CVE-2026-120263

Severity:

CRITICAL RISK

(9.8)

Account Linking Flaw (CWE-287) in Gitea OAuth2 Login

CVE-2026-120263

Deferred

Vulnerability type

Category:

Authentication Bypass

CWE:

CWE-287, CWE-639

Impact:

Account Takeover

Severity:

CRITICAL RISK

(9.8)

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

When Gitea's non-default automatic account-linking mode is enabled alongside registration, the linking flow can trust a name or email entered in the form instead of verifying it against the OAuth2 provider's identity. An attacker with an account at a configured provider could link their identity to another Gitea user and sign in as that user, potentially including an administrator.

Affected context

The issue applies when [oauth2_client].ACCOUNT_LINKING is set to auto and registration is enabled. During OAuth2 sign-up and account linking, the form could use user-submitted name or email details to select an existing Gitea account rather than requiring a match with the identity asserted by the provider. A successful link persists for later sign-ins.

Exploit preconditions

  • Attack surface: Gitea's OAuth2 account-linking and registration flow
  • Required access: An account with a configured OAuth2 provider; no victim password is required
  • Configuration: Automatic account linking is enabled and registration is enabled
  • Trigger point: The attacker submits the account-linking form with another user's name or email
  • Why exploitation is possible: The existing account was selected using submitted form data rather than a verified provider identity

Why this happens

The linking flow treated user-controlled identity fields as authoritative when selecting an existing account. Because it did not require the selected account to match the email or provider-derived user name asserted by the OAuth2 provider, an attacker could associate their own external identity with another user's account. This is an authentication weakness (CWE-287) and can also involve authorization bypass through a user-controlled account identifier (CWE-639).

Potential impact

  • An attacker could sign in as another Gitea user without knowing that user's password.
  • A compromised account could expose private repositories or other account data.
  • An attacker could gain administrator-level access if a privileged account is linked.
  • The unauthorized link could enable continued access through later OAuth2 sign-ins.

General mitigation guidance

Defensive patterns include verifying account ownership using identity attributes asserted by the OAuth2 provider, rather than trusting names or email addresses submitted in a form. Automatic linking can be disabled by default or replaced with an explicit account-ownership check, such as requiring the existing account's password or an authenticated session. Validate provider identity claims, minimize trust in user-controlled linking inputs, and apply least privilege to accounts and OAuth2 integrations.

How teams detect issues like this

Review account-linking code for lookups that use form-supplied names, emails, or account identifiers without confirming them against trusted provider claims. Static analysis and code review can flag flows where user-controlled values determine an authenticated account. Monitor account-link events for mismatches between provider identity claims and the linked Gitea account, and enforce policies requiring verified identity matching or explicit proof of existing-account ownership.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-28.3.0/
github.comgithub.com/go-gitea/gitea/pull/40121
github.comgithub.com/go-gitea/gitea/pull/40137
github.comgithub.com/go-gitea/gitea/releases/tag/v28.3.0
github.comgithub.com/go-gitea/gitea/security/advisories/GHSA-8p3x-w464-4g6v

Frequently asked

questions

An attacker needs an account with an OAuth2 provider configured for the Gitea instance. The vulnerable automatic-linking and registration settings must also be enabled.

No. The flaw allowed an attacker to link their own provider identity to another user's Gitea account without knowing its password.

Link an existing account only after verifying that its identity matches trusted claims from the OAuth2 provider, or require proof of ownership of the existing account.

Treat form-submitted identity details as untrusted, validate identity claims at authentication boundaries, and review account-linking policies for secure defaults.

Find out what's already
exploitable in your codebase.