You pushed a commit with AWS credentials in a config file. Maybe it was a .env file you forgot to add to .gitignore. Maybe it was hardcoded credentials in a Terraform variable file. Maybe someone on your team "just for now" put the keys in a README.
Here's what happens in the first 10 minutes. This is not speculation — it's documented attacker behavior that AWS security teams, incident responders, and researchers have observed repeatedly.
T+0:00 — The commit lands on GitHub
Your commit is public. GitHub's own secret scanning runs within seconds and will notify you — but only if you've enabled push protection and secret scanning on the repository. Most repositories don't have this configured. And even if GitHub flags it, the notification goes to your email inbox, where it may sit unread for hours.
What you don't know: automated credential harvesting bots also watch GitHub in near-real time. They monitor public repositories for patterns matching AWS access key IDs (AKIA...) using GitHub's public Events API and search API. The dwell time between a public commit and the first bot scanning it is measured in seconds to minutes.
T+0:30 — First validation call
The attacker (automated or human) runs sts:GetCallerIdentity with your credentials. This API call:
- Costs nothing (it's free)
- Confirms the credentials are valid
- Returns your AWS account ID, the IAM user or role ARN, and the user ID
- Does NOT appear in Cost Explorer — it's metadata, not billed usage
- DOES appear in CloudTrail — but only if you're watching
MITRE ATT&CK: T1078 — Valid Accounts. The attacker has confirmed initial access.
T+1:00 — Reconnaissance
Next, the attacker enumerates what the compromised credentials can do. Common calls: iam:ListUsers, iam:GetAccountSummary, iam:ListRoles, ec2:DescribeRegions, sts:GetAccessKeyInfo. Each of these is a read-only call — no cost impact, but all visible in CloudTrail.
The goal here is to understand the account's IAM permissions, whether there are other roles to assume (privilege escalation), and which regions are available to operate in.
MITRE ATT&CK: T1087 — Account Discovery, T1069 — Permission Groups Discovery.
T+2:00 — Region selection for cover
Experienced attackers deliberately operate in regions the victim has never used. Why? Because most organizations' CloudWatch alarms, security tools, and cost visibility are scoped to their primary regions. An attack in ap-southeast-1 against a company that only operates in us-east-1 and eu-west-1 is effectively invisible to their existing monitoring.
The attacker calls ec2:DescribeInstances across multiple regions to confirm which ones have no existing infrastructure — an empty response means no one is watching there.
T+3:00 — GPU fleet launch
The primary use case for stolen AWS credentials is cryptomining. The economics work: a p3.8xlarge costs $12.24/hour, runs 4 NVIDIA V100 GPUs, and can mine Ethereum (or increasingly, other proof-of-work coins) at a profit margin that pays off even after accounting for the risk of the credentials being rotated.
The attacker calls ec2:RunInstances: typically 10-50 instances in the new region, GPU instance type, with a userdata script that downloads and runs the mining software automatically. The entire operation is automated.
At 10 × p3.2xlarge ($3.06/hr each): $30.60/hour. Left running for 24 hours: $734 per day. For a serious attacker running 50+ instances: $3,600/day or more.
MITRE ATT&CK: T1496 — Resource Hijacking.
T+5:00 — Covering tracks
A sophisticated attacker's next move is to disable CloudTrail logging in the region they're operating in. The API call is cloudtrail:StopLogging. Once called, no further API activity in that trail is logged — including the mining operation itself.
This is the MITRE ATT&CK technique T1562.008 — Impair Defenses: Disable Cloud Logs. It's simple, fast, and devastatingly effective against organizations that aren't monitoring for the call itself.
Here's the critical point: StopLogging still appears in CloudTrail before logging stops. If you're watching for that call in real time, you catch it. If you're looking at CloudTrail after the fact, you'll find a gap — the log entries simply aren't there.
T+8:00 — Operational
The mining fleet is running. CloudTrail is disabled in the attack region. The attacker may also call ec2:CreateSecurityGroup to open inbound ports for pool communication, and set up IAM roles or policies to ensure the instances can communicate back to their infrastructure.
From this point, absent external detection, the operation runs until: the credentials are rotated, AWS detects the abuse and suspends the account (typically takes 24-72 hours for automated detection), or the bill is noticed on the next business day.
What real-time detection looks like
At T+0:30, when sts:GetCallerIdentity fires from an IP address that has never been seen on this account, a real-time detection system generates a low-priority signal: "credentials accessed from unknown IP."
At T+3:00, when ec2:RunInstances fires in a region with zero prior history, the signal becomes critical: "RunInstances in ap-southeast-1 — this region has NEVER been used in this account." You receive a Slack alert within minutes of the call, before the 10th instance has even finished launching.
At T+5:00, if cloudtrail:StopLogging fires, you receive an immediate alert: MITRE T1562.008 detected. You can revoke the credentials and terminate the instances before the mining operation ever becomes profitable.
The total window from detection to remediation, with real-time alerting, is 15-30 minutes. The total bill: a few dollars at most. Without real-time detection, the window is 24-48 hours, and the bill is $10,000-$100,000+.
The attackers are automated. Your detection needs to be automated too. Manual log review and daily digest emails cannot match the speed of credential abuse bots that act within 30 seconds of a public commit.
Related articles
The access key nobody retired: how to find and kill stale AWS keys
A vendor key, never retired, found in their environment. Audit commands to find unused AWS access keys, check what they did, and retire them safely.
How to audit AWS for signs of past compromise (after the Qubole breach)
A vendor's IAM credentials assumed customer roles for two weeks unnoticed. A step-by-step audit with commands: trusted roles, AssumeRole hunting, persistence.
Bought the wrong Savings Plan? You have a short window to return it
AWS lets you return a mistaken Savings Plan for a limited time. The exact rules, the calendar-month trap, and which plans cannot be returned.
Protect your AWS account — 14-day free trial
Real-time threat and cost anomaly detection. Detects credential theft, cryptomining, and runaway costs in under 15 minutes. 5-minute setup via CloudFormation.
No credit card. Cancel anytime.