The .env File Was Just Sitting There: How a Single Cognito Misconfiguration Unlocked a Fintech’s…
A Cognito identity pool returned live AWS credentials to the browser, and those credentials had read access to production S3 buckets. The attacker used them to list buckets, find a folder named secrets, and download a production .env file containing database credentials, encryption keys, Redis URLs and an ERP password.
The client operates in financial services. Real users.
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 Cognito identity pool was configured to return AWS credentials to the browser and its role allowed reading production S3, where a .env file with secrets was stored.
Impact
An attacker could read production S3 data and obtain database, encryption, Redis and ERP credentials, enabling lateral movement and compromise of user data; the credentials expired after one hour but that did not prevent the exposure.
What the attacker needed
Authorized bug bounty scope; victim uses the web app; no account needed to observe
The fix
The organisation acknowledged the finding and remediated the issue; the write-up recommends server-side token exchange, least-privilege identity pool roles, moving secrets to Secrets Manager, deny-by-default bucket policies and rotating all exposed secrets.
How it was found
- Intercept the browser's request to Cognito GetCredentialsForIdentity in Burp Suite.
- Observe the response contains AccessKeyId, SecretKey and SessionToken.
- Export the credentials and run aws s3 ls to list buckets.
- List the production bucket and spot a secrets/ prefix.
- Download the .env file from that prefix.
- Enumerate IAM users and their attached policies.
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.
AWS Cognito is a login service. When set up wrongly, it can hand out temporary cloud keys to whoever is using the website. Here those keys could read private storage, and a file full of passwords was sitting in that storage.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.