Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-52797

CVE-2026-52797: Gogs Path Traversal Vulnerability

CVE-2026-52797 is a path traversal flaw in Gogs self-hosted Git service that allows authorized users to write git diff results to arbitrary paths. This article covers technical details, affected versions, and mitigation.

Published:

CVE-2026-52797 Overview

CVE-2026-52797 is a path traversal vulnerability [CWE-22] affecting Gogs, an open source self-hosted Git service. The flaw exists in versions prior to 0.14.0 and allows an authorized user to control the value passed to the git diff command. Insufficient input filtering lets attackers escape the target directory and write diff output to arbitrary filesystem paths. The vendor fixed the issue in version 0.14.0.

Critical Impact

Authenticated attackers can write arbitrary files outside the intended directory, leading to high availability impact and potential service compromise on Gogs servers.

Affected Products

  • Gogs self-hosted Git service versions prior to 0.14.0
  • Deployments exposing the diff functionality to authenticated users
  • All platforms hosting vulnerable Gogs builds (Linux, Windows, macOS, container deployments)

Discovery Timeline

  • 2026-06-24 - CVE-2026-52797 published to NVD
  • 2026-06-25 - Last updated in NVD database

Technical Details for CVE-2026-52797

Vulnerability Analysis

The vulnerability resides in Gogs' handling of user-supplied parameters passed to the git diff command. An authenticated user can manipulate the value that controls the diff output destination. Because Gogs fails to properly filter or sanitize this value, the attacker bypasses the intended target directory restriction.

The scope change in the attack profile indicates that successful exploitation affects resources beyond the vulnerable component itself. Integrity impact is low while availability impact is high, suggesting attackers can corrupt or overwrite files critical to service operation. The attack requires only low privileges and no user interaction, making it viable for any authenticated user on the platform.

Root Cause

The root cause is improper limitation of a pathname to a restricted directory [CWE-22]. Gogs accepts user-controlled input destined for the git diff command but does not validate that the resolved output path remains within the expected directory. Traversal sequences and filter bypass techniques allow the diff result to be written to attacker-chosen locations on the host filesystem.

Attack Vector

An authenticated attacker submits a crafted request to the Gogs interface that triggers a git diff operation. The attacker injects a manipulated path value that bypasses input filtering. Gogs executes the diff and writes the resulting output to the attacker-specified arbitrary path. Depending on filesystem permissions of the Gogs process, the attacker can overwrite repository data, configuration files, or other server-side resources.

For exploitation details, refer to the GitHub Security Advisory GHSA-pm6v-2h4w-4rp2.

Detection Methods for CVE-2026-52797

Indicators of Compromise

  • Unexpected files appearing outside Gogs repository directories owned by the Gogs service account
  • Modifications to Gogs configuration files (app.ini, custom/) without administrative action
  • Anomalous git diff invocations in Gogs process logs containing path traversal sequences such as ../

Detection Strategies

  • Monitor Gogs HTTP request logs for diff endpoint parameters containing traversal sequences or unexpected absolute paths
  • Audit filesystem activity around the Gogs data directory for writes outside expected repository subdirectories
  • Review authenticated user activity for unusual diff operations targeting non-standard paths

Monitoring Recommendations

  • Enable verbose request logging on the Gogs reverse proxy and forward to a centralized log platform for analysis
  • Deploy file integrity monitoring on Gogs installation directories, configuration paths, and adjacent filesystem locations
  • Alert on any process spawned by the Gogs service account that writes files outside the expected repository tree

How to Mitigate CVE-2026-52797

Immediate Actions Required

  • Upgrade all Gogs instances to version 0.14.0 or later without delay
  • Audit existing user accounts and disable any unrecognized or stale authenticated users
  • Inspect the Gogs host for unauthorized file modifications resulting from prior exploitation attempts

Patch Information

The Gogs maintainers released version 0.14.0 containing the fix for this path traversal vulnerability. Administrators should review the GitHub Security Advisory GHSA-pm6v-2h4w-4rp2 for full remediation guidance and upgrade procedures.

Workarounds

  • Restrict authenticated access to Gogs to trusted users only until the upgrade is complete
  • Run the Gogs process under a dedicated low-privilege account with strict filesystem permissions outside its data directory
  • Place Gogs behind a web application firewall configured to block path traversal patterns in request parameters
bash
# Verify installed Gogs version and confirm upgrade to 0.14.0 or later
gogs --version

# Restrict Gogs service account filesystem permissions (example for Linux)
chown -R gogs:gogs /home/gogs/gogs-repositories
chmod 750 /home/gogs/gogs-repositories

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.