How to fix: Terraform provider lockfile exposed
The response is a .terraform.lock.hcl file: registry.terraform.io provider blocks with their recorded hashes.
Why it matters
The provider list is an inventory of the infrastructure itself. Seeing aws, cloudflare, vault, datadog and a database provider together tells an attacker which cloud the estate runs on, which secret store it uses, and which SaaS platforms hold an API token for this organisation, before any other reconnaissance. The pinned provider versions also indicate how recently the infrastructure code was touched.
Rated above the language lockfiles because of what it implies rather than what it contains: this file only exists inside a Terraform working directory, so its presence under a web root means infrastructure code was deployed alongside the application. The files beside it are the real exposure. terraform.tfvars and any .tfstate in the same directory routinely contain credentials and full resource inventories.
How to fix it
- 1Remove the Terraform working directory from the web-served path immediately.
- 2Check the same directory for terraform.tfvars, *.auto.tfvars and *.tfstate, and treat every value in them as compromised.
- 3Rotate any credential that could have been in those files.
- 4Move state to a remote backend with access control so it is never a file on an application host.
Code examples
Check what else is reachable in that directory
for f in terraform.tfstate terraform.tfvars terraform.tfstate.backup .terraform.lock.hcl; do
printf '%s ' "$f"
curl -s -o /dev/null -w '%{http_code}\n' "https://example.com/$f"
doneUse a remote backend instead of local state
terraform {
backend "s3" {
bucket = "example-tf-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
encrypt = true
dynamodb_table = "tf-state-lock"
}
}References
Detected automatically by VulnRadar. The check id is supply-chain-terraform-lock-exposed, stable across every scan so you can filter or diff on it.
More supply chain checks
- Mediumnpm/yarn Lock File Exposed
- MediumPython Requirements File Exposed
- MediumRuby Gemfile or Gemfile.lock Exposed
- MediumExternal CDN Script Without SRI Hash
- HighHTTP Script Loaded on HTTPS Page
- MediumPHP composer.json or composer.lock Exposed
- HighDockerfile or docker-compose.yml Exposed
- Critical.env File Exposed at Public URL
Questions
- How severe is Terraform provider lockfile exposed?
- VulnRadar rates this medium severity in the supply chain 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 supply-chain-terraform-lock-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Terraform provider lockfile exposed map to?
- It maps to CWE-540. 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.