Skip to main content

Gogs CVE-2026-52797

| EUVDEUVD-2026-39085 HIGH
Path Traversal (CWE-22)
2026-06-16 https://github.com/gogs/gogs GHSA-pm6v-2h4w-4rp2
8.5
CVSS 3.1 · Vendor: https://github.com/gogs/gogs
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Register or use existing Gogs account
  2. Delivery
    Create repository with data/gogs.db placeholder
  3. Exploit
    Send crafted _preview POST with -output= payload
  4. Execution
    Bypass path.Clean filter via /../ prefix
  5. Persist
    git diff overwrites gogs.db on host
  6. Impact
    Gogs database corrupted, service denial

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Path canonicalization, traversal prevention
MITRE ATT&CK

2 techniques across 2 tactics: Discovery, Collection

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Requires an authenticated Gogs account with permission to create or edit a repository (PR:L); the attacker must be able to reach the POST /:user/:repo/_preview/:branch/:path_to_file editor endpoint, which is exposed by default. The attacker must pre-create a directory and placeholder file in the repository whose path mirrors the target host file (e.g., data/gogs.db) so the TreeEntry existence check passes. Exploitation is limited to files writable by the OS user running the Gogs process - typically the Gogs data directory, app.ini, and other application-owned files; arbitrary system-wide file overwrite is constrained by filesystem permissions. No user interaction by another party is required (UI:N), and the vulnerable endpoint is reachable over the network (AV:N).

Impact

CVSS 3.1 is rated 8.5 with vector AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:L/A:H - the high score is driven by the scope change (S:C, host file overwrite from a repo-scoped context) and high availability impact (A:H, corruption of the Gogs database). However, PR:L means an authenticated account with repository edit rights is required, which in many Gogs deployments (private/internal teams or invite-only registration) materially limits real-world risk. No EPSS score, KEV listing, or SSVC decision data was provided, but a fully weaponizable payload (-output=/../data/gogs.db) is published in the vendor advisory itself, making exploitation trivial for any user with access. The impact is limited to integrity/availability of host files writable by the Gogs process - there is no confidentiality impact (C:N) and no path to RCE described. Defenders running Gogs with open registration should treat this as high priority; closed-deployment operators can treat it as moderate.

Exploit ScenarioDerived

An attacker with a regular Gogs account creates a repository, adds a data/ directory containing an empty gogs.db placeholder, then submits a crafted POST /:user/:repo/_preview/:branch/data/gogs.db request whose path field carries the payload -output=/../data/gogs.db. The server passes the payload to git diff, which interprets it as the --output flag and overwrites the Gogs server's real SQLite database (or app.ini) with diff output, corrupting it and causing Gogs to fail on next restart. Working payload and step-by-step exploitation are published in the GHSA advisory.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.4% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jun 17, 2026

Authenticated path traversal in Gogs self-hosted Git service (versions <= 0.13.4) allows any user with repository edit permissions to overwrite arbitrary files on the host filesystem via the diff preview endpoint, resulting in denial of service. By abusing the git diff --output=<file> flag through the POST /:user/:repo/_preview/:branch/:path_to_file handler and bypassing the standard library path.Clean filter, an attacker can corrupt critical files such as gogs.db or app.ini. Publicly available exploit code exists in the form of a detailed researcher write-up with payload examples, though no CISA KEV listing or active exploitation has been reported.

RemediationAI

Vendor-released patch: upgrade Gogs to version 0.14.0 or later, per GHSA-pm6v-2h4w-4rp2 (https://github.com/gogs/gogs/security/advisories/GHSA-pm6v-2h4w-4rp2). The fix replaces the unfiltered treePath argument to GetDiffPreview with the validated entry variable and switches filtering from the standard library path.Clean to the internal pathutil.Clean helper, which correctly normalizes traversal sequences. If immediate upgrade is not possible, compensating controls include disabling self-registration ([service] DISABLE_REGISTRATION = true in app.ini) to limit attackers to trusted users, restricting which users hold write access to repositories, blocking the /_preview/ route at a reverse proxy for non-trusted source IPs (side effect: breaks the in-browser file-edit preview feature for affected users), and ensuring the data/gogs.db and app.ini files are backed up and monitored for unexpected modification so a successful attack can be detected and reverted quickly.

Affected VersionsENISA

gogs < 0.14.0

Affected Packages

go gogs.io/gogs fix: 0.14.0
euvd gogs fix: 0.14.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 2 packages in go, euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Gogs is a self-hosted Git service written in Go and packaged as pkg:go/gogs.io_gogs. The vulnerability is a classic CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) caused by the DiffPreviewPost handler in internal/route/repo/editor.go passing the raw treePath user input to exec.Command("git", "diff", treePath) rather than the validated entry variable returned by TreeEntry. The filter weakness stems from the Go standard library's path.Clean semantics: sequences like -output=/../data/gogs.db survive cleaning because path.Clean collapses parent-directory traversals in a way that preserves the attacker-controlled flag prefix, allowing it to reach the underlying git diff invocation as an option rather than a path argument.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/gogs/gogs) PRIMARY 8.5 HIGH
AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:L/A:H
vuln.today AI 8.5 HIGH

Network-reachable editor endpoint, low complexity with published payload, requires an authenticated repo-editor account (PR:L), no confidentiality impact, integrity limited to overwritten file, high availability via DB corruption; scope changes to the host filesystem.

3.1 AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:L/A:H
4.0 AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:L/VA:H/SC:N/SI:L/SA:H
SUSE HIGH

Primary rating from Vendor (https://github.com/gogs/gogs).

CVSS VectorVendor: https://github.com/gogs/gogs

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Changed
Confidentiality
None
Integrity
Low
Availability
High

DescriptionCVE.org

Vulnerability type: Path Traversal Impact: DoS Exploitation prerequisite: authorized user Description: As an authorized user, an intruder can dictate the value which is passed to the git diff command which, together with bypassing the filtering of the passed value, allows the user to bypass the target directory and write the result of the comparison to any arbitrary path. Researcher: Artyom Kulakov (Positive Technologies) Mitigation:

  1. https://github.com/gogs/gogs/blob/b7372b1f32cd0bb40984debfb049e3fc04efaee4/internal/route/repo/editor.go#L307 - on this line, instead of the treePath variable, which comes directly from the user unchanged, we should first filter and then pass the entry variable.
  2. To filter the treePath variable, it is better to use the preexisting pathutil.Clean function instead of path.Clean from the standard Go library.

Exploitation

A Positive Technologies researcher discovered that the user has the ability to preview their changes when editing a file in the repository. The POST /:user/:repo/_preview/:branch/:path_to_file method is responsible for displaying the changes. The problem is how the POST /:user/:repo/_preview/:branch/:path_to_file method processes the value passed to the :path_to_file (see Listing 1). ###### Listing 1. _preview method processor

Go
func DiffPreviewPost(c *context.Context, f form.EditPreviewDiff) {
	// В treePath попадает значение из :path_to_file
	treePath := c.Repo.TreePath

    // Проверка, что файл существует в репозитории
	entry, err := c.Repo.Commit.TreeEntry(treePath)

	-cut-

	// Значение, полученное от пользователя, передается в функцию в обход фильтра
	diff, err := c.Repo.Repository.GetDiffPreview(c.Repo.BranchName, treePath, f.Content)

	-cut-

The first problem to solve is to make the TreeEntry function think that the value passed in is a file that actually exists in the repository. To do this, we must consider how the TreeEntry function actually makes this decision (see Listing 2). ###### Listing 2. Path checking and cleaning function

Go
func (t *Tree) TreeEntry(subpath string, opts ...LsTreeOptions) (*TreeEntry, error) {

	-cut-
	// Очистка пути от “.” И “/”
	subpath = path.Clean(subpath)

	// Разбиение результата на компоненты для их последующей верификации в цикле
	paths := strings.Split(subpath, "/")

	-cut-

	for i, name := range paths {
		-cut-
	}

Thus, we have a two-level path verification system. At the first stage, extra characters are removed, and at the second stage the resulting path is divided into components, each of which is then checked to be present in the repository. If the TreeEntry function receives a path that has the format of ../../../../../../etc/passwd, it will be transformed into an [.., .., .., .., .., .., etc, passwd] array. The first element of this array will fail further validation and an error will be returned. This problem can be bypassed if the path is directly from the root directory and the corresponding directory hierarchy is present in the repository. A path in the format of /etc/passwd will turn into an [, etc, passwd] array and successfully pass through the filter (see Figure 1). ###### Figure 1. Example of filter bypass !image The resulting value will be passed unchanged to the GetDiffPreview function, which will execute the git diff /etc/passwd command in the current repository (see Listing 3). ###### Listing 3. Change comparison function

Go
func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *gitutil.Diff, err error) {
	-cut-

	cmd := exec.Command("git", "diff", treePath)
	cmd.Dir = localPath
	cmd.Stderr = os.Stderr

	-cut-
}

However, we will not get any results because such a command will exit early with an error stating that the /etc/passwd is outside the repository boundaries. Because of the specifics of the exec.Command function, there is no way to embed commands or insert spaces to separate the arguments. So, we get one controllable command parameter diff.

Then a second task arises: to select a parameter which allows us to perform malicious actions. Such a parameter is --output=<file>. This option allows the result of the comparison to be written over the passed path. The malicious command looks like this: git diff -output=/data/gogs.db. It overwrites the database file with garbage, which leads to denial of service. Instead of a database file, we could also overwrite a app.ini configuration file.

The final challenge is to bypass the filter in order to pass the payload. This is possible through the use of some peculiarities in the library function path.Clean. By entering a specific sequence of characters, the path.Clean function discards everything that came before this sequence and the sequence itself, leaving only the remains. This behavior is best demonstrated by the following table (see Table 1). ###### Table 1. Results of the path.Clean function operation

Input dataResult
any ../../targettarget
any1/…/any2/../any3/../targettarget
./targettarget
/../target/target
a/b/../../../../target../../target

So, the payload that will bypass the filters and do as we wish, will look like this: -output=/../data/gogs.db. Attack steps:

  1. Create a data directory in the repository and an empty gogs.db file in that directory.
  2. Send a payload request and check that the code returned is a 200 OK (see Figure 2).

###### Figure 2. Example of a successful attack !image

Executive ViewAI

Why It Matters

Gogs self-hosted Git service versions 0.13.4 and earlier contain an authenticated path traversal vulnerability (CVSS 8.5) that allows users with repository edit permissions to overwrite critical system files such as gogs.db and app.ini. This could enable denial of service, data destruction, or unauthorized access to hosted repositories and user data. Publicly available exploit code exists, creating immediate risk for organizations running vulnerable versions.

Business Impact: High
Compensating Controls

No vendor-released patch identified at time of analysis. Interim mitigations: (1) Restrict repository edit permissions to administrative staff only; (2) Disable or firewall the vulnerable preview endpoint; (3) Implement file integrity monitoring on critical configuration files (gogs.db, app.ini); (4) Review access logs for suspicious activity on the preview endpoint.

Threat Intelligence Overview

EPSS Score
0.4%
Top 73% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS 0.4%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact
High

Priority Score

42
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +42
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.

Denial of Service attacks render applications or systems unavailable by overwhelming resources or triggering failure conditions.

Vendor StatusVendor

SUSE

Severity: Important
Product Status
SUSE Linux Enterprise Server 16.1 Affected
SUSE Linux Enterprise Server for SAP applications 16.1 Affected
SUSE Linux Enterprise Module for Package Hub 15 SP5 Affected
SUSE Linux Enterprise Module for Package Hub 15 SP6 Affected
openSUSE Leap 15.5 Affected

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy