From a Single .git Directory to Full AWS Compromise
An exposed .git directory allowed the full source repository to be reconstructed, revealing valid AWS access keys in commit history. Those overly permissive credentials gave the attacker full read and write access to S3 buckets containing sensitive data.
medium.com
Published on medium.com
In this article, I’ll walk through one of my recent security finding that demonstrates how a seemingly low-risk misconfiguration — an exposed .git directory—can escalate into a full AWS cloud compromise, including leaked credentials, unrestricted S3 bucket access, and excessive IAM permissions.
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 the .git directory was deployed to the public web root and never blocked, and secrets were committed to the repository and left valid with excessive permissions.
Impact
The attacker could exfiltrate sensitive data including PII and card details, modify or inject content, and permanently destroy data, with no defence mentioned.
What the attacker needed
Publicly accessible .git directory; valid AWS keys in commit history; overly permissive IAM policy
The fix
The .git directory should be blocked from public access, secrets should never be committed and should be rotated, and IAM permissions should follow least privilege.
How it was found
- Find that the .git directory is accessible over HTTP.
- Dump and reconstruct the repository locally with a git dumping tool.
- Search the commit history and configuration files for credentials.
- Test the found AWS keys with the AWS CLI.
- Enumerate IAM permissions and list S3 buckets.
- Download, upload, overwrite and delete S3 objects.
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 website's .git folder is like a backup of all the code and its history. If it is left public, anyone can download it and look for secrets such as cloud passwords. Here, old cloud keys were found and still worked, letting the attacker read and change files stored in the company's cloud storage.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.