Detection, logging and monitoring
If something bad happened in this AWS account tonight, would anyone know, and could anyone work out what happened?
Blackpine, a fictional five-person invoicing SaaS with no security person.
CloudTrailVPC Flow LogsAWS ConfigEventBridgeSNSAthenaS3
Read the write-upFour questions need answers: who did what and when, who talked to whom over the network, is each resource set up the way it should be, and will a human actually be told when something important happens.
Architecture
What I built
- 1A multi-region CloudTrail trail to S3 with log file validation on.
- 2VPC Flow Logs on the VPC, into the same bucket.
- 3AWS Config with three managed rules over a small set of resource types.
- 4Config immediately flagged the app server security group. Fixed it.
- 5An SNS topic with an email subscription, then an EventBridge rule for root console login.
- 6Signed in as root to test it. No email came.
- 7Found why, rebuilt the rule in the right region, and the email arrived.
- 8Athena tables over CloudTrail and Flow Logs, then ran SQL against my own logs and read what they said.
What broke and how I fixed it
- The root sign-in alert never arrived because those events only reach EventBridge in us-east-1. A direct SNS test isolated it to the rule rather than the topic.
- AWS Config flagged the app's own security group with port 22 open to 0.0.0.0/0, against its own design. Fixed and re-checked.
- CloudTrail and Flow Logs are the raw evidence. Config gives an opinion about it. EventBridge and SNS make sure a person hears about it. Athena is how you ask questions later.