Untrusted Terraform Modules

Untrusted Terraform Modules

A module pinned to a branch can change under you.

What Is Untrusted Terraform Modules?

A Terraform module source is a remote code dependency that provisions with your credentials. A networking module pinned to a branch gains a commit that adds an IAM role trusting an outside account, and the next apply creates it, three lines in a diff nobody reads. You'll watch the outside account assume that role and read a production export, then pin the module to a reviewed commit so a new push no longer changes your infrastructure, and commit the provider lock file so a provider cannot change under you either.

What You'll Learn in Untrusted Terraform Modules

Untrusted Terraform Modules — Training Steps

  1. A module pinned to a branch

    Bob maintains a public networking module that many accounts use. He has noticed that Rudmoss pins it to a branch, not a commit, so whatever he pushes to that branch, Rudmoss applies. Rudmoss runs a workforce scheduling platform on AWS.

  2. Whatever the branch becomes

    The source points at the module's main branch. Every apply pulls whatever is on that branch at the time, which is not necessarily what Rudmoss reviewed.

  3. Open the module

    Bob controls the module's code. He opens its IAM file to add something that looks like part of the networking.

  4. Add a role that trusts him

    Next to the flow-log resource, which belongs here, Bob adds an IAM role whose trust policy names his own AWS account. In a hundred-line module it reads as more networking.

  5. Three lines that matter

    The role grants whoever can assume it read access to the account's storage, and the account allowed to assume it is Bob's.

  6. Push it to the branch

    Bob pushes the change to the module's main branch. From this moment, every account pinned to that branch gets the role on its next apply.

  7. Assume the role

    The role now exists in Rudmoss's production account, and its trust policy names Bob's account. He assumes it.

  8. Read a production export

    The role carries S3 read across the account. Bob reads a customer export straight out of production storage.

  9. Where the role came from

  10. A role trusting a stranger

    Rudmoss's monitoring flags a new IAM role whose trust policy names an external account, created by the nightly pipeline, and an S3 export read from that account.

Security Framework Coverage

CWE

  • CWE-494 Download of Code Without Integrity Check
  • CWE-829 Inclusion of Functionality from Untrusted Control Sphere

MITRE ATT&CK

  • T1195.001 Supply Chain Compromise: Compromise Software Dependencies and Development Tools

CIS Controls

  • CIS 2 Inventory and Control of Software Assets
  • 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
  • ID.AM Asset Management
  • PR.PS Platform Security

NICE Framework

  • DD-WRL-004 Secure Systems Development
  • IO-WRL-005 Systems Administration