hackweb
notes on hacking and technology
IT EN
main menu
user menu
you are not logged in

IaC and secrets: Terraform state in the clear

January 8, 2025 · 1 min read · #cloud #iac #secrets

Infrastructure as Code describes infrastructure in versioned files. The recurring problem is secrets: DB passwords, keys, tokens end up in the code or the state.

Where they leak

Terraform's state stores resource attributes, including generated secrets, in cleartext. If the state lands in git or a poorly protected S3 bucket, the secrets are exposed. Other classics: hardcoded values in .tf files, and secrets in the CI/CD plan (logs).

grep -i 'password\|secret\|key' terraform.tfstate
# often full of credentials

Defence

Encrypted remote backend for the state (S3 + KMS, Terraform Cloud) with restricted access, never in git. Secrets from a secret manager referenced at runtime, not hardcoded. Repo scanning (gitleaks, trufflehog) and CI plan scanning. Mark sensitive outputs.


« back to home

latest posts
 
your IP address:
216.73.216.108
visitor #1
MOTD:
Every abstraction leaks somewhere.
Here we look at where.
topics