All posts
Cost

AWS Cost Anomaly Detection has a 24-hour blind spot — here's why it matters

September 3, 20266 min read

AWS Cost Anomaly Detection is a free, built-in AWS service that uses machine learning to detect unexpected spending. If you're not using it, you should enable it today — it's better than nothing. But if you believe it will catch a credential theft incident before significant damage is done, this post is for you.

How AWS Cost Anomaly Detection actually works

AWS Cost Anomaly Detection runs on the AWS Cost Explorer billing pipeline. This pipeline ingests usage data from all AWS services and makes it available for querying — but that ingestion doesn't happen in real time. It happens on a daily cycle.

Here's the technical pipeline:

  1. AWS services emit usage records continuously throughout the day
  2. These records are batched and ingested into the billing system (Cost Explorer) on a roughly 24-hour cycle
  3. Cost Anomaly Detection runs its ML models against the ingested data
  4. Alerts are sent after the anomaly is confirmed against the ingested data

AWS's own documentation states that Cost Explorer data has a latency of up to 24 hours for most services. In practice, the lag from "usage occurred" to "Cost Anomaly Detection alert sent" is typically 24-48 hours. Sometimes longer on weekends or for certain service types.

The worked example: a 2am credential theft

Let's run through a real scenario. AWS credentials leak to a public GitHub repository at 2:00am on a Tuesday.

2:00am: Credentials are public. Attacker bots detect them within minutes.

2:15am: Attacker validates credentials via sts:GetCallerIdentity, runs reconnaissance.

2:25am: Attacker launches 20 × p3.2xlarge instances in ap-southeast-1 (a region the company has never used). Cost rate: $61.20/hour.

2:30am: Attacker disables CloudTrail logging in the attack region.

2:30am — 8:00am Wednesday: Mining operation runs for 29.5 hours. Total EC2 charges: $1,805.40. Plus data transfer, EBS, and other costs: ~$2,100 total.

Wait — where does the $80,000 number come from? That's if the attacker runs a larger fleet (50+ instances) or if detection takes the full 48-hour cycle.

At 50 × p3.2xlarge ($3.06/hr each): $153/hour. Over 48 hours before a Cost Anomaly Detection alert arrives: $7,344. Over a week (many incidents go unnoticed until the monthly bill review): $25,704. With a larger GPU fleet or high-cost instances: $50,000-$100,000+ is not unusual in documented incidents.

Wednesday morning: The daily billing cycle completes. Cost Explorer data is updated. AWS Cost Anomaly Detection runs its models. If the anomaly is large enough and the ML threshold is met, an alert is sent.

Wednesday 10am-2pm (approximately): Alert email arrives in someone's inbox — 30+ hours after the attack started.

Why the billing pipeline can't be made faster

This isn't a bug in AWS Cost Anomaly Detection — it's a fundamental constraint of how billing data flows. Usage records need to be batched, deduplicated, rated (priced), and ingested before anomaly detection can run against them. This process requires consistency across hundreds of services and millions of accounts. Daily batching is a reasonable engineering tradeoff for a billing system at AWS scale.

But it means that billing-based anomaly detection is structurally unsuited for real-time security incident response. You cannot make AWS Cost Anomaly Detection faster by tuning thresholds or adjusting alert frequency — the lag is in the data pipeline, not the alerting layer.

What real-time detection looks at instead

Real-time detection doesn't watch billing data. It watches API calls.

When an attacker launches GPU instances via ec2:RunInstances, that API call appears in CloudTrail within seconds. EventBridge can receive that event within seconds. A detection rule can evaluate the event — "RunInstances in a region with zero prior history" — and fire a Slack alert within minutes of the call.

This is fundamentally different from cost-based detection:

  • Cost detection: measures financial impact after the fact, with hours of lag
  • API detection: measures the action as it happens, with seconds of lag

The tradeoff is signal quality. API-based detection requires knowledge of what normal looks like at the API level — which regions, which instance types, which IAM principals launch instances in your account. Cost-based detection is simpler: "spend went up." API-based detection requires more sophisticated baselining but enables dramatically faster response.

What AWS Cost Anomaly Detection is actually good for

Don't disable it. Cost Anomaly Detection is genuinely useful for:

  • Slow-building cost increases over weeks that don't have a single anomalous API call (e.g., gradual data transfer growth)
  • Reserved Instance or Savings Plan utilization tracking
  • Identifying waste patterns across accounts that don't trigger API-level signals
  • Teams with no other monitoring as a baseline safety net

It's free, it's easy to set up, and it will catch large anomalies eventually. But for security-adjacent cost events — credential theft, cryptomining, ransomware-via-IAM — the 24-48 hour lag is the difference between a $500 incident and a $50,000 one.

Use AWS Cost Anomaly Detection as a backstop. Use real-time API monitoring as your primary line of defense. The two tools are not redundant — they watch different things at different time scales.
aws-cost-anomaly-detectioncomparisonfinops

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.