GitHub Advisory Database
GHSA-5qhx-gwfj-6jqr
Gogs user can update repository content with read-only permission
Details
Vulnerability Description
The endpoint PUT /repos/:owner/:repo/contents/* does not require write permissions and allows access with read permission only via repoAssignment().
After passing the permission check, PutContents() invokes UpdateRepoFile(), which results in:
- Commit creation
- Execution of
git push
As a result, a token with read-only permission can be used to modify repository contents.
---
Attack Prerequisites
- Possession of a valid access token
- Read permission on the target repository
(public repository or collaborator with read access)
---
Attack Scenario
- The attacker accesses the target repository with a read-only token
- The attacker sends a
PUT /contentsrequest to update an arbitrary file - The server creates a commit and performs a git push on behalf of the attacker
---
Potential Impact
- Source code tampering
- Injection of backdoors
- Compromise of release artifacts and distributed packages
Affected packages
| Ecosystem | Package | Affected versions |
|---|---|---|
| Go | gogs.io/gogs | All versions before 0.13.4 (fixed in 0.13.4) |