Skip to content

feat(queries): add 20 new Terraform AWS queries with auto-remediation support#7991

Open
cx-antero-silva wants to merge 3 commits intoCheckmarx:masterfrom
cx-antero-silva:iac-scanner-gap-queries
Open

feat(queries): add 20 new Terraform AWS queries with auto-remediation support#7991
cx-antero-silva wants to merge 3 commits intoCheckmarx:masterfrom
cx-antero-silva:iac-scanner-gap-queries

Conversation

@cx-antero-silva
Copy link
Contributor

@cx-antero-silva cx-antero-silva commented Mar 9, 2026

Summary

20 new Terraform AWS security queries (Beta)

New queries covering security misconfigurations across IAM, networking, encryption, logging, and access control.

Auto-remediation support added to 5 queries

The following queries include remediation and remediationType fields, enabling the kics remediate command to automatically fix detected issues:

Query Issue type Remediation
amazon_dms_replication_instance_is_publicly_accessible IncorrectValue publicly_accessible true → false
cloudformation_stack_termination_protection_disabled MissingAttribute add termination_protection = true
cloudformation_stack_termination_protection_disabled IncorrectValue termination_protection false → true
ecs_services_assigned_with_public_ip_address IncorrectValue assign_public_ip true → false (resource + module)
mq_broker_logging_disabled IncorrectValue log flag false → true
mq_broker_logging_disabled MissingAttribute add missing general/audit key
mq_broker_logging_disabled MissingAttribute add missing logs { general = true / audit = true } block
rds_cluster_with_backup_disabled MissingAttribute add backup_retention_period = 7

Remediation patterns used

  • replacementjson.marshal({"before": "<current>", "after": "<desired>"}) for IncorrectValue
  • addition → plain string "key = value" or multiline block for MissingAttribute

Test plan

  • Verify all 20 new queries produce findings on their positive test fixtures
  • Verify no findings on negative test fixtures
  • For the 5 auto-remediation queries: run kics scan and confirm remediation and remediation_type appear in JSON output
  • Run kics remediate and verify Terraform files are patched correctly

…ysis

Gap analysis comparing KICS against Trivy/tfsec, Terrascan, Snyk IaC and
Prowler identified security checks present in multiple tools but absent from
KICS. All queries marked experimental: true.

AWS Terraform (10 queries):
- Beta - EMR Cluster Local Disk Encryption Disabled (HIGH, CWE-311)
- Beta - CloudFormation Stack Termination Protection Disabled (MEDIUM, CWE-693)
- Beta - API Gateway V2 CORS Wildcard Origin Allowed (HIGH, CWE-942)
- Beta - Step Functions State Machine Logging Disabled (MEDIUM, CWE-778)
- Beta - WAFv2 Web ACL Logging Disabled (MEDIUM, CWE-778)
- Beta - Cognito User Pool Advanced Security Disabled (MEDIUM, CWE-307)
- Beta - Route53 Zone Query Logging Disabled (LOW, CWE-778)
- Beta - EventBridge Bus Allows Cross-Account Access (HIGH, CWE-284)
- Beta - ECS Task Definition Without Read-Only Root Filesystem (HIGH, CWE-732)
- Beta - Kinesis Firehose Delivery Stream SSE Disabled (HIGH, CWE-311)

GCP Terraform (5 queries):
- Beta - Cloud SQL PostgreSQL log_checkpoints Not Enabled (MEDIUM, CWE-778)
- Beta - Cloud SQL PostgreSQL log_lock_waits Not Enabled (MEDIUM, CWE-778)
- Beta - GKE Node Pool Auto-Repair Disabled (MEDIUM, CWE-693)
- Beta - GKE Node Pool Auto-Upgrade Disabled (MEDIUM, CWE-1188)
- Beta - GKE Cluster Stackdriver Logging Disabled (MEDIUM, CWE-778)

Azure Terraform (5 queries):
- Beta - Key Vault Key Expiry Not Set (MEDIUM, CWE-324)
- Beta - Key Vault Secret Expiry Not Set (MEDIUM, CWE-324)
- Beta - Storage Account Queue Logging Disabled (MEDIUM, CWE-778)
- Beta - Container Registry Admin Account Enabled (HIGH, CWE-269)
- Beta - Redis Cache Publicly Accessible (HIGH, CWE-668)

Each query includes query.rego, metadata.json, and positive/negative test fixtures.
Gap analysis sources: Trivy/tfsec, Terrascan, Snyk IaC, Prowler.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cx-antero-silva cx-antero-silva requested a review from a team as a code owner March 9, 2026 22:35
@github-actions github-actions bot added community Community contribution feature request Community: new feature request query New query feature cloudformation CloudFormation query terraform Terraform query gcp PR related with GCP Cloud azure PR related with Azure Cloud aws PR related with AWS Cloud labels Mar 9, 2026
Add remediation and remediationType fields to the following queries
that previously lacked auto-remediation capability:
- amazon_dms_replication_instance_is_publicly_accessible: replace true→false
- cloudformation_stack_termination_protection_disabled: add true / replace false→true
- ecs_services_assigned_with_public_ip_address: replace true→false (resource + module)
- mq_broker_logging_disabled: replace false→true, add missing keys, add missing logs block
- rds_cluster_with_backup_disabled: add backup_retention_period = 7

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cx-antero-silva cx-antero-silva changed the title feat(queries): add 20 Beta security queries from IaC scanner gap feat(queries): add 20 new Terraform AWS queries with auto-remediation support Mar 11, 2026
@github-actions github-actions bot removed gcp PR related with GCP Cloud azure PR related with Azure Cloud labels Mar 11, 2026
@kicsbot
Copy link
Contributor

kicsbot commented Mar 19, 2026

Your pull request can't be merged due to missing the Apache license statement.

Please add the following statement at the end of the pr description:

I submit this contribution under the Apache-2.0 license.

In case the statement has already been added, make sure it is the last sentence in the description and the only one in its line.

Thank you!
KICS Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws PR related with AWS Cloud cloudformation CloudFormation query community Community contribution feature request Community: new feature request query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants