Summary
The organization repository deletion endpoint did not enforce the public-only restriction on access tokens, checking only whether the organization was public. As a result, an owner using a public-only token could permanently delete private repositories in that organization.
Affected context
The issue occurs in the DELETE /api/v1/orgs/{org}/repos API route when authorization checks consider the organization's visibility but do not also enforce the token's access restrictions. It is risky when a public-only token belonging to an organization owner can reach the route while the organization contains private repositories.
Exploit preconditions
- Attack surface: The organization repository deletion API
- Required access: A valid public-only access token belonging to an owner of a public organization
- Trigger point: A request to delete all repositories for that organization
- Why exploitation is possible: The route checked that the organization was public but did not enforce the token's public-only restriction for private repositories
Why this happens
The route applied an incomplete authorization check: it verified an organization-level property without checking whether the token was permitted to act on each affected repository. This is an authorization enforcement failure mapped to CWE-863: Incorrect Authorization, because access controls did not correctly restrict an operation on private resources.
Potential impact
- Private repositories may be permanently deleted without the token being authorized to reach them
- Organizations could lose repository content, history, or related work
- Recovery efforts may require backups and could disrupt development workflows
General mitigation guidance
Defensive patterns include evaluating authorization against every resource affected by a bulk operation, rather than relying only on organization-level visibility. Treat token scopes and resource visibility as separate constraints, deny access by default when either check fails, and limit deletion privileges to the minimum required. Where practical, use safeguards such as explicit confirmation and recoverable deletion mechanisms for destructive operations.
How teams detect issues like this
- Review routes that perform bulk operations for checks against every affected resource
- Use static analysis or code review to identify authorization decisions based only on parent-resource visibility
- Add policy and integration tests covering restricted tokens, private resources, and destructive actions
- Monitor audit logs for bulk deletion requests made with tokens that have limited scopes

