CVE-2022-1986: OS Command Injection in Gogs
Summary
CVE-2022-1986: OS Command Injection in file editor in Gogs in gogs.io/gogs. Affects gogs.io/gogs versions < 0.12.9. Fixed in 0.12.9. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Gogs is an open-source self-hosted Git service written in Go. It provides a lightweight and easy-to-use platform for managing repositories, users, and organizations. Gogs allows users to collaborate on code, track changes, and manage their projects effectively. However, a vulnerability has been discovered in Gogs that allows for OS command injection.
Vulnerability Detail
The OS command injection vulnerability in Gogs allows an attacker to execute arbitrary commands on the underlying operating system. This can be exploited by an authenticated user with write access to a repository's file editor. By crafting a malicious file name or content, an attacker can inject arbitrary commands that will be executed when the file is accessed or modified. This can lead to unauthorized access, data leakage, and potential compromise of the host system.
How To Fix
Latest published version: v0.13.3 as of 22 Oct 2026
go get gogs.io/gogs@v0.13.3
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
0.12.9
This is the first release that contains the fix.
go get gogs.io/gogs@v0.12.9
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, users can restrict write access to the file editor for untrusted users. By limiting the ability to modify files through the Gogs interface, the risk of exploitation can be reduced. Additionally, it is advisable to monitor and review file changes for any suspicious activity.
Conclusion
The OS command injection vulnerability in Gogs poses a significant risk to the security and integrity of repositories and host systems. It is crucial for Gogs users to update their installations to the latest patched version (0.12.9 or later) to mitigate this vulnerability. By following the recommended steps and monitoring for any suspicious activity, users can enhance the security of their Gogs deployments.
See every vulnerability recorded for gogs.io/gogs →
FAQ
The vulnerability allows an attacker to execute arbitrary commands on the underlying operating system, potentially leading to unauthorized access, data leakage, and compromise of the host system.
Users of Gogs versions prior to 0.12.9 are affected by this vulnerability. Organizations and individuals using Gogs for code collaboration and version control should update their installations to the latest patched version.
You can use the Vulert Playground at Vulert Scanner to check if your Gogs installation is affected by this vulnerability. Simply provide your Gopkg.lock file, and Vulert will analyze it for any open-source vulnerabilities, including this OS command injection issue.
At the time of this report, there are no known public exploits specifically targeting this OS command injection vulnerability in Gogs. However, it is crucial to update to the latest patched version to mitigate the risk.
If you observe any suspicious activity or believe your Gogs installation has been compromised, it is recommended to disconnect the affected system from the network and seek assistance from a qualified security professional. They can help investigate the incident, assess the impact, and guide you through the remediation process.
Related vulnerabilities
Recent vulnerabilities recorded for gogs.io/gogs.