Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
🐹
🐹 Go
Not in CISA KEV
HIGH severity

CVE-2026-52797 — gogs

HIGH

CVE-2026-52797 is a high-severity (CVSS 8.5) Path Traversal vulnerability in gogs.io/gogs. A fix is available for gogs.io/gogs — see the affected versions and patch details below.

Gogs: Overwriting critical files results in a denial of service

Also known asGHSA-pm6v-2h4w-4rp2GO-2026-5545
Published
Jun 24, 2026
Updated
Aug 12, 2026
Affected
1 pkg
Patched
1 / 1
Exploits
None indexed
Exploitation data as of Sep 27, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Exploitation Status

Proof-of-concept exploit code exists

  • CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.

Exploitation and automatability from CISA’s SSVC triage for CVE-2026-52797.

EPSS Exploitation Probability

via FIRST.org ↗
0.5%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs43th percentile — riskier than 43% of all scored CVEsHighest risk

Probability of exploitation in the next 30 days, from FIRST.org EPSS.

How urgent is this, really

CVE-2026-52797 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.

Where this sits among everything scored

Of 379,842 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.

Real-World Exposure

1 pkg affected
🐹gogs.io/gogs

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects Go packages — download data is not available via public APIs for these ecosystems.

Description

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
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
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
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

Affected Packages

1 total 1 fixed
EcosystemPackageVulnerable rangeFix
🐹Gogogs.io/gogsall versions0.14.0go get gogs.io/gogs@v0.14.0

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for gogs.io/gogs, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update gogs.io/gogs to 0.14.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-52797 is resolved across your whole dependency graph.

  3. Workarounds

    Resolve every user-supplied path to its canonical form and reject anything that escapes the intended directory, and run the component under an account that has no read or write access outside the directory it legitimately serves.

Frequently Asked Questions

**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
O3 Security · Impact-Aware SCA

Is CVE-2026-52797 in your dependencies?

Find it across Go, including transitive dependencies.