{"id":"CVE-2026-28699","aliases":["CVE-2026-28699","GHSA-9r5x-wg6m-x2rc","GO-2026-5299"],"related":[],"kind":"vulnerability","state":"published","title":"Gitea Basic Auth bypasses OAuth2 access token scopes","summary":"Gitea versions up to and including 1.26.1 allow OAuth2 access token scope enforcement to be bypassed through HTTP Basic authentication.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Gitea versions up to and including 1.26.1 allow OAuth2 access token scope enforcement to be bypassed through HTTP Basic authentication.","source":"cvelist"},{"lang":"en","text":"### 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.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Gitea: OAuth2 access token scope enforcement bypass via HTTP Basic authentication in code.gitea.io/gitea","format":"markdown","source":"go"},{"lang":"es","text":"Las versiones de Gitea hasta la 1.26.1 inclusive permiten que la aplicación del alcance del token de acceso OAuth2 sea eludida a través de la autenticación básica HTTP.","source":"nvd"}],"published":"2026-06-16T23:40:34.000Z","modified":"2026-10-25T15:10:00.147Z","severity":{"scorer":"Gitea","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"Gitea","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"}],"cwes":["CWE-284","CWE-863"],"affected":[{"ranges":[{"type":"semver","introduced":"0","lastAffected":"1.26.1","status":"affected"}],"vendor":"Gitea","product":"Gitea Open Source Git Server","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.26.2"}],"ecosystem":"Go","package":"code.gitea.io/gitea","purl":"pkg:golang/code.gitea.io/gitea","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.26.2"}],"ecosystem":"Go","package":"code.gitea.io/gitea","purl":"pkg:golang/code.gitea.io/gitea","source":"go"}],"references":[{"url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-9r5x-wg6m-x2rc","tags":["advisory","exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/go-gitea/gitea/pull/37503","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://github.com/go-gitea/gitea/releases/tag/v1.26.2","tags":["release-notes"],"sources":["cvelist","nvd"]},{"url":"https://blog.gitea.com/release-of-1.26.2/","tags":["release-notes"],"sources":["cvelist","nvd"]},{"url":"https://github.com/go-gitea/gitea","tags":["package"],"sources":["ghsa"]}],"credits":["Alardiians"],"assigner":"Gitea","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-07-06T15:18:36.564Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-28699","url":"https://www.cve.org/CVERecord?id=CVE-2026-28699","licence":"CVE Terms of Use","modified":"2026-07-06T15:18:39.782Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9r5x-wg6m-x2rc","url":"https://github.com/advisories/GHSA-9r5x-wg6m-x2rc","licence":"CC-BY-4.0","modified":"2026-06-25T19:56:25.925Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5299","url":"https://pkg.go.dev/vuln/GO-2026-5299","licence":"CC-BY-4.0","modified":"2026-06-25T19:45:30.548Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-28699","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-28699","licence":"Public domain","modified":"2026-10-25T15:10:00.147Z"}],"updatedAt":"2026-11-25T22:59:27.116Z","epss":{"score":0.00567,"percentile":0.48414,"date":"2026-12-02T12:00:21.000Z"}}