Fix 0.0.0.0/0 SSH & RDS Security Groups
Close internet-facing SSH, RDP, Postgres, and MySQL ports (TF001–TF004).
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.
0 bytes uploaded · 0 AWS keys · One-time local CLI, SARIF 2.1.0 & SOC 2 CC6.1/CC6.7 dossier via Polar.sh.
.tf Files
.tf files — scanned strictly in browser memory.
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.
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
}
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
}
| 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 |
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.
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.
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.
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.
0.0.0.0/0 SSH & RDS Security GroupsClose internet-facing SSH, RDP, Postgres, and MySQL ports (TF001–TF004).
Verify S3 Public Access Block (TF006), SSE-KMS (TF008), and versioning (TF017).
*:* IAM PoliciesRefactor full admin wildcards (IAM001, IAM004) into ARN-scoped least privilege.