The vulnerability lies in an improper access control flaw within Gitea's attachment deletion functionality. A user who previously uploaded an attachment to a repository could delete it even after losing access to that repository. This was achieved by making a deletion request through a different repository where the user still held permissions, while referencing the unique identifier (UUID) of the target attachment.
The root cause was the system's failure to validate that the attachment being deleted was part of the repository context of the incoming request. The code only verified if the user making the request was the original uploader of the attachment, completely ignoring the repository scope.
The analysis of the fixing commit, fbea2c68e8df11cfa94e8ead913b79946780ed30, confirms this diagnosis. Two key functions were patched:
-
DeleteAttachment in routers/web/repo/attachment.go: The patch introduced a critical check, if attach.RepoID != ctx.Repo.Repository.ID, which ensures the attachment's repository ID matches the ID of the repository in the current request context. This directly addresses the vulnerability for issue attachments.
-
DeleteReleaseAttachment in routers/api/v1/repo/release_attachment.go: In this function, a FIXME comment was removed which read: Should prove the existence of the given repo. The removal of this comment as part of the security fix indicates that this API endpoint for release attachments suffered from the same logical flaw and was patched accordingly.
Exploitation of this vulnerability would involve calls to either DeleteAttachment or DeleteReleaseAttachment, as these were the functions that processed the deletion request without proper authorization checks.