/

CVE-2026-52813

Severity:

CRITICAL RISK

(10.0)

Path Traversal (CWE-23) in Gogs Org Repo Storage

CVE-2026-52813

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-23

Impact:

Remote Code Execution via Filesystem Manipulation

Severity:

CRITICAL RISK

(10.0)

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 path traversal flaw in Gogs allows specially crafted organization names to direct repository data to arbitrary filesystem locations.

Under certain configurations, an attacker can chain nested repositories to overwrite another repository's hooks configuration, potentially leading to remote code execution.

Affected context

This vulnerability appears in Gogs installations that accept user-controlled organization names and use them directly to construct filesystem paths for repository storage.

It is most relevant where organizations can be created with minimal validation, and repositories are stored on shared or predictable directory structures.

Environments that rely on Git hooks for automation or deployment workflows are especially exposed, since repository data can influence hook configuration.

Exploit preconditions

  • Attack surface: Web interface or API endpoints that allow creation or modification of organization names and repositories.
  • Required access: Ability to create organizations and repositories, typically any authenticated user on a misconfigured instance; stronger tenant isolation may reduce risk.
  • Trigger point: Using an organization name containing ../ causes repository paths to be resolved to attacker-chosen locations on the filesystem.
  • Why exploitation is possible: The application concatenates organization names into filesystem paths without normalizing or validating against traversal sequences, allowing repositories to be placed where they can overwrite other repositories' hooks or configuration.

Why this happens

The underlying issue is improper validation of path components derived from user-controlled input, corresponding to CWE-23 (Relative Path Traversal).

Gogs constructs repository storage paths by directly embedding organization names without sanitizing or canonicalizing them, so sequences like ../ are honored by the filesystem.

Once an attacker can control where a repository is stored, they can create nested repositories whose internal files overlap with existing repositories' hook directories or configuration files, enabling unintended modification of executable hook scripts.

Potential impact

  • An attacker may write repository data or configuration files to arbitrary locations within the Git storage area.
  • An attacker could overwrite Git hook scripts of other repositories to execute arbitrary commands when those hooks run.
  • An attacker can potentially gain remote code execution on the server through malicious hook configurations.
  • An attacker may disrupt normal repository operations or corrupt project data by interfering with underlying storage paths.

General mitigation guidance

Mitigation generally focuses on constraining and validating all filesystem paths derived from user input and decoupling untrusted identifiers from physical storage layout.

Common defensive patterns include:

  • Normalizing and validating path components, explicitly rejecting .., path separators, and other traversal sequences in organization and repository names.
  • Using whitelists or strict regex-based constraints for user-visible identifiers that will be used in filesystem paths.
  • Mapping logical organization and repository identifiers to internal, opaque directory names that are not directly derived from user input.
  • Running Git hooks and related automation with least privilege and minimizing reliance on writable hook locations influenced by multi-tenant users.
  • Isolating repository storage per tenant or project to reduce the blast radius of any single compromised path.

How teams detect issues like this

Effective detection combines path-handling review with runtime monitoring:

  • Static analysis rules can flag direct concatenation of user input into filesystem paths without normalization or validation, especially when ../ is not explicitly rejected.
  • Code reviews should look for any use of organization, user, or repository names in file or directory creation logic, checking for traversal protections and canonicalization.
  • Security policies can require central utilities or wrappers for filesystem access that enforce safe path handling and reject suspicious patterns.
  • Log analysis may highlight anomalous repository creation events or unexpected directories under repository storage paths, indicating potential exploitation.
  • Automated application security testing tools can be configured to fuzz path parameters with traversal sequences and alert on unexpected directory creation or file access.

Sources

SourceLink
github.comgithub.com/gogs/gogs/commit/f6acd467305943aae8403cbac81f0118dd1235d7
github.comgithub.com/gogs/gogs/pull/8334
github.comgithub.com/gogs/gogs/releases/tag/v0.14.3
github.comgithub.com/gogs/gogs/security/advisories/GHSA-c39w-43gm-34h5

Frequently asked

questions

Exploitability depends on who can create organizations and repositories in the Gogs instance. On installations where any authenticated user can create organizations, the vulnerability can be broadly exploitable, especially in shared or multi-tenant environments.

The attacker typically needs the ability to create or manage organizations and repositories in the affected Gogs deployment. They do not need shell access to the server; the vulnerability is triggered through normal application operations that write repository data to disk.

The safest fix is to strictly validate and sanitize all user-controlled identifiers used in filesystem paths, rejecting any traversal sequences or illegal characters, and mapping logical names to internal, canonical directory structures rather than using raw input directly.

Long-term prevention involves adopting a consistent safe-path abstraction for storage, enforcing strong input validation, isolating tenant data, and treating hook scripts as sensitive execution points subject to access control and integrity checks. Regular security reviews of filesystem and hook handling logic, combined with automated checks for unsafe path operations, help prevent regressions.

Find out what's already
exploitable in your codebase.