Skip to main content
VulnerabilityPublished

CVE-2026-57886: Gitea · Cross-repository issue/comment attachment re-linking can expose private attachment content

Affects code.gitea.io/giteaSource GCVE Database

0
Compare

Mentioned vulnerabilities

Authoritative record:CVE-2026-57886· Medium 5.9

Not known to be exploited · CVSS 5.9 Medium : upgrade to 1.27.0 when convenient.

Data as of 30 Oct 2026, 11:52 UTC

CVSS 3.1 base score
5.9Medium
How severe the flaw is on the 0–10 CVSS scale.
EPSS
0.3% chance of exploitation in 30 days – higher than 24% of CVEsExploit Prediction Scoring System: the likelihood attackers will use this flaw soon.
Patch
Available – fixed in 1.27.0
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N

Exploitation evidence

  1. Disclosed: evidence found.

    CVE published 13 Aug 2026

  2. Detectable: no evidence on record.

    No public nuclei template indexed

  3. Weaponized: no evidence on record.

    No public exploit code indexed in Metasploit or Exploit-DB

  4. Exploited in the wild: no evidence on record.

    Not in CISA KEV and no source reports exploitation

  5. Observed by OffSeq Mirage: no evidence on record.

    No attack traffic recorded by OffSeq Mirage sensors

A missing step is not evidence of safety. Sources: cve.org (opens in a new tab), the Metasploit, Exploit-DB and nuclei-templates index as of 30 Oct 2026.

What to do

Upgrade code.gitea.io/gitea to 1.27.0.

Affected software

ProductAffectedFixed in
Gocode.gitea.io/giteaAffected
  • <1.27.0
Fixed in
  • 1.27.0

Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.

Description

## 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: `main` commit `a39b2775edcb3ba53def96794491b91335117d81` (`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-207` returns the repository ID from `IssueID` or `ReleaseID`. - `routers/web/repo/attachment.go:153-184` checks read permission on that linked repository. - `routers/web/repo/attachment.go:216-224` opens 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 received `404`. - 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 received `200`; 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 = 2` and `IssueID = 4` was passed to `UpdateIssueAttachments` for attacker issue `ID = 1`, whose `RepoID = 1`. - The call succeeded. - The attachment row still had `RepoID = 2`, but its `IssueID` was changed to the attacker issue. - `GetAttachmentLinkedTypeAndRepoID` then resolved the attachment to attacker repository `RepoID = 1`. Model-level comment-path behavior: - The same cross-repository attachment UUID was passed to `UpdateCommentAttachments` for attacker comment `ID = 1`. - The call succeeded. - The attachment row still had `RepoID = 2`, but its `IssueID` and `CommentID` were changed to the attacker's issue/comment. - The linked repository used for access checks became attacker repository `RepoID = 1`. Negative control: - Existing release test `TestAddReleaseAttachmentsRejectsDifferentRepo` passes 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 `UpdateIssueAttachments` and deri

References

Community reviews

Loading reviews…