CVE-2026-20706: Gitea Token Scope Bypass On Web Vulnerability
MODERATECVE-2026-20706 is a MODERATE token scope bypass on web vulnerability (CWE-863: Incorrect Authorization) affecting Gitea libraries in the Go ecosystem. The issue involves token scope bypass on web archive download endpoint. Remediation is available by upgrading affected packages to version 1.26.2.
CVE-2026-20706 at a Glance
How to Fix CVE-2026-20706
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.
Upgrade code.gitea.io/gitea to 1.26.2
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-20706, 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-863: Incorrect Authorization, where the product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. 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
CVE-2026-20706 Affected Gitea Versions
1 component(s)| 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-20706?
Which Gitea versions are affected?
What version fixes CVE-2026-20706?
Is code.gitea.io/gitea affected?
What CWE is associated with CVE-2026-20706?
How can I check Go dependencies for CVE-2026-20706?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-cr4g-f395-h25h",
"modified" : "2026-06-16T23:42:04Z",
"published" : "2026-06-16T23:42:04Z",
"aliases" : [ "CVE-2026-20706" ],
"summary" : "Gitea: Token scope bypass on web archive download endpoint",
"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.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA: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-cr4g-f395-h25h"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/go-gitea/gitea"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-863" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-06-16T23:42:04Z",
"nvd_published_at" : null
}
}