Skip to content
Leaked secrets Write-up Intermediate

Large-Scale Data Exfiltration: Exploiting Secrets in .env Files to Compromise Cloud Accounts and Inflict Severe Business Degradation

Attackers exploited publicly accessible .env files to obtain AWS access keys, then used those keys to escalate privileges and create a Lambda function that scanned for more exposed .env files and exfiltrated credentials. They then used the stolen credentials to access S3 buckets, exfiltrate data, delete it, and leave ransom notes.

Ofir Yakovian Follow

Published on infosecwriteups.com

{{media:0}}

Ofir Yakovian, on infosecwriteups.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 the web server was misconfigured to serve .env files publicly, and the exposed AWS access keys had excessive permissions that allowed privilege escalation.

Impact

Attackers could compromise cloud accounts, exfiltrate sensitive data from S3 buckets, delete the data, and demand ransom, affecting approximately 110,000 domains and exposing over 90,000 credentials.

What the attacker needed

Web server misconfigured to serve .env files; AWS access keys with sufficient permissions; No additional authentication required

The fix

Organizations should properly configure web servers to block access to .env files and avoid using long-term AWS access keys, instead using temporary credentials with least privilege.

How it was found

  1. Scan domains for publicly accessible .env files.
  2. Extract AWS access keys from the .env file.
  3. Use the keys to call AWS APIs and discover account details.
  4. Create a new IAM role with administrator permissions and assume it.
  5. Create a Lambda function that scans for more .env files and uploads credentials to an attacker-controlled S3 bucket.
  6. Use stolen credentials to access S3 buckets, exfiltrate data, delete it, and leave a ransom note.

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 holds secret keys and passwords. If a web server is misconfigured, anyone can download this file by visiting a special URL. Attackers found many such files, took the cloud keys inside, and used them to break into cloud accounts, steal data, and demand ransom.

What is Leaked secrets?

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.