What happened
Replaying the .env file extortion intrusion / reported by Unit 42 in August 2024
- 1
Exposed .env file
Date not statedScanners request the .env file from victims' web applications, and the servers return it with long-term AWS access keys in cleartext.
- 2
The stolen key in the account
Date not statedThe key is used through Tor to map the account's IAM users, S3 buckets and SES settings, then creates a role and attaches AdministratorAccess to it.
- 3
Compute for the attacker
Date not statedAn EC2 instance launch fails for lack of permissions; a Lambda function with the new admin role then runs a .env scanner in every enabled region and stores the credentials it finds in the attackers' public bucket.
- 4
Data held for ransom
Date not statedBucket objects are copied out through a VPN and deleted, and a ransom note is uploaded to the emptied bucket; the data is not encrypted.
S3 buckets of multiple organizations were copied out, emptied and left with a ransom note; the campaign targeted 110,000 domains. How many organizations were extorted, which buckets were emptied and how much data was taken are not stated.
Where cloud-provider controls fit
An AWS WAF protection pack (web ACL) that blocks requests for the .env file's path refuses the request only where your site's traffic passes through a resource the pack protects; the sources do not say where the web servers ran. With the key in hand, a service control policy that refuses calls from outside your networks would have refused the account mapping from Tor. One that refuses IAM user calls without MFA refuses it only if the key belonged to an IAM user; the report also calls the credential a role, and the MFA statement does not refuse a role's calls. A service control policy that keeps role creation and administrative policy attachment to approved administrators would have refused the admin role. A permissions boundary refuses the same calls only while the credential cannot remove it, and the sources do not state its other permissions. The EC2 launch failed in the incident for lack of permissions, so a service control policy on EC2 launches had nothing left to prevent there. Service control policies on Lambda creation and on approved regions would have bounded the scanner, though the sources do not say whether the key belonged to an exempt deployment pipeline. A resource control policy that keeps S3 to your networks would have refused the reads from the VPN; resource control policies date from after the incident. A bucket policy carries the same deny, but the attackers' admin role could edit it. S3 Object Lock in compliance mode would have kept the deleted versions.
Could this have been prevented?
In hindsight, not as a whole. 3 controls would have refused a step outright, and 9 controls would have limited one. The counts below are control assessments, not attack stages: several can address the same step. The same replay with the controls in place before the incident shows where each phase would have been refused or bounded.
- 3
- Prevented
- 9
- Contained
- 0
- Not covered
How it could have been prevented
The same replay with the controls in place. Green marks where a step is refused, blue where it is bounded, and red where no control reaches it. Open a row to read the control, why it acts, and its caveat.
Replaying the .env file extortion intrusion / reported by Unit 42 in August 2024
1 · Exposed .env file
1 Contained3 on other clouds2 · The stolen key in the account
2 Prevented2 Contained6 on other clouds3 · Compute for the attacker
3 Contained6 on other clouds4 · Data held for ransom
1 Prevented3 Contained6 on other cloudsKey facts
- The campaign targeted 110,000 domains; Unit 42 counted over 90,000 unique leaked variables, about 7,000 of them for cloud services and 1,515 for social media accounts
- The stolen key was used through Tor for reconnaissance; the identity check, the IAM user and S3 bucket listings and the SES discovery calls succeeded
- The credential was not an administrator but could create roles and attach policies; a new role received the AWS managed policy AdministratorAccess. The report calls the credential both an IAM user and an IAM role
- A security group open on all ports, a key pair and an EC2 instance were attempted within a minute and failed for lack of permissions; Unit 42 judged the instance was meant for cryptomining
- A Lambda function with the new role was deployed to every other enabled region within a second; the scan lists in the attackers' public bucket held more than 230 million unique targets
- S3 objects were copied out through a VPN and deleted, and a ransom note was left in the emptied bucket; the data was not encrypted. Unit 42 published on August 15, 2024, and AWS said its services were not affected
Sources
Every fact in this breakdown comes from the public reporting below. The replay is a model of that reporting, not a reconstruction of the environment it describes.
- 1.Leaked Environment Variables Allow Large-Scale Extortion Operation in Cloud EnvironmentsUnit 42 (Palo Alto Networks) · Sep 3, 2024 · ResearchEntry vector, discovery calls, privilege escalation, failed EC2 attempt, Lambda scanner, S3 exfiltration and deletion, ransom note, counts, source networks, remediation advice
- 2.Large-scale extortion campaign targets publicly accessible environment variable files (.env)Security Affairs · Aug 18, 2024 · NewsAWS statement on the cause
The estate in the replay is illustrative and drawn at the level of attack stages; the victim's real environment is not public. Verdicts describe what a control does when it is in place before the incident. They are not an assessment of the victim's security program.