Executive brief
Gogs is an open-source self-hosted Git service used by teams to manage source code. A vulnerability in the file preview feature allows an authorized user to manipulate internal commands to overwrite critical system files. This can lead to a complete service outage (Denial of Service) by corrupting the application's database or configuration files, potentially requiring manual restoration from backups.
Technical details
A path traversal and argument injection vulnerability exists in the `DiffPreviewPost` function within `internal/route/repo/editor.go`. The application fails to properly sanitize the `:path_to_file` parameter before passing it to the `git diff` command via `exec.Command`. By exploiting specific behaviors of the Go `path.Clean` function (e.g., using `/../` sequences), an attacker can bypass repository boundary checks. This allows the injection of the `--output=<file>` flag into the Git command, enabling the attacker to overwrite arbitrary files on the host filesystem, such as `gogs.db` or `app.ini`, with the results of a diff comparison. This results in a Denial of Service (DoS). The issue is fixed in version 0.14.0 by ensuring the path is properly filtered using `pathutil.Clean` before use.
Affected products
- Gogs Gogs < 0.14.0
Timeline
- 2026-06-03: advisory: GitHub Security Advisory published
- 2026-06-24: disclosed: CVE published to NVD
- 2026-06-24: patched: Fix released in version 0.14.0