Gitea
CVE-2026-57886
MEDIUM
Severity by source
AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N
Network-exploitable by authenticated low-privilege users (PR:L); AC:H because victim UUID must be obtained independently; C:H for full private file disclosure; I:L for attachment linkage mutation; no availability impact.
Primary rating from GitHub Advisory.
CVSS VectorGitHub Advisory
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N
Lifecycle Timeline
2DescriptionGitHub Advisory
Summary
Gitea's issue and comment attachment update paths accept attachment UUIDs without verifying that each attachment belongs to the target issue/comment repository. If an authenticated attacker knows a victim attachment UUID, they can re-link that attachment to an attacker-controlled issue or comment, causing later attachment access checks to use the attacker's repository authorization context.
Affected
- Component: web issue/comment attachment handling.
- Confirmed version:
maincommita39b2775edcb3ba53def96794491b91335117d81(v1.27.0-dev-352-ga39b2775ed). - Fixed in: not fixed at the time of validation.
- Other versions: not exhaustively tested. The affected code path appears structurally similar to versions that contain the current issue/comment attachment update logic.
Description / Root Cause
files[] values from issue/comment edit flows are passed to updateAttachments in routers/web/repo/issue.go:589-629. That helper calls:
models/issues/issue_update.go:267-278(UpdateIssueAttachments)models/issues/comment.go:623-642(UpdateCommentAttachments)
Both functions load attachments by UUID and update the attachment linkage, but neither validates that the attachment row's RepoID matches the repository of the target issue/comment. They also do not reject attachments already linked to a different issue/comment.
Attachment reads then use the linked issue/release repository to decide access:
services/repository/repository.go:185-207returns the repository ID fromIssueIDorReleaseID.routers/web/repo/attachment.go:153-184checks read permission on that linked repository.routers/web/repo/attachment.go:216-224opens and serves the file from the attachment's storage path after the linked-repository permission check succeeds.
For the global /attachments/{uuid} route in routers/web/web.go:872-876, there is no current repository context, so the early attach.RepoID mismatch check in ServeAttachment does not protect against this re-linking case.
A patched sibling path already demonstrates the intended invariant: models/repo/release.go:179-215 rejects release attachments whose RepoID differs from the release repository. That guard was introduced for CVE-2026-20736, but the issue/comment paths still lack an equivalent check.
Impact
An attacker who can edit an issue/comment in a repository they can read can move a known victim attachment UUID into that repository's authorization context. After the re-link, the attachment download path resolves access against the attacker-controlled repository while serving the original attachment file.
This can disclose private issue/comment attachments if the attacker has obtained the UUID through prior legitimate access, copied links, notification content, logs, browser history, or another exposure. The attack does not require write access to the victim repository.
Reproduction Summary
Full HTTP/E2E observation:
- A local Gitea server was started with an isolated SQLite database.
- A victim user created private repositories, private issues, and issue attachments containing unique marker strings.
- An attacker user first attempted to download each victim attachment through
/attachments/{uuid}and received404. - The attacker then submitted the victim UUID through the real issue edit route in an attacker-controlled public repository.
- The same attacker could then download the victim issue attachment through
/attachments/{uuid}and received200; the response body contained the unique issue marker. - The attacker repeated the flow through the real comment edit route and could download the second victim attachment with
200; the response body contained the unique comment marker.
Model-level issue-path behavior:
- A fixture attachment with
RepoID = 2andIssueID = 4was passed toUpdateIssueAttachmentsfor attacker issueID = 1, whoseRepoID = 1. - The call succeeded.
- The attachment row still had
RepoID = 2, but itsIssueIDwas changed to the attacker issue. GetAttachmentLinkedTypeAndRepoIDthen resolved the attachment to attacker repositoryRepoID = 1.
Model-level comment-path behavior:
- The same cross-repository attachment UUID was passed to
UpdateCommentAttachmentsfor attacker commentID = 1. - The call succeeded.
- The attachment row still had
RepoID = 2, but itsIssueIDandCommentIDwere changed to the attacker's issue/comment. - The linked repository used for access checks became attacker repository
RepoID = 1.
Negative control:
- Existing release test
TestAddReleaseAttachmentsRejectsDifferentRepopasses and confirms the release path rejects the same class of cross-repository attachment linkage.
Detailed verifier and step-by-step runbook are available on request.
Suggested Fix
Add repository and linkage validation before updating issue/comment attachments.
Recommended checks:
- Load the target issue for
UpdateIssueAttachmentsand derive itsRepoID. - Load the target comment's issue for
UpdateCommentAttachmentsand derive itsRepoID. - Reject any attachment whose
RepoIDdiffers from the target issue repository. - Reject attachments already linked to a different issue/comment/release, except for attachments already linked to the same object being updated.
- If caller context is available at the web/service layer, also require new unlinked attachments to belong to the current actor or to have been uploaded in the current edit session.
- Preserve any legacy
RepoID = 0migration behavior only when it can be proven safe for the target repository.
Also consider a cleanup/audit query for existing inconsistent rows where attachment.issue_id != 0 and attachment.repo_id differs from the linked issue repository.
Regression Tests
Add tests that fail before the fix and pass after it:
UpdateIssueAttachmentsrejects an attachment whoseRepoIDdiffers from the target issue'sRepoID.UpdateCommentAttachmentsrejects an attachment whoseRepoIDdiffers from the target comment issue'sRepoID.- Same-repository unlinked attachment linking still works for normal issue/comment editing.
- Attachments already linked to a different issue/comment cannot be moved by passing their UUID in
files[]. - Existing release guard test remains passing.
AnalysisAI
Cross-repository attachment re-linking in Gitea exposes private issue and comment attachments to authenticated attackers who know a victim's attachment UUID. An attacker with issue-editing rights in any repository they can access can inject a victim UUID into the files[] parameter of an issue or comment edit request, causing Gitea to re-link that attachment into the attacker's authorization context; subsequent requests to /attachments/{uuid} then resolve access against the attacker's repository rather than the victim's, delivering the private file. …
Unlock full vulnerability intelligence
- Risk assessment & exploitation conditions
- Attack chain visualization
- Remediation with exact patch versions
- Threat intelligence from 22 sources
- Personal watchlist & email alerts
Free forever · No credit card required
Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata
Vulnerability AssessmentAI
| Exploitation | The attacker must be authenticated to the Gitea instance with at least issue-editing permissions in one repository they control or have write access to - any such repository suffices, including a public repository on the same instance. … Additional conditions and limiting factors are described in the full assessment. |
| Risk Assessment | The provided CVSS 3.1 vector (AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N, score 5.9) accurately reflects the attack profile: network-reachable, requires a low-privilege authenticated session, and carries High confidentiality impact offset by High attack complexity. … Full risk analysis with EPSS, KEV, and SSVC signal comparison available after sign-in. |
| Exploit Scenario | An attacker authenticated to a Gitea instance edits an issue in a repository they control and injects a victim attachment UUID - obtained, for example, from a notification email or a previously shared link - into the files[] form parameter of the issue update HTTP request. Gitea's UpdateIssueAttachments function accepts the UUID and re-links the attachment to the attacker's issue without validating repository ownership. … |
| Remediation | Upgrade Gitea to version 1.27.0, which incorporates fixes from pull requests https://github.com/go-gitea/gitea/pull/38406 and https://github.com/go-gitea/gitea/pull/38426, and commits de4b8277e9cb576f2315fb03b5ab6478b42a1d31 and f69e15afe7496cc62e96dab244629c69eb31a7bf. … Detailed patch versions, workarounds, and compensating controls in full report. |
Threat intelligence, references, and detailed analysis are available after sign-in.
Broken access control in Gitea's Composer package registry (versions up to and including 1.26.1) lets remote attackers r
Gitea before 1.16.7 does not escape git fetch remote. Rated high severity (CVSS 7.5), this vulnerability is remotely exp
The git hook feature in Gitea 1.1.0 through 1.12.5 might allow for authenticated remote code execution in customer envir
Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') vulnerability in Gitea Gitea
Container escape in Gitea act_runner (Docker backend, through act 0.262.0) lets an authenticated user with workflow-exec
models/repo_mirror.go in Gitea before 1.7.6 and 1.8.x before 1.8-RC3 mishandles mirror repo URL settings, leading to rem
An issue was discovered in Gitea through 1.11.5. Rated high severity (CVSS 7.5), this vulnerability is remotely exploita
Missing Authorization in GitHub repository go-gitea/gitea prior to 1.16.4. Rated high severity (CVSS 7.1), this vulnerab
Open Redirect on login in GitHub repository go-gitea/gitea prior to 1.16.5. Rated medium severity (CVSS 6.1), this vulne
Reverse-proxy authentication bypass in the official Gitea Docker image (versions up to and including 1.26.2) allows any
Branch-protection bypass in Gitea's self-hosted Git server (all versions before 1.26.0) allows a user with push access t
Migration transport protections in Gitea are bypassed for Git LFS operations, affecting all self-hosted instances before
Same technique Authentication Bypass
View allShare
External POC / Exploit Code
Leaving vuln.today
GHSA-6c6r-5xr4-cr5m