Skip to content
RCE Disclosed report Advanced CVE-2022-2024

Gogs OS Command Injection vulnerability

Gogs did not properly sanitise upload paths to the .git directory on case-insensitive file systems, allowing a malicious user to upload a crafted config file and delete files to gain SSH access. All installations with repository upload enabled on such systems are affected.

gogs/gogs

Originally disclosed on huntr

Critical View original

Impact

The malicious user is able to update a crafted config file into repository's .git directory in combination with crafted file deletion to gain SSH access to the server on case-insensitive file systems. All installations with repository upload enabled (default) on case-insensitive file systems (Windows, macOS, etc.) are affected.

Patches

Make sanitization of upload path to .git directory to be case-insensitive. Users should upgrade to 0.12.11 or the latest 0.13.0+dev.

Workarounds

Disable repository upload.

References

https://huntr.dev/bounties/18cf9256-23ab-4098-a769-85f8da130f97/

For more information

If you have any questions or comments about this advisory, please post on https://github.com/gogs/gogs/issues/7030.

From the GitHub Advisory Database (GHSA-pfvh-p8qp-9ww9, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the upload path sanitisation only checked for the exact lowercase '.git' string and did not account for case-insensitive file systems where '.GIT' or other case variants resolve to the same directory.

What the attacker needed

Repository upload enabled (default); case-insensitive file system (Windows, macOS, etc.); malicious user with upload access

The fix

The fix makes the sanitisation of upload paths to the .git directory case-insensitive; users should upgrade to 0.12.11 or later, or disable repository upload as a workaround.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Gogs is a self-hosted Git service. On some systems, file names are not case-sensitive, so a folder named '.GIT' is treated the same as '.git'. The software only blocked the lowercase version, so an attacker could upload a file into the '.git' folder and then delete other files to make the server run their code, giving them remote access.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from gogs/gogs

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.