/

CVE-2026-118395

Severity:

HIGH RISK

(7.5)

Authorization Bypass (CWE-284) in Gitea Repository APIs

CVE-2026-118395

Deferred

Vulnerability type

Category:

Authorization Bypass

CWE:

CWE-284

Impact:

Unauthorized creation of private organizations and repositories

Severity:

HIGH RISK

(7.5)

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's public-only personal access tokens were still accepted by several API endpoints that create organizations or repositories, despite restrictions on creating private resources. A token with the necessary write scopes could therefore create private resources in permitted contexts, although it could not read the private repositories it created.

Affected context

The issue affects Gitea API operations for organization creation, organization repository creation, and repository generation from templates. The restriction was enforced on some repository-creation endpoints but not consistently across the related endpoints, so a public-only token with relevant write scopes could still create private resources where its owner had permission to do so. The token did not gain read access to the private repositories it created.

Exploit preconditions

  • Attack surface: Gitea API endpoints for creating organizations, creating organization repositories, and generating repositories from templates
  • Required access: A valid public-only personal access token with the write scopes required by the requested operation
  • Trigger point: A request to an affected creation endpoint
  • Why exploitation is possible: The affected endpoints did not consistently enforce the token's public-only resource restriction; organization and repository permissions still applied

Why this happens

Authorization checks for the public-only token restriction were inconsistent across API endpoints. Some creation routes enforced the restriction, while related routes accepted the same token for private-resource operations. This is an access-control enforcement weakness mapped to CWE-284: Improper Access Control. The issue concerns authorization policy applied to resource creation; it does not imply that the token could read the private repositories created.

Potential impact

  • A token holder could create private repositories in organizations where they were permitted to create repositories
  • A token holder could create private organizations if their token had the necessary scope and the operation was otherwise permitted
  • A token holder could generate private repositories from templates
  • Private resources created this way could increase storage or administration burden, though the token would not thereby gain access to read those repositories

General mitigation guidance

Defensive patterns include applying resource-visibility restrictions consistently at a shared authorization layer across all equivalent API operations. Treat token scope and resource visibility as separate authorization checks, and default to denying private-resource creation when a credential is restricted to public resources. Keep permissions narrowly scoped and limit who can create organizations or repositories.

How teams detect issues like this

  • Review API routes that create organizations or repositories and compare their authorization checks for consistency.
  • Use static analysis or code review to identify endpoint-specific checks that are missing or differ from shared policy.
  • Test authorization behavior across route aliases, repository-generation flows, and public-only tokens with relevant write scopes.
  • Monitor audit logs for private-resource creation by restricted tokens, and enforce policies that alert on or block such events.
  • Automated security review tools may help identify inconsistent access-control checks across related handlers.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-28.3.0/
github.comgithub.com/go-gitea/gitea/pull/39690
github.comgithub.com/go-gitea/gitea/pull/39853
github.comgithub.com/go-gitea/gitea/releases/tag/v28.3.0
github.comgithub.com/go-gitea/gitea/security/advisories/GHSA-x5v4-836g-f95x

Frequently asked

questions

If it has the required write scopes and the owner has the necessary permissions, it can use affected endpoints to create private organizations or repositories, including repositories generated from templates. It cannot read the private repositories it creates.

Yes. The caller needs a valid public-only personal access token with the scopes required for the requested operation. The relevant endpoint must also permit the token owner to create the resource.

Apply the public-only restriction consistently in a shared authorization layer for every operation that can create or generate private resources, and deny by default when the restriction is not explicitly satisfied.

Maintain authorization tests across related endpoints and route aliases, including checks for token scopes and resource visibility. Review changes to API handlers for policy consistency and monitor creation events involving restricted credentials.

Find out what's already
exploitable in your codebase.