Terraform Plan Leaks
The plan printed a database password in a public comment.
What Is Terraform Plan Leaks?
A Terraform plan is a diff of real values, and a CI bot posts it to a public pull request. An output holding a database connection string prints in full, password and all, because nobody marked it sensitive. You'll lift the credential from a plan comment, open the production database with it, then mark the output sensitive so the plan redacts it. Because sensitive only hides the display while the value still sits in state, you'll also confirm that the credential which already printed was rotated and the leaked copy is dead.
What You'll Learn in Terraform Plan Leaks
- A plan renders the real value of every output and changed attribute, so an unmarked secret is printed where the plan is posted.
- Marking a variable or output sensitive redacts it in plan and apply output, so a public comment no longer carries the value.
- Sensitive hides the display only; the value still lives in state, so the backend needs protecting and the leaked copy needs rotating.
- Plan artifacts should be kept off public logs and comments, and secrets passed by reference rather than printed.
Terraform Plan Leaks — Training Steps
-
A plan in a public comment
Bob watches public infrastructure repositories for the plan output their pipelines post on each pull request. Lorvane's booking-infra repo is public, and its bot posts the full plan. Lorvane runs a travel booking platform.
-
Connect with it
A connection string is host, user, and password in one line. Bob points a client straight at the production booking database.
-
Read the bookings
The credential came from a public comment, and it opens the production database. Bob reads the bookings table.
-
Why the plan printed it
-
A credential in a public comment
Lorvane's secret scanner flags a database connection string in a plan comment on the public booking-infra repo, and the database shows a read from an unknown address.
-
The output that printed
The value came from an output the stack publishes so other stacks can read the database endpoint. Alice opens it.
-
Nothing marks it secret
The output's value is a full connection string, and the output carries no sensitive flag, so the plan renders it and the bot posts it.
-
Mark it sensitive
A sensitive output is still produced and still usable by other stacks, but the plan renders it as a redacted placeholder instead of the real value.
-
Redacted, not removed
The plan will now hide the value. It is important to be clear about what that does and does not do: the display is redacted, but the value is unchanged, and it still sits in the state in plaintext.
-
The plan redacts it now
A new pull request runs the plan again. The output that leaked the connection string is now rendered as a placeholder.
Security Framework Coverage
CWE
- CWE-532 Insertion of Sensitive Information into Log File
- CWE-200 Exposure of Sensitive Information to an Unauthorized Actor
MITRE ATT&CK
- T1552 Unsecured Credentials
CIS Controls
- CIS 3 Data Protection
- CIS 16 Application Software Security
NIST CSF
- PR.AT-02 Individuals in specialized roles are provided with awareness and training so that they possess the knowledge and skills to perform relevant tasks with cybersecurity risks in mind
- PR.DS Data Security
- PR.PS Platform Security
NICE Framework
- DD-WRL-004 Secure Systems Development
- IO-WRL-005 Systems Administration