/

CVE-2026-20912

Severity:

CRITICAL RISK

(9.1)

Improper Access Control in Gitea Repository Ownership Checks

CVE-2026-20912

Modified

Vulnerability type

Category:

Improper Access Control

CWE:

CWE-284, CWE-639, CWE-283

Impact:

Unauthorized Access to Private Repository Attachments

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 contains an access control flaw where repository ownership is not properly validated when linking attachments to releases. This can allow an attachment originally uploaded to a private repository to be linked to a release in a different public repository, unintentionally exposing private content to unauthorized users.

The issue becomes risky in multi-repository environments where users can create releases and manage attachments across both private and public projects, especially when sensitive files are stored as release assets.

Affected context

This vulnerability affects Gitea instances where:

  • Users can host both private and public repositories.
  • Attachments (e.g., binaries, logs, artifacts) are uploaded and later linked to releases.
  • The underlying implementation allows attachments to be reassigned or linked across repositories without re-validating that the attachment and target release belong to the same owner/repository context.

It is most relevant in collaborative setups where multiple users manage releases and where private repositories store sensitive artifacts as attachments.

Exploit preconditions

  • Attack surface: Gitea web UI or API endpoints that handle release creation/editing and attachment linking.
  • Required access: Ability to:
  • Upload attachments to at least one private repository, and
  • Create or edit releases in another repository that is public (or has broader visibility).
  • Trigger point: The attacker links or assigns an attachment from a private repository to a release in a public repository by leveraging the flawed ownership check.
  • Why exploitation is possible: The system trusts attachment identifiers or metadata without strictly confirming that the attachment belongs to the same repository or that the acting user is authorized to expose it in the target repository, corresponding to broken authorization logic (CWE-284) and improper authorization based on user-controlled identifiers (CWE-639).

Why this happens

The root cause is an authorization logic defect where attachment-repository relationships are not consistently validated when linking attachments to releases. Instead of deriving authorization from the current repository and the attachment's original repository ownership, the implementation appears to rely on:

  • An attachment identifier or reference that can be reused across repositories, and
  • Insufficient checks to ensure that the attachment's source repository has compatible visibility with the target repository.

This maps to CWE-284: Improper Access Control, as the system does not enforce correct permissions when exposing attachments, and CWE-639: Authorization Bypass Through User-Controlled Key, since a user can select or reference an attachment ID to bypass proper per-resource ownership checks.

Potential impact

  • Private attachments may be exposed via public releases and downloaded by anyone with access to the public repository.
  • Leakage of sensitive build artifacts, configuration files, logs, test datasets, or proprietary binaries stored as release assets.
  • Indirect disclosure of internal project structure, file naming conventions, and deployment practices.
  • Compliance or data protection violations if confidential or regulated data is stored as attachments.
  • Erosion of trust in the integrity and confidentiality of private repositories and their artifacts.

General mitigation guidance

Effective mitigation focuses on enforcing strict, context-aware authorization whenever attachments are associated with releases:

  • Ensure that every attachment-linking operation verifies that the attachment and the target release belong to the same repository (or to repositories with explicitly compatible visibility rules).
  • Derive authorization from the current repository context rather than trusting user-supplied attachment identifiers or paths.
  • Restrict attachment reuse across repositories, or require explicit secure transfer logic with full permission and visibility checks.
  • Apply least-privilege principles to release management capabilities, limiting who can upload, link, or reassign attachments.
  • Introduce secure defaults so that attachments created in private repositories are treated as private by default and cannot be referenced from public contexts without additional, validated steps.
  • Implement defense-in-depth by centralizing access control decisions in a shared authorization layer, rather than scattering checks across handlers or controllers.

How teams detect issues like this

Detection generally combines code-centric and operational approaches:

  • Static analysis & code review:
  • Look for controller or handler code that links attachments to releases without re-checking repository ownership or visibility.
  • Flag patterns where authorization is based purely on attachment IDs, query parameters, or user-controlled keys, rather than entity relationships.
  • Enforce review checklists that explicitly ask whether cross-repository resource sharing is possible and how it is controlled.
  • Policy and automated checks:
  • Add tests that attempt to link an attachment from a private repository to a public repository and verify that it fails.
  • Use automated security testing or API fuzzing to try cross-context resource linkage and observe access control behavior.
  • Runtime monitoring:
  • Log attachment creation, reassignment, and download events with repository context and user identifiers.
  • Monitor for unusual patterns such as attachments originating from private repositories being downloaded frequently from public endpoints.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-1.25.4/
github.comgithub.com/go-gitea/gitea/pull/36320
github.comgithub.com/go-gitea/gitea/pull/36355
github.comgithub.com/go-gitea/gitea/releases/tag/v1.25.4
github.comgithub.com/go-gitea/gitea/security/advisories/GHSA-vfmv-f93v-37mw
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-20912
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2432219
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-20912.json

Frequently asked

questions

Yes, it can typically be exploited remotely via the Gitea web interface or API, as long as the attacker has legitimate access to at least one private repository and the ability to manage releases in another repository with broader visibility.

The attacker generally needs authenticated access that allows them to upload attachments in a private repository and create or edit releases in a public (or more widely visible) repository. They do not need administrative access to the server itself.

The most robust fix is to enforce strict, centralized authorization for attachment operations: always verify that the attachment's original repository is compatible with the target release's repository and that the acting user has permission to expose the attachment in that context. Avoid trusting raw attachment IDs or user-supplied keys without contextual checks.

Future prevention involves designing APIs and data models so that every access to cross-referenced resources (attachments, releases, repositories) passes through a common authorization layer. Combine this with security-focused code reviews, automated tests for cross-repository access scenarios, and clear guidelines that any user-controlled identifier must be revalidated against ownership and visibility constraints.

Find out what's already
exploitable in your codebase.