Why you need to be careful with secrets in your cloud:
Secrets and terraform state:
Terraform state can be stored in many places: locally, on a cloud provider its storage solution, etc.. It can easily happen that secrets end up in Terraform state, as the systems which are created by it often needs to communicate with other systems for which it requires authentication. So, ensure that secrets are always encrypted in terraform state, or ensure that all secrets are stored in a secrets management system. Alternatively, ensure the secret is created in Terraform, but the value is set and managed through a different process.
Note that secrets are not the only reason not to let people access terraform state. TF state read access can expose configuration details to unauthorized eyes, while terraform write access can allow an attacker to setup a bogus state which, on the next terraform apply-run ends up with unauthorized changes.
Access to the Administrator/owner account:
If you were able to use the AWS administrator account to access the data, then you can see why this is a bad idea for production. Because with this account you can change anything within the account, and you can easily exfiltrate any of the secrets.
Last but not least: we could easily exec into the container, to grep the mount with the secret. This has to do with 3 things:
-
we are allowed to do so by means of RBAC, which should not be your normal case in PRD: otherwise everybody of your organization can poke around in the container.
-
we are having executables within the container (sh/openssl/etc) which we can execute to setup a shell. Stripping your container from any non-necessary binary can help to reduce attack-surface and make it harder for any attacker that did an RCE at your container to jump to other places within the container to further gain execution.
-
we have exposed the configmap as an ENV. This means that anybody who got to the container runtime within the pod can now dump the secret. We brought the secret close to the consumer, but maybe not close enough yet (e.g. the app only).