Terraform Plan Leaks

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

Terraform Plan Leaks — Training Steps

  1. 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.

  2. Connect with it

    A connection string is host, user, and password in one line. Bob points a client straight at the production booking database.

  3. Read the bookings

    The credential came from a public comment, and it opens the production database. Bob reads the bookings table.

  4. Why the plan printed it

  5. 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.

  6. The output that printed

    The value came from an output the stack publishes so other stacks can read the database endpoint. Alice opens it.

  7. 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.

  8. 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.

  9. 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.

  10. 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