CVE-2026-28699: Gitea Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-9r5x-wg6m-x2rc
CVSS 8.1
CWE-284 CWE-863
Published
Advisory Summary

CVE-2026-28699 is a HIGH (CVSS 8.1) remote code execution vulnerability (CWE-284: Improper Access Control) affecting Gitea libraries in the Go ecosystem. The issue involves oauth2 access token scope enforcement bypass via http basic authentication. Remediation is available by upgrading affected packages to version 1.26.2.

CVE-2026-28699 at a Glance

CVE Identifier CVE-2026-28699
GHSA Identifier GHSA-9r5x-wg6m-x2rc
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-284: Improper Access Control
Affected Product Gitea
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-28699

To remediate this vulnerability, upgrade all affected Gitea dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

code.gitea.io/gitea fixed: 1.26.2
Upgrade code.gitea.io/gitea to 1.26.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for code.gitea.io/gitea

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-28699, inspect your project dependencies for Gitea:

inspect dependencies for code.gitea.io/gitea

Analyze the terminal output to locate any version of Gitea in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.26.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. In Gitea, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary Gitea fails to enforce OAuth2 access token scopes when the token is submitted via HTTP Basic authentication instead of a Bearer token. An OAuth2 application granted only `read:user` can use the same token as `Authorization: Basic base64(<token>:x-oauth-basic)` and perform write actions, including modifying profiles, adding email addresses, creating repositories, and deleting repositories as the authorizing user. ### Details **Root cause:** `services/auth/basic.go` accepts OAuth2 access tokens through the Basic auth path but does not store the token scope in the request context: ```go // services/auth/basic.go if uid != 0 { store.GetData()["LoginMethod"] = OAuth2TokenMethodName store.GetData()["IsApiToken"] = true // scope is NOT set return u, nil } ``` The scope enforcement middleware in `routers/api/v1/api.go` exits early when `ApiTokenScope` is absent: ```go // routers/api/v1/api.go — tokenRequiresScopes scope, scopeExists := ctx.Data["ApiTokenScope"].(auth_model.AccessTokenScope) if ctx.Data["IsApiToken"] != true || !scopeExists { return //<- exits without checking scope, all actions permitted } ``` When a token arrives via Bearer, `ApiTokenScope` is populated and scope checks apply normally. When the same token arrives via Basic auth, `ApiTokenScope` is never set, so `tokenRequiresScopes` returns immediately and no scope is enforced. **Suggested fix:** When an OAuth2 access token is accepted in `services/auth/basic.go`, populate `ApiTokenScope` in the request context identically to the Bearer-token OAuth2 path. ### PoC 1. Create an OAuth2 application in Gitea. 2. Authorize it as a normal user with scope `read:user` only. 3. Take the resulting access token and call a write endpoint both ways: **Bearer | correctly blocked:** ``` Authorization: Bearer <token> PATCH /api/v1/user/settings -> 403 Forbidden ``` **Basic | bypass:** ``` Authorization: Basic base64(<token>:x-oauth-basic) PATCH /api/v1/user/settings -> 200 OK ``` **All verified bypass endpoints using a `read:user`-only token:** | Endpoint | Bearer | Basic | |---|---|---| | `PATCH /api/v1/user/settings` | 403 | 200 | | `POST /api/v1/user/emails` | 403 | 200 | | `POST /api/v1/user/repos` | 403 | 200 | | `PATCH /api/v1/repos/{owner}/{repo}` | 403 | 200 | | `DELETE /api/v1/repos/{owner}/{repo}` | 403 | 200 | The bypass respects the user's normal repository permissions, it does not grant access to repositories the user cannot otherwise reach, and does not escalate to admin. ### Impact Any OAuth2 application with any restricted scope can silently operate beyond its granted permissions by switching from Bearer to Basic auth. An attacker who obtains a token (e.g. via a malicious OAuth2 app a user authorized) can: - Modify the victim's profile and settings - Add attacker-controlled email addresses to the victim's account - Create repositories as the victim - Modify or delete the victim's private repositories The entire OAuth2 scope system is effectively bypassed for any token submitted via Basic auth.

CVE-2026-28699 Affected Gitea Versions

1 component(s)
Fixed Versions:
1.26.2
Product / Package Ecosystem Affected Versions Fixed Version
code.gitea.io/gitea
Go
< 1.26.2
1.26.2

References

Frequently Asked Questions

What is CVE-2026-28699?
CVE-2026-28699 is a security vulnerability in Gitea involving OAuth2 access token scope enforcement bypass via HTTP Basic authentication under CWE-284: Improper Access Control.
Which Gitea versions are affected?
Affected versions include releases prior to 1.26.2 across affected packages: code.gitea.io/gitea.
What version fixes CVE-2026-28699?
Upgrading to 1.26.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is code.gitea.io/gitea affected?
Yes, code.gitea.io/gitea is affected in releases prior to 1.26.2. Upgrade your dependency to 1.26.2 or later.
What is the CVSS score of CVE-2026-28699?
CVE-2026-28699 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-28699?
CVE-2026-28699 is classified under CWE-284: Improper Access Control (The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.).
How can I check Go dependencies for CVE-2026-28699?
Run the dependency tree command: 'inspect dependencies for code.gitea.io/gitea'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9r5x-wg6m-x2rc",
  "modified" : "2026-06-16T23:40:34Z",
  "published" : "2026-06-16T23:40:34Z",
  "aliases" : [ "CVE-2026-28699" ],
  "summary" : "Gitea: OAuth2 access token scope enforcement bypass via HTTP Basic authentication",
  "details" : "### Summary\n\nGitea fails to enforce OAuth2 access token scopes when the token is submitted via HTTP Basic authentication instead of a Bearer token. An OAuth2 application granted only `read:user` can use the same token as `Authorization: Basic base64(<token>:x-oauth-basic)` and perform write actions, including modifying profiles, adding email addresses, creating repositories, and deleting repositories as the authorizing user.\n\n### Details\n\n**Root cause:** `services/auth/basic.go` accepts OAuth2 access tokens through the Basic auth path but does not store the token scope in the request context:\n\n```go\n// services/auth/basic.go\nif uid != 0 {\n    store.GetData()[\"LoginMethod\"] = OAuth2TokenMethodName\n    store.GetData()[\"IsApiToken\"] = true   // scope is NOT set\n    return u, nil\n}\n```\n\nThe scope enforcement middleware in `routers/api/v1/api.go` exits early when `ApiTokenScope` is absent:\n\n```go\n// routers/api/v1/api.go — tokenRequiresScopes\nscope, scopeExists := ctx.Data[\"ApiTokenScope\"].(auth_model.AccessTokenScope)\nif ctx.Data[\"IsApiToken\"] != true || !scopeExists {\n    return   //<- exits without checking scope, all actions permitted\n}\n```\n\nWhen a token arrives via Bearer, `ApiTokenScope` is populated and scope checks apply normally. When the same token arrives via Basic auth, `ApiTokenScope` is never set, so `tokenRequiresScopes` returns immediately and no scope is enforced.\n\n**Suggested fix:** When an OAuth2 access token is accepted in `services/auth/basic.go`, populate `ApiTokenScope` in the request context identically to the Bearer-token OAuth2 path.\n\n### PoC\n\n1. Create an OAuth2 application in Gitea.\n2. Authorize it as a normal user with scope `read:user` only.\n3. Take the resulting access token and call a write endpoint both ways:\n\n**Bearer | correctly blocked:**\n```\nAuthorization: Bearer <token>\nPATCH /api/v1/user/settings  ->  403 Forbidden\n```\n\n**Basic | bypass:**\n```\nAuthorization: Basic base64(<token>:x-oauth-basic)\nPATCH /api/v1/user/settings  ->  200 OK\n```\n\n**All verified bypass endpoints using a `read:user`-only token:**\n\n| Endpoint | Bearer | Basic |\n|---|---|---|\n| `PATCH /api/v1/user/settings` | 403 | 200 |\n| `POST /api/v1/user/emails` | 403 | 200 |\n| `POST /api/v1/user/repos` | 403 | 200 |\n| `PATCH /api/v1/repos/{owner}/{repo}` | 403 | 200 |\n| `DELETE /api/v1/repos/{owner}/{repo}` | 403 | 200 |\n\nThe bypass respects the user's normal repository permissions, it does not grant access to repositories the user cannot otherwise reach, and does not escalate to admin.\n\n### Impact\n\nAny OAuth2 application with any restricted scope can silently operate beyond its granted permissions by switching from Bearer to Basic auth. An attacker who obtains a token (e.g. via a malicious OAuth2 app a user authorized) can:\n\n- Modify the victim's profile and settings\n- Add attacker-controlled email addresses to the victim's account\n- Create repositories as the victim\n- Modify or delete the victim's private repositories\n\nThe entire OAuth2 scope system is effectively bypassed for any token submitted via Basic auth.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "code.gitea.io/gitea"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.26.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.26.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/go-gitea/gitea/security/advisories/GHSA-9r5x-wg6m-x2rc"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/go-gitea/gitea"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-284", "CWE-863" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-16T23:40:34Z",
    "nvd_published_at" : null
  }
}