Skip to content

Chapter 13: Auditing an inherited setup

Assume nothing. Look before you change anything.

  1. 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.)
  2. What's exposed: sudo ss -tlnp; external nc to every listening port; the security group's inbound rules.
  3. 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).
  4. Which DB user the app uses and whether it's a superuser.
  5. Database roles and settings: unknown superusers, pg_hba rules, pg_file_settings (pending settings), postgresql.auto.conf, hidden files in the data dir.
  6. History: instance launch time, authorized_keys dates, data-dir dates, last -a. Was this server cloned from another?
  7. 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).
  8. Run a read-only triage script (tools/triage-host.sh in this book checks all of the above and flags RED/AMBER).