Skip to content
Info disclosure Write-up Intermediate

Leaked .git folder leads to RCE

An exposed .git folder allowed reconstruction of a WordPress site's source code, including wp-config.php with database credentials. Those credentials worked on an Adminer interface, giving the attacker database access and a path to arbitrary SQL execution and potential remote code execution.

James Clee Follow

Published on james-clee.com

Today I wanted to share my first big success story from my bug bounty attempts. Although the issue has been fixed, the report has not been officially disclosed yet.

James Clee (@jtcsec), on james-clee.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

Impact

The attacker could read and modify the WordPress database, including user accounts and password hashes, and potentially escalate to remote code execution; the program asked the researcher to stop and changed the credentials, and verified both paths could most likely have been successful.

What the attacker needed

Exposed .git folder; database credentials in config file; Adminer accessible

The fix

The exposed .git folder and Adminer interface should be removed from public access, and database credentials should not be committed to repositories or reused across services.

How it was found

  1. Run a directory scan and notice the .git folder and artifacts.
  2. Use a tool to reconstruct the git repository and retrieve the source code.
  3. Find wp-config.php in the retrieved files and extract the database credentials.
  4. Locate an Adminer interface on the site and log in with the extracted credentials.
  5. Use Adminer's SQL command interface to run arbitrary SQL commands.

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.

A .git folder is part of a version control system that developers use to track changes; if it is left on a public web server, anyone can download it and rebuild the source code. Here the rebuilt code contained a configuration file with the database username and password. The attacker used those credentials on a database management tool called Adminer to log in and run SQL commands, which could lead to taking over the server.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.