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.

