How to Detect AWS Access Key Compromise with Wazuh

· Original article ↗

Summary

A hands-on guide configures Wazuh to ingest AWS CloudTrail and GuardDuty logs, correlate suspicious access-key activity, and alert on validation, enumeration, persistence, and exfiltration signals.

Key points

  • The guide uses CloudTrail API events and GuardDuty findings, exported to S3, as telemetry for detecting suspected compromised AWS access keys.
  • Wazuh rules flag key validation from untrusted IPs, repeated AccessDenied errors, suspicious credential or user creation attempts, and GuardDuty exfiltration or anomalous-behavior findings.
  • Correlation rules alert when validation and persistence activity match the same IAM identity within 900 seconds, regardless of event processing order.
  • The demonstration emulates validation, permission probing, and a denied attempt to create a backup access key; it uses a GuardDuty sample finding to test ingestion and rule matching.
  • The article notes that S3 interval polling can miss out-of-order delivery files and recommends SQS-based CloudTrail collection where detection completeness matters.
  • Recommended protections include replacing long-lived keys with short-lived credentials, restricting credential use by network, scanning for exposed secrets, and quarantining compromised keys.

Article Details

Defense Focus
Detect AWS access key compromise by correlating CloudTrail API activity with GuardDuty findings to identify a compromise chain and alert security teams.
Detection Methods
  • Flag sts:GetCallerIdentity and sts:GetSessionToken calls from source IP addresses absent from the trusted-IP list, excluding listed service identities.
  • Detect six or more AccessDenied events from the same IAM identity within 900 seconds as possible permission enumeration.
  • Flag CreateAccessKey, CreateUser, or AttachUserPolicy calls from untrusted IP addresses by identities absent from the service-identity list; the rule alerts even when the operation is denied.
  • Match GuardDuty findings for credential exfiltration or anomalous behavior.
  • Correlate validation and persistence events for the same IAM identity in either processing order within 900 seconds.
Data Sources
  • AWS CloudTrail management events, including source IP, IAM identity, API event name, and AccessDenied errors.
  • Amazon GuardDuty findings exported to Amazon S3, including credential-exfiltration and anomalous-behavior findings.
Rule Types
  • Custom Wazuh XML rules using event-field matching and exact-match CDB lists for trusted IP addresses and excluded service identities.
  • Frequency-and-timeframe rule for repeated AccessDenied events.
  • Same-identity correlation rules with a 900-second window that support either event-processing order.
Platforms
  • Centralized deployment with server, indexer, and dashboard components.
Defensive Actions
  • Prefer IAM roles and short-lived credentials over long-term access keys.
  • Use the Wazuh AWS module's SQS-based CloudTrail collection where detection completeness matters; interval polling can miss out-of-order delivery files.
  • Use a service control policy or resource control policy to restrict credential use to corporate CIDR ranges or expected VPCs.
  • Enable CloudTrail log-file integrity validation and restrict access to the log bucket.
  • Rotate access keys and scan repositories and CI/CD configuration for committed secrets.
  • Keep trusted-IP and service-identity lists current as egress addresses and service identities change.
  • Use AWSCompromisedKeyQuarantineV2 to automatically deactivate a stolen access key.
  • Enable IAM Access Analyzer and enforce least privilege.

MITRE ATT&CK

Vendors

Products

Related Articles