Exposed .env File Leads To API Key Leak & Financial Impact
A publicly accessible .env file exposed API keys that were valid and tied to a billing account. An attacker could use these credentials to consume the company's API balance and cause financial loss.
medium.com
Published on medium.com
Hello everyone, I’m Sherlok, and today I’d like to share how I discovered an exposed .env file that led to leaked API credentials and real financial impact.
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 web server was misconfigured to serve the .env file publicly without any access restriction.
Impact
An attacker could consume the company's API balance, automate large-scale API usage, exhaust quota causing denial of service, and use the API for unauthorized data enrichment.
What the attacker needed
Publicly accessible .env file; no authentication required
The fix
The backend should block access to .env files at the web server level, store secrets outside the web root, rotate all leaked credentials, and monitor usage for abuse.
How it was found
- Use a browser extension to detect exposed .env files.
- Open the .env file and note the API keys.
- Use curl to send an authenticated request with the key.
- Check if the key can access account balance information.
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 .env file is a configuration file that often stores secret keys and passwords. If it is left publicly accessible on a website, anyone can read those secrets. Here, the keys allowed access to an API that costs money, so an attacker could run up bills.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.