Chapter 13: Auditing an inherited setup¶
Assume nothing. Look before you change anything.
- What's running and how:
docker ps -a; for each container,docker inspect -f '{{index .Config.Labels "com.docker.compose.project.config_files"}}'→ which compose file? (In the Chapter 1 incident: the development file on both servers.) - What's exposed:
sudo ss -tlnp; externalncto every listening port; the security group's inbound rules. - Where the data really lives: the app's
DB_HOST(in the Chapter 1 incident, the local DB container on production was an unused leftover; the real database was RDS). - Which DB user the app uses and whether it's a superuser.
- Database roles and settings: unknown superusers,
pg_hbarules,pg_file_settings(pending settings),postgresql.auto.conf, hidden files in the data dir. - History: instance launch time,
authorized_keysdates, data-dir dates,last -a. Was this server cloned from another? - AWS side: RDS public access + SG; VPC default SG rules and members ("Related resources" tab); CloudTrail for who changed SGs (
AuthorizeSecurityGroupIngress) and who read secrets (GetSecretValue). - Run a read-only triage script (
tools/triage-host.shin this book checks all of the above and flags RED/AMBER).