/

CVE-2026-20706

Severity:

CRITICAL RISK

(9.1)

Authorization Bypass (CWE-284) in Gitea Archive Endpoint

CVE-2026-20706

Deferred

Vulnerability type

Category:

Improper Access Control

CWE:

CWE-284

Impact:

Unauthorized Repository Data Access

Severity:

CRITICAL RISK

(9.1)

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

Gitea allows repository archive downloads to bypass token scope checks on the web archive download endpoint.

As a result, an attacker holding a token with limited or unrelated scopes may still be able to download repository archives, exposing code and sensitive project assets.

Affected context

This vulnerability arises in Gitea deployments that rely on scoped access tokens to control repository-level operations.

It manifests specifically on the web archive download endpoint used to retrieve compressed snapshots (e.g., ZIP/TAR) of repositories.

When scope checks are incomplete or missing, tokens intended for restricted operations can become effectively over-privileged in the context of archive downloads, increasing exposure of source code and related files.

Exploit preconditions

  • Attack surface: Gitea HTTP(S) web interface, particularly the repository archive download endpoint.
  • Required access: Possession of any valid token or credential that can be presented to the endpoint; strict archive-related scopes are not properly enforced.
  • Trigger point: A request to download a repository archive via the affected endpoint using a token that should not have archive/download permissions.
  • Why exploitation is possible: The authorization layer does not correctly enforce or validate token scopes for archive downloads, allowing tokens to perform actions beyond their intended privileges.

Why this happens

The issue reflects a classic improper access control pattern where authorization checks are incomplete or inconsistently applied for a specific operation.

In the affected Gitea endpoint, the logic that validates token scopes fails to ensure that only tokens with the appropriate permissions can download repository archives.

This maps to CWE-284: Improper Access Control, where the system does not consistently enforce the declared authorization policy, resulting in an unintended privilege extension for archive download operations.

Potential impact

  • Unauthorized download of private or internal repository archives.
  • Exposure of proprietary source code and intellectual property.
  • Leakage of configuration files, credentials, or secrets stored in the repository.
  • Facilitation of further attacks via code analysis, dependency enumeration, or discovery of infrastructure details.
  • Increased risk of data exfiltration and compliance violations.

General mitigation guidance

Mitigation typically focuses on ensuring that access control logic is consistent, centralized, and scope-aware for every endpoint that serves sensitive content.

Recommended patterns include:

  • Implement a unified authorization layer that enforces token scopes and repository permissions for all data access paths, including archive endpoints.
  • Treat any operation that returns bulk repository data (archives, clones, or exports) as high-privilege and require explicit, appropriate scopes.
  • Design tokens and scopes with least privilege in mind, avoiding broad or catch-all scopes where possible.
  • Regularly review access control rules, especially for convenience features like web-based downloads, to confirm they adhere to the same policies as core APIs.
  • Apply defense-in-depth by restricting network exposure of administration interfaces and enforcing strong authentication around token issuance and management.

How teams detect issues like this

Detection can leverage both code-centric and operational approaches:

  • Perform targeted code reviews to confirm that every endpoint returning repository data consults a shared authorization mechanism and validates token scopes.
  • Use static analysis or policy-as-code tools to flag routes or controllers that bypass standard auth middleware or contain custom authorization logic.
  • Enable detailed access logging for archive downloads and monitor for unusual patterns, such as tokens with minimal scopes performing large or frequent archive fetches.
  • Integrate security tests into CI/CD that exercise endpoints with tokens of varying scopes to verify that over-privileged behavior is not possible.
  • Periodically audit issued tokens, their scopes, and associated activity to identify potential scope misuse or unexpected access paths.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-1.26.2/
github.comgithub.com/go-gitea/gitea/pull/37735
github.comgithub.com/go-gitea/gitea/releases/tag/v1.26.2
github.comgithub.com/go-gitea/gitea/security/advisories/GHSA-cr4g-f395-h25h

Frequently asked

questions

It primarily affects scenarios where repositories are intended to be restricted, such as private or internal projects. Public repositories are generally already accessible, so the risk is more about unintended access to non-public code.

An attacker needs access to a valid token or credential that can be presented to the archive download endpoint. Because scope enforcement is flawed, even tokens with limited or unrelated scopes may be able to fetch repository archives.

The most robust fix is to centralize authorization checks and ensure that all endpoints, especially those providing bulk data access, strictly validate token scopes and repository permissions using a common, well-reviewed mechanism.

Prevention relies on designing and enforcing a consistent access control model, using shared middleware for auth checks, thoroughly testing endpoints for scope adherence, and incorporating authorization-focused reviews and automated checks into the development lifecycle.

Find out what's already
exploitable in your codebase.