GSEC · Question #245
Which practice can help protect secrets in a cloud environment?
The correct answer is C. Excluding the tfstate file from code repositories. Terraform state files store resource attributes in plaintext, including sensitive values like passwords and API keys, making them a critical secret exposure risk if committed to version control.
Question
Which practice can help protect secrets in a cloud environment?
Options
- AAvoiding the use of Terraform variables
- BRunning privileged docker runtime
- CExcluding the tfstate file from code repositories
- DUsing the -net-host flag
How the community answered
(49 responses)- A8% (4)
- B16% (8)
- C71% (35)
- D4% (2)
Why each option
Terraform state files store resource attributes in plaintext, including sensitive values like passwords and API keys, making them a critical secret exposure risk if committed to version control.
Terraform variables are a recommended practice for parameterization and can even reference environment variables or secret managers, so avoiding them does not protect secrets.
Running a privileged Docker runtime expands the attack surface and grants the container elevated host permissions, which is a security risk rather than a protection.
The tfstate file persists all infrastructure state including sensitive data such as database passwords, private keys, and connection strings in plaintext JSON. Committing this file to a code repository exposes these secrets to anyone with repository access. Excluding it via .gitignore and using remote state backends with encryption is the correct mitigation.
The --net=host flag shares the host network namespace with the container for networking purposes and has no relationship to secret management or protection.
Concept tested: Terraform state file secret exposure risk
Source: https://developer.hashicorp.com/terraform/language/state/sensitive-data
Topics
Community Discussion
No community discussion yet for this question.