How to fix: Terraform State File (.tfstate) Publicly Accessible
The response body matches the structural shape of a Terraform state file: a terraform_version version string, a lineage UUID, and a top-level resources array, all present in the same JSON document. This checks the .tfstate format itself, not just a filename in a URL.
Why it matters
Terraform state routinely stores resource attributes in plaintext, including database passwords, private keys, API tokens, and connection strings generated by providers, alongside a complete map of the account's infrastructure (instance IDs, internal IPs, security group rules). Anyone who can fetch this file can extract working credentials and a blueprint of the environment.
Teams sometimes commit terraform.tfstate to a public repository, serve it from a public S3 bucket or web root, or leave a local backend's state file inside a publicly deployed build directory. Terraform state was never designed to be exposed: it is meant to be read only by the Terraform CLI against an access-controlled backend.
How to fix it
- 1Immediately remove the file from public access and rotate every credential that could appear in a resource's attributes (database passwords, generated API keys, TLS private keys).
- 2Move to a remote backend with access control and encryption at rest: S3 with a bucket policy plus DynamoDB locking, or Terraform Cloud/Enterprise.
- 3Add *.tfstate and *.tfstate.backup to .gitignore and to your build's exclude list so it is never committed or bundled into a deployable artifact.
- 4Enable state file encryption and restrict backend bucket/API access to the CI/CD identity only.
Code examples
S3 remote backend with encryption and locking
terraform {
backend "s3" {
bucket = "my-org-tfstate"
key = "prod/terraform.tfstate"
region = "us-east-1"
encrypt = true
dynamodb_table = "terraform-locks"
}
}.gitignore: never commit state
*.tfstate
*.tfstate.*
.terraform/References
Detected automatically by VulnRadar. The check id is terraform-state-file-exposed, stable across every scan so you can filter or diff on it.
More info disclosure checks
- MediumRails Session Cookie Missing HttpOnly Flag
- InfoServer header truncated
- InfoPHP session cookie naming exposes runtime
- Infoconfig.js / settings.js referenced (verify contents)
- Infoenv.js / environment.js referenced (verify contents)
- InfoSitemap.xml publicly accessible
- InfoOpenAPI schema version exposed in URL
- LowCORS exposes internal CDN hostname
Questions
- How severe is Terraform State File (.tfstate) Publicly Accessible?
- VulnRadar rates this critical severity in the info disclosure category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id terraform-state-file-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Terraform State File (.tfstate) Publicly Accessible map to?
- It maps to CWE-538. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.