Skip to content
Path traversal Write-up Advanced

Securing Developer Tools: Unpatched Code Vulnerabilities in Gogs (2/2)

Gogs, a self-hosted Git service, contained a path traversal in its file deletion feature and an argument injection in its changes preview, both of which let an authenticated attacker delete or truncate internal Git metadata and thereby run arbitrary commands on the server. The maintainers stopped responding and all four reported issues remain unpatched in the latest release.

Thomas Chauchefoin Follow

Published on sonarsource.com

In last week's blog post, we examined an unfixed vulnerability in Gogs, an open-source solution for self-hosting source code. The flaw is one of four vulnerabilities we discovered and reported to the maintainers.

Thomas Chauchefoin (@swapgs), Paul Gerste, on sonarsource.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

How it worked

Root cause

Likely user-controlled paths were passed to file deletion and to a git command without validation, and Git's fallback to treating a directory as a bare repository let the attacker supply their own configuration.

Impact

An authenticated attacker could run commands as the Gogs service user, reading, modifying or deleting all hosted source code and reaching internal hosts, and could read configuration secrets; the text notes the default configuration is vulnerable for these two issues.

What the attacker needed

An authenticated account; ability to create or edit a repository; default configuration

The fix

The maintainers did not fix the issues, so the researchers published patches that validate the user-controlled path and add end-of-options arguments, and recommend migrating to a maintained fork.

How it was found

  1. Create or use a repository and open the file deletion feature in the web interface.
  2. Confirm the deletion with a crafted file path that reaches the repository's internal Git metadata.
  3. Remove the metadata file that marks the checkout as a normal repository.
  4. Place repository files that make Git treat the checkout as a bare repository with attacker-controlled configuration.
  5. Trigger a Git operation so the configuration causes a command to run.

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 write-up has not been written yet. The Original tab links to the source.

Gogs is software that lets a team host its own code repositories. Two of its features trusted a file name supplied by the user without checking it: one let a user point the delete action at internal bookkeeping files, and the other let a crafted file name add extra options to a command the server runs. Once those internal files were damaged, the server could be tricked into running commands the attacker chose.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by Thomas Chauchefoin

View all

3 more disclosed reports, best first.

More from Gogs

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.