Summary
A broken authorization check in Gitea's Git LFS lock handling allows users with write access to one repository to delete LFS locks that belong to other repositories.
Under certain conditions, this can enable unauthorized modification of large file workflows across projects, potentially disrupting builds, releases, or collaboration processes.
Affected context
This vulnerability arises in Gitea instances that:
- Use Git LFS (Large File Storage) and rely on LFS locks to coordinate changes to large files
- Allow users write access on one or more repositories
- Use shared Gitea infrastructure hosting multiple repositories for different projects or teams
The issue manifests when the application fails to correctly enforce that an LFS lock deletion request targets a lock belonging to the same repository as the requesting user's authorized scope.
Exploit preconditions
- Attack surface: Gitea HTTP/HTTPS API or UI endpoints responsible for Git LFS lock management.
- Required access: Valid account on the Gitea instance with write permissions to at least one repository that uses Git LFS.
- Trigger point: Submission of a lock deletion request that references an LFS lock associated with a different repository than the one the attacker legitimately controls.
- Why exploitation is possible: The server-side authorization logic checks that the user has sufficient privileges to delete some lock, but does not strictly bind the lock to the repository for which the user has write access, leading to a cross-repository authorization bypass (CWE-284, CWE-639).
Why this happens
The root cause is incomplete authorization enforcement on LFS lock deletion endpoints.
Instead of verifying both:
- The user's permission on the specific repository, and
- The association of the LFS lock with that same repository,
the implementation only partially validates access.
This matches CWE-284: Improper Access Control and CWE-639: Authorization Bypass Through User-Controlled Key, where identifiers or resource references (e.g., lock IDs) can be manipulated to operate on resources outside the intended authorization scope.
In abstract terms, the system trusts a client-supplied identifier for a protected resource without re-checking that the resource belongs to the context (repository) for which the user is authorized.
Potential impact
- Attackers with write access to one repository could delete LFS locks belonging to unrelated repositories.
- Disruption of workflows where LFS locks are used to coordinate exclusive edits to large files.
- Potential data integrity issues if teams rely on locks to prevent concurrent modifications or conflicting updates.
- Interference with CI/CD pipelines or release processes that depend on predictable LFS lock states.
- Erosion of separation between projects or tenants hosted on the same Gitea instance.
General mitigation guidance
Mitigations generally focus on tightening authorization boundaries and validating resource ownership:
- Ensure that every LFS lock operation (create, list, update, delete) enforces repository-scoped authorization checks, verifying that the lock belongs to the repository on which the user is acting.
- Use server-side lookups of locks by ID in combination with repository context, instead of trusting client-supplied identifiers alone.
- Apply a consistent access-control layer around Git LFS endpoints that mirrors the permission model for repositories (e.g., owner, collaborator with write access).
- Limit overly broad permissions and avoid granting write access where read-only access is sufficient.
- Where possible, apply defense-in-depth controls such as audit logging and rate limiting on sensitive operations like lock deletions.
How teams detect issues like this
Organizations can detect this class of vulnerability and its potential abuse using:
- Static analysis: Rules or patterns looking for authorization checks that validate user permissions but not resource ownership (e.g., operations using a global ID without accompanying repository or tenant checks).
- Code review: Manual reviews of LFS-related handlers or controllers to confirm that each action uses repository-scoped queries and permission checks, and does not rely solely on client-supplied identifiers.
- Logging and monitoring: Enable detailed logs of LFS lock operations including acting user, repository, lock ID, and lock's actual repository; alert when the acting repository context and lock's repository differ.
- Automated policy enforcement: Integrate security checks into CI pipelines to flag new endpoints that perform state-changing actions on shared or cross-tenant resources without explicit scope validation.

