The vulnerability lies in the incorrect authorization checks for public-only personal access tokens (PATs) when accessing repositories or packages owned by users or organizations with Limited visibility. The affected functions were using IsPrivate() to check for visibility, which evaluates to false for Limited visibility, thus bypassing the intended restrictions of the public-only scope. An attacker with a public-only token could access repositories and packages that were not public, but internal to the Gitea instance. The fix, identified in commit de4b8277e9cb576f2315fb03b5ab6478b42a1d31, replaces the IsPrivate() checks with !IsPublic(). This ensures that public-only tokens can only access resources that are truly public, and not those with Limited or Private visibility, correctly enforcing the security model.