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

OS Command Injection in file editor in Gogs

A malicious user could update a crafted config file in the repository's .git directory and combine it with crafted file deletion to gain SSH access to the server. All installations with repository upload enabled 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. All installations with repository upload enabled (default) are affected.

Patches

File deletions are prohibited to repository's .git directory. Users should upgrade to 0.12.9 or the latest 0.13.0+dev.

Workarounds

N/A

References

https://huntr.dev/bounties/776e8f29-ff5e-4501-bb9f-0bd335007930/

For more information

If you have any questions or comments about this advisory, please post on #7000.

From the GitHub Advisory Database (GHSA-67mx-jc2f-jgjm, 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 file editor allowed writing to and deleting files inside the repository's .git directory, which should be protected.

Impact

An attacker with upload access could gain SSH access to the server, affecting all installations with repository upload enabled.

What the attacker needed

Repository upload enabled (default); malicious user account

The fix

File deletions to the repository's .git directory were prohibited, and users should upgrade to version 0.12.9 or later.

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.

A user with upload access could place a special file inside the hidden .git folder that controls how the repository works. By also deleting certain files, they could trick the server into letting them log in remotely as if they were the server itself.

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.