The vulnerability is caused by two related issues in Gitea's API, allowing a public-only scoped token to access private organization data. First, the /api/v1/user/orgs endpoint was missing the checkTokenPublicOnly middleware in its route definition within the api.Routes function. This meant no public-only check was performed for that specific endpoint. Second, the api.checkTokenPublicOnly function itself contained a logical flaw. It used a switch statement that would only evaluate the first matching scope category for an endpoint, so if an endpoint had multiple categories (e.g., User and Organization), it would not check all of them, leading to incomplete validation. The handler for the endpoint, org.ListMyOrgs, also failed to filter results for public-only access. The fix involved adding the missing middleware to the route, correcting the logic in checkTokenPublicOnly to iterate through all scope categories, and ensuring the data retrieval in org.ListMyOrgs respects the public-only constraint.