gogs.io/gogs

CVE-2026-52797

CVE-2026-52797 is a high-severity path traversal vulnerability in gogs.io/gogs (go), affecting versions <= 0.13.4. It is fixed in 0.14.0.

Key facts
CVSS score
8.5
High
Attack vector
Network
Issuing authority
GitHub Advisory Database
Affected package
gogs.io/gogs
Fixed in
0.14.0
Disclosed
2026

Summary

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: 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. 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/:pathtofile method is responsible for displaying the changes. The problem is how the POST /:user/:repo/preview/:branch/:pathtofile method processes the value passed to the :pathtofile (see Listing 1). Listing 1. _preview method processor 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 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 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 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 data | Result | | ----------- | ----------- | | any ../../target | target | | any1/…/any2/../any3/../target | target | | ./target | target | | /../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: Create a data directory in the repository and an empty gogs.db file in that directory. Send a payload request and check that the code returned is a 200 OK (see Figure 2). Figure 2. Example of a successful attack

Impact

What is path traversal?

Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.

Severity and exposure

CVE-2026-52797 has a CVSS score of 8.5 (High). The vector is network-reachable, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment.

A fixed version is available (0.14.0). Upgrading removes the vulnerable code path.

Affected versions

go

  • gogs.io/gogs (<= 0.13.4)

Security releases

  • gogs.io/gogs → 0.14.0 (go)
Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter instead of chasing every advisory.

Kodem's runtime-powered SCA identifies whether CVE-2026-52797 is reachable in your applications. Explore open-source security for your team.

See if CVE-2026-52797 is reachable in your applications. Get a demo

Already deployed Kodem? See CVE-2026-52797 in your environment

Remediation advice

Upgrade gogs.io/gogs to 0.14.0 or later to resolve this vulnerability.

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently asked questions about CVE-2026-52797

What is CVE-2026-52797?

CVE-2026-52797 is a high-severity path traversal vulnerability in gogs.io/gogs (go), affecting versions <= 0.13.4. It is fixed in 0.14.0. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.

How severe is CVE-2026-52797?

CVE-2026-52797 has a CVSS score of 8.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.

Which versions of gogs.io/gogs are affected by CVE-2026-52797?

gogs.io/gogs (go) versions <= 0.13.4 is affected.

Is there a fix for CVE-2026-52797?

Yes. CVE-2026-52797 is fixed in 0.14.0. Upgrade to this version or later.

Is CVE-2026-52797 exploitable, and should I be worried?

Whether CVE-2026-52797 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo

What actually determines whether CVE-2026-52797 is exploitable, and how bad it is?

Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.

How do I fix CVE-2026-52797?

Upgrade gogs.io/gogs to 0.14.0 or later.

Stop the waste.
Protect your environment with Kodem.