TF007–TF012 · CIS AWS v5.0 5.6 / 2.3.1 / 3.6 · SOC 2 CC6.7

Fix Terraform EC2 IMDSv1 & Unencrypted RDS, EBS & KMS

Stop SSRF credential theft with IMDSv2 (http_tokens = "required", TF009) and close RDS/EBS/KMS encryption and CloudTrail audit gaps (TF007–TF012) directly in your browser—0 bytes uploaded.

Scan EC2 / RDS TF (0 Upload) Pro CLI Pack $49 →

0 bytes uploaded · 0 AWS keys · One-time local CLI, SARIF 2.1.0 & SOC 2 CC6.1/CC6.7 dossier via Polar.sh.

TF009 (EC2 IMDSv2 Required) TF007 / TF010 (RDS & EBS KMS) TF011 / TF012 (KMS Rotation & CloudTrail) 0 Network Requests During Scan
1. Load an EC2/RDS Terraform Sample or Drop Local .tf Files
Drag & drop local Terraform .tf files — scanned strictly in browser memory.

Vulnerable vs. Hardened EC2, RDS & KMS Terraform (Before & After)

Enforce metadata_options { http_tokens = "required" } on every EC2 instance and launch template to block IMDSv1 SSRF attacks, encrypt RDS and EBS root volumes with a rotating customer-managed KMS key (enable_key_rotation = true), and enable multi-region CloudTrail with log file validation.

Vulnerable · TF005 · TF007 · TF009 · TF010 · TF011 · TF012
resource "aws_instance" "api_worker" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.medium"

  root_block_device {
    volume_size = 50
    encrypted   = false
  }

  metadata_options {
    http_endpoint = "enabled"
    http_tokens   = "optional"
  }
}

resource "aws_db_instance" "orders" {
  identifier          = "orders-prod"
  engine              = "postgres"
  instance_class      = "db.t4g.medium"
  storage_encrypted   = false
  publicly_accessible = true
}

resource "aws_kms_key" "app_data" {
  description         = "App data key"
  enable_key_rotation = false
}
Hardened · 100/100 (Grade A · 0 Findings)
resource "aws_kms_key" "app_data" {
  description         = "App data CMK with annual rotation"
  enable_key_rotation = true
}

resource "aws_instance" "api_worker" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.medium"

  root_block_device {
    volume_size = 50
    encrypted   = true
    kms_key_id  = aws_kms_key.app_data.arn
  }

  metadata_options {
    http_endpoint               = "enabled"
    http_tokens                 = "required"
    http_put_response_hop_limit = 1
  }
}

resource "aws_db_instance" "orders" {
  identifier              = "orders-prod"
  engine                  = "postgres"
  instance_class          = "db.t4g.medium"
  storage_encrypted       = true
  kms_key_id              = aws_kms_key.app_data.arn
  publicly_accessible     = false
  deletion_protection     = true
  backup_retention_period = 14
}

Compute, Encryption & Audit Rules Covered (TF007–TF012)

Rule Severity Terraform Gap Caught CIS AWS v5.0 / SOC 2 Mapping
TF007 HIGH aws_db_instance / aws_rds_cluster missing storage_encrypted = true CIS 2.3.1 · SOC 2 CC6.1 / CC6.7 · ISO A.8.24 · PCI 3.5
TF008 HIGH aws_s3_bucket missing SSE-KMS or AES256 encryption config CIS 2.1.1 · SOC 2 CC6.1 / CC6.7 · ISO A.8.24
TF009 HIGH aws_instance or launch template allowing IMDSv1 (http_tokens != "required") CIS 5.6 · SOC 2 CC6.1 / CC6.6 · ISO A.5.17 / A.8.9
TF010 HIGH aws_ebs_volume or EC2 root_block_device not encrypted CIS 2.2.1 · SOC 2 CC6.1 / CC6.7 · ISO A.8.24
TF011 HIGH aws_kms_key missing enable_key_rotation = true CIS 3.6 · SOC 2 CC6.1 / CC6.7 · PCI 3.6
TF012 HIGH aws_cloudtrail single-region or missing enable_log_file_validation = true CIS 3.1 / 3.2 · SOC 2 CC6.1 / CC7.2 · ISO A.8.15

Automate CIS AWS v5.0 & SOC 2 CC6.7 Checks Locally

Scan every Terraform repository locally with leastproof-cli and export SARIF 2.1.0 + SHA-256 sealed auditor dossiers without paying $3k–$18k/yr for SaaS CSPM tools.

Frequently Asked Questions

Why must EC2 instances set http_tokens = "required" in Terraform?

IMDSv1 allows unauthenticated HTTP GET requests to 169.254.169.254, turning any web app SSRF bug into instant IAM credential theft. Requiring IMDSv2 session tokens blocks SSRF metadata exfiltration.

Can I enable storage_encrypted = true on an existing RDS instance without downtime?

No—enabling encryption on an unencrypted RDS instance forces replacement. Copy a snapshot with KMS encryption enabled, restore to a new encrypted instance, and switch endpoints.

Why do CIS AWS v5.0 and SOC 2 require KMS rotation and CloudTrail validation?

Annual KMS key rotation limits cryptographic exposure, while multi-region CloudTrail with log file validation provides tamper-evident audit trails required by SOC 2 CC7.2.

Related AWS IAM & Terraform Remediation Guides

Fix 0.0.0.0/0 SSH & RDS Security Groups

Close internet-facing SSH, RDP, Postgres, and MySQL ports (TF001–TF004).

Read Security Group Guide

Fix AWS S3 Public Buckets

Verify S3 Public Access Block (TF006), SSE-KMS (TF008), and versioning (TF017).

Open S3 Terraform Checker

Fix Wildcard *:* IAM Policies

Refactor full admin wildcards (IAM001, IAM004) into ARN-scoped least privilege.

Read Wildcard IAM Guide

Oriancy Local Security Quartet

4 Zero-Upload Scanners · 1 One-Time Bundle
DevSecOps Quartet Bundle — All 4 local CLIs & auditor packs on one-time Polar licenses · oriancy.com