Summary
An authorization flaw in Gitea allows API users to fork repositories into organizations without passing the intended CanCreateOrgRepo permission check.
Under certain configurations, this missing access control can expose organization-level secrets and internal project data to unauthorized users.
Affected context
This vulnerability appears in Gitea deployments where:
- API access is enabled for users who can fork repositories
- Organizations host repositories with restricted access or sensitive secrets
- The API endpoint handling repository forks into organizations fails to enforce the CanCreateOrgRepo permission check
It is most relevant in multi-tenant environments or instances where organizations rely on fine-grained permissions to protect internal code and configuration.
Exploit preconditions
- Attack surface: Gitea HTTP(S) API endpoint responsible for forking repositories into organizations
- Required access: Valid Gitea user account with general ability to fork repositories, but without explicit permission to create repositories in the target organization
- Trigger point: Calling the fork-to-organization API endpoint and specifying a target organization where the user should not be able to create repositories
- Why exploitation is possible: The API path lacks a strict enforcement of the CanCreateOrgRepo authorization check, allowing repository creation in an organization context without confirming the user's rights for that organization
Why this happens
The underlying issue is an improper access control implementation where authorization checks are incomplete or inconsistently applied for a specific API workflow.
The code path that processes repository forks into organizations does not reliably invoke or enforce the CanCreateOrgRepo check, meaning it trusts the request's parameters instead of validating the caller's organization-level permissions.
This aligns with CWE-284: Improper Access Control, in which security-critical operations are exposed without proper verification that the actor has the necessary privileges for the target resource.
Potential impact
- Unauthorized creation of repositories inside organizations where the user should not have repository creation rights
- Exposure of organization secrets or configuration stored in repository content, hooks, or CI/CD configuration
- Leakage of internal source code and intellectual property to users with lower privilege levels
- Expansion of an attacker's foothold within a Gitea instance by gaining visibility into private organizational projects
General mitigation guidance
Mitigation generally centers on enforcing consistent authorization for every path that creates or modifies organization resources.
Common defensive patterns include:
- Ensuring all repository creation flows call a central permission-check function that validates organization-level rights (such as CanCreateOrgRepo)
- Avoiding duplicate or ad hoc authorization logic for web UI and API, instead consolidating checks into reusable, testable modules
- Applying defense-in-depth by verifying permissions both at the controller/handler layer and within lower-level service functions
- Designing organization-level policies so that default permissions are restrictive, limiting collateral exposure if a check is missed
- Logging and monitoring permission-sensitive operations, such as repository creation within organizations, to detect misuse patterns
How teams detect issues like this
Detection efforts can focus on both code-level and operational signals:
- Static analysis or code review rules that flag resource-creation endpoints missing explicit authorization checks
- Architectural reviews that verify organization operations (create, fork, transfer) all traverse shared authorization routines
- Runtime monitoring of API calls that create repositories, correlating them with the caller's known organization permissions to spot anomalies
- Periodic audits of organization repositories and membership, checking for unexpected repositories or owners that may indicate abuse
Automated security review tools and policy-as-code frameworks can help enforce that all API handlers performing organization-scoped actions declare and invoke the required permission checks.

