{"id":"CVE-2026-20706","aliases":["GHSA-cr4g-f395-h25h","GO-2026-5334"],"url":"https://o3.security/vulnerability/CVE-2026-20706","summary":"Gitea repository archive downloads bypass token scope checks","details":"## Summary\n\nPR #37698 added checkDownloadTokenScope to /raw/*, /media/*, and attachment download web endpoints. The /archive/* endpoint (repo.Download in routers/web/repo/repo.go:372) was not included in the fix. This endpoint accepts OAuth2 tokens via webAuth.AllowOAuth2 (registered at routers/web/web.go:1649-1652) but does not call checkDownloadTokenScope or CheckRepoScopedToken.\n\nA personal access token with any non-repository scope (e.g., read:issue or read:misc) can download full repository archives (zip/tar.gz) of private repositories the token owner has access to.\n\n## Impact\n\nScope escalation: tokens scoped to non-repository categories can access full repository content through the archive download endpoint. Higher impact than endpoints fixed in #37698 because /archive/* serves the entire repository.\n\n## Steps to Reproduce\n\n1. Create a personal access token with ONLY read:misc scope\n2. Access: GET /{owner}/{private-repo}/archive/main.tar.gz\n3. Archive is served (200 OK) instead of being rejected (403 Forbidden)\n\nCompare with fixed endpoints:\n- GET /{owner}/{private-repo}/raw/branch/main/README.md correctly returns 403\n\n## Root Cause\n\nDownload function in routers/web/repo/repo.go:372 does not call checkDownloadTokenScope. The outer group middleware reqUnitCodeReader checks repository permission but not token scope.\n\nThe API equivalent (/api/v1/repos/{owner}/{repo}/archive/*) IS properly scoped via tokenRequiresScopes(AccessTokenScopeCategoryRepository). The git HTTP endpoints are scoped via CheckRepoScopedToken in httpBase.\n\n## Suggested Fix\n\nAdd checkDownloadTokenScope(ctx) to Download and InitiateDownload in routers/web/repo/repo.go. The function already exists in routers/web/repo/download.go (same package).\n\n## Discovery Method\n\nVariant analysis of PR #37698 — reviewed all web routes with webAuth.AllowOAuth2 middleware.","published":"2026-07-03T20:19:28.868Z","modified":"2026-08-12T03:51:46.321942622Z","cvss":{"score":9.1,"severity":"CRITICAL","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"},"epss":{"score":0.00565,"percentile":0.44346,"asOf":"2026-08-24"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Go","name":"code.gitea.io/gitea","fixedVersion":"1.26.2"}],"fix":{"url":"https://github.com/go-gitea/gitea/pull/37735","label":"go-gitea/gitea#37735"},"references":[{"type":"ADVISORY","url":"https://blog.gitea.com/release-of-1.26.2/"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/20xxx/CVE-2026-20706.json"},{"type":"ADVISORY","url":"https://github.com/go-gitea/gitea/releases/tag/v1.26.2"},{"type":"ADVISORY","url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-cr4g-f395-h25h"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-20706"},{"type":"FIX","url":"https://github.com/go-gitea/gitea/pull/37735"},{"type":"PACKAGE","url":"https://github.com/go-gitea/gitea"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:46.321942622Z"}}