Skip to content

security: enforce repo access on attachment download - #8320

Merged
unknwon merged 5 commits into
mainfrom
GHSA-p9f5-h3rx-j5qw
Jun 4, 2026
Merged

unknwon merged 5 commits into
mainfrom
GHSA-p9f5-h3rx-j5qw

Conversation

@unknwon

@unknwon unknwon commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary

  • The attachment download endpoint did not check whether the requester could view the parent repository, only that the supplied UUID matched an attachment row.
  • The handler now resolves the parent issue or release, loads its repository, and denies the request when the repository is private and the current user has neither ownership nor read access.

Refs GHSA-p9f5-h3rx-j5qw.

Test plan

  • Upload an attachment to an issue in a private repository.
  • Confirm an unauthenticated visitor receives 404 for GET /attachments/:uuid.
  • Confirm a signed-in user without access to the repository receives 404.
  • Confirm the repository owner and collaborators with read access can still download the file.
  • Repeat for an attachment on a release in a private repository.
  • Confirm attachments on public repositories continue to download for anonymous and signed-in users.

unknwon added 4 commits June 4, 2026 10:27
The GET /attachments/:uuid handler returned the attachment file based
only on the UUID lookup, with no check that the requester could view
the parent repository. Anyone who learned an attachment UUID could
download files from private repositories.

The handler now resolves the parent issue or release, loads the owning
repository, and denies the request when the repository is private and
the current user has neither ownership nor read access.
Shared caches that honored "Cache-Control: public" could store the
attachment body and serve it to other clients that share the URL,
including unauthorized requesters who never reach the new repo-access
check. Switch to "private" so only the requesting browser may cache
the response.
PermissionsStore.AccessMode already returns AccessModeOwner for the
repository owner and AccessModeRead for everyone on a public repo, so
the IsOwnedBy and IsPrivate branches were dead code on top of the
HasAccess call.
@unknwon unknwon added this to the 0.14.3 milestone Jun 4, 2026
@unknwon
unknwon merged commit d3ca23f into main Jun 4, 2026
7 checks passed
@unknwon
unknwon deleted the GHSA-p9f5-h3rx-j5qw branch June 4, 2026 14:39
unknwon added a commit that referenced this pull request Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant