/

CVE-2026-52799

Severity:

HIGH RISK

(7.5)

Broken Access Control (CWE-639) in Gogs Attachments API

CVE-2026-52799

Deferred

Vulnerability type

Category:

Broken Access Control

CWE:

CWE-639, CWE-862

Impact:

Unauthorized Information Disclosure

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A broken access control issue in Gogs causes the attachments download endpoint to serve raw files without checking whether the requester can view the related issue, comment, release, or repository.

Under typical configurations, this can allow unauthorized users, including unauthenticated ones in some setups, to download attachments from private repositories when they know or can guess the attachment UUID.

Affected context

The vulnerability occurs in Gogs instances that expose the /attachments/:uuid endpoint and rely on repository or issue-level permissions to protect attachment content.

It is most relevant when private repositories or restricted issues/comments/releases store sensitive files as attachments.

In environments configured with REQUIRE_SIGNIN_VIEW = false, unauthenticated users may be able to access attachments if they possess a valid UUID, but even with sign-in required, missing checks on the attachment's parent resource can still lead to unauthorized access.

Exploit preconditions

  • Attack surface: HTTP GET requests to the /attachments/:uuid endpoint on a Gogs server.
  • Required access: Ability to reach the Gogs web interface; in some configurations, no authentication is needed.
  • Trigger point: Supplying a valid UUID for an attachment whose parent issue/comment/release or repository should not be visible to the requester.
  • Why exploitation is possible: The endpoint returns the raw attachment file without enforcing permission checks against the associated resource or repository, violating object-level access control expectations.

Why this happens

The bug stems from treating attachment resources as independently accessible objects without re-validating access against their owning entities.

Instead of enforcing repository or issue-level authorization at the time of file download, the implementation trusts the presence of a UUID alone.

This aligns with CWE-639: Authorization Bypass Through User-Controlled Key and CWE-862: Missing Authorization, where user-supplied identifiers reference protected objects without corresponding permission checks.

Potential impact

  • Unauthorized users may download attachments from private repositories.
  • Sensitive documents, logs, or artifacts stored as attachments could be exposed.
  • Confidential project information and intellectual property can be leaked.
  • Compliance violations may occur if regulated data is stored in attachments.

General mitigation guidance

Mitigation generally involves enforcing object-level access control whenever direct references are used.

Secure patterns include:

  • Validating the requester's permissions against the attachment's parent repository or issue before serving the file.
  • Centralizing authorization logic so that all resource-specific endpoints delegate permission checks to shared access-control mechanisms.
  • Avoiding endpoints that serve data purely based on opaque identifiers without correlating them to the user's effective privileges.
  • Reducing the sensitivity of data stored in attachments or segregating highly sensitive files behind stricter access controls.

How teams detect issues like this

Effective detection often combines code-centric and configuration-focused approaches:

  • Static analysis and manual review looking for endpoints that retrieve objects by ID or UUID without invoking permission checks on the associated parent resource.
  • Auditing handler functions for download or export operations to ensure they incorporate role and repository visibility checks.
  • Implementing security tests that attempt to access attachments from private repositories using accounts with no repository access or with no authentication.
  • Using automated security scanning tools and policies that flag any direct object reference lacking an authorization call path.

Sources

SourceLink
github.comgithub.com/gogs/gogs/releases/tag/v0.14.3
github.comgithub.com/gogs/gogs/security/advisories/GHSA-p9f5-h3rx-j5qw

Frequently asked

questions

Its impact is most severe for private or restricted repositories because public repositories are already accessible. However, any attachment that relies on repository or issue-level permissions for protection may be exposed.

Not necessarily. In configurations with REQUIRE_SIGNIN_VIEW = false, unauthenticated users can exploit the issue if they possess a valid attachment UUID. In stricter setups, a low-privileged authenticated user might still retrieve attachments they should not see.

Always couple direct object access (by ID or UUID) with authorization checks on the object's owning resource, using centralized access-control routines. The download logic should confirm that the requester can view the parent repository, issue, comment, or release before returning the file.

Design APIs around consistent authorization layers, enforce mandatory permission checks for all resource handlers, and include security-focused tests in CI that attempt unauthorized access to objects using guessed identifiers. Regular code review for ID-based lookups and strong access-control policies are crucial.

Find out what's already
exploitable in your codebase.