AWS IAM & multi-account security · Lesson 6 of 7 · 4 min read
Detection, audit and incident response
The detective stack
| Service | Role |
|---|---|
| CloudTrail | API call history — organisation trail to the log-archive account, log file validation, S3 Object Lock; data events (S3 object-level, Lambda) selectively; CloudTrail Lake for SQL queries |
| AWS Config | Resource configuration history and compliance rules (e.g. s3-bucket-public-read-prohibited); conformance packs; aggregators |
| GuardDuty | Threat detection from CloudTrail, VPC Flow Logs, DNS logs, EKS audit logs, runtime monitoring — e.g. credentials used from unusual IPs, crypto-mining |
| Security Hub | Aggregates findings and runs standards (CIS, AWS Foundational Security Best Practices) across accounts |
| IAM Access Analyzer | External/unused access, policy validation |
| Detective / Security Lake | Investigation and centralised security data |
| Macie | Sensitive data discovery in S3 |
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Leaked access key — the runbook
- Contain: deactivate the key immediately (don't just delete — you lose the reference); if a role session was stolen, revoke active sessions (IAM console "Revoke active sessions" adds a deny for tokens issued before now).
- Investigate: CloudTrail for the key ID — what was called, from where, which resources created (often EC2 for crypto-mining in many regions, new IAM users/keys for persistence).
- Eradicate: delete attacker-created resources, users, keys, roles, Lambda functions; check all regions.
- Recover: rotate any secrets the key could read; review billing.
- Learn: why a long-lived key existed and how it leaked (committed to Git → secret scanning / push protection); replace with roles/OIDC; add GuardDuty alerts and SCPs denying key creation.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Debugging AccessDenied
aws sts get-caller-identity— are you who you think you are (right role, right account)?- Read the error: modern AccessDenied messages state which policy type denied (
...with an explicit deny in a service control policy,...because no identity-based policy allows the ...). - Check: identity policy action/resource ARNs (bucket vs object ARN), conditions (region, tags, source VPC endpoint), permissions boundary, SCPs/RCPs, resource policies (S3 bucket policy, KMS key policy — encrypted objects need
kms:Decrypttoo), session policies. - Cross-account: both sides must allow; for S3 objects uploaded by another account, Object Ownership matters.
- IAM Policy Simulator and CloudTrail event (errorCode, errorMessage) to confirm.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.