Skip to main content
The CDK Insights rule library

AWS CDK security rules

Every check CDK Insights runs — 137 security, cost and best-practice rules across 36 AWS services. Each one explains what it catches, why it matters, and how to fix it in your CDK code.

$ npx cdk-insights scan

ACM

1 rule

API Gateway

4 rules

AppSync

2 rules

Auto Scaling

2 rules

Backup

2 rules

CloudFront

4 rules

CloudTrail

1 rule

CloudWatch

3 rules

Cognito

3 rules

Cross-service

4 rules

DynamoDB

5 rules

EC2

11 rules

ECR

3 rules

ECS

7 rules

EFS

1 rule

EKS

4 rules

ElastiCache

3 rules

ELB

4 rules

EventBridge

3 rules

Glue

2 rules

IAM

10 rules

IAM Role Assumable By Any AWS Account

CRITICAL

Detects IAM roles whose trust policy allows a wildcard principal to assume them with no scoping condition — anyone with an AWS account can become the role.

How to fix

ECS Container Secrets Without Execution Role Access

HIGH

An ECS container definition pulls Secrets[].ValueFrom from an in-template Secrets Manager secret or SSM parameter, but the task EXECUTION role (which the ECS agent uses to resolve secrets) lacks secretsmanager:GetSecretValue / ssm:GetParameters. Containers fail to start with ResourceInitializationError.

How to fix

Event Source Mapping Missing Required IAM Permissions

HIGH

An AWS::Lambda::EventSourceMapping polls an in-template SQS queue, Kinesis stream, or DynamoDB stream but the function execution role lacks the documented required actions (e.g. sqs:ReceiveMessage / DeleteMessage / GetQueueAttributes). The mapping fails to create or the poller fails with AccessDenied.

How to fix

IAM Overly Permissive Policies

HIGH

Detects IAM policies with overly permissive actions like * wildcards.

How to fix

Lambda Trigger Missing Resource-Based Permission

HIGH

An in-template trigger (EventBridge rule, SNS lambda subscription, S3 bucket notification) targets a Lambda function but no AWS::Lambda::Permission grants the service principal invoke access. The trigger silently never invokes the function. CDK custom-resource notification patterns are excluded.

How to fix

Step Functions Integration Without Role Permissions

HIGH

A Step Functions definition declares a service integration (lambda:invoke, dynamodb:getItem, sqs:sendMessage, sns:publish, states:startExecution) targeting an in-template resource, but the state machine role lacks the required action. Task states fail at execution time. Statically unparseable definitions are skipped.

How to fix

Compute Reference Without IAM Permissions

MEDIUM

A Lambda function or ECS task definition references an in-template resource (DynamoDB table, S3 bucket, SQS queue, SNS topic, Kinesis stream, secret, event bus, state machine) through an environment variable, but its execution role grants no action in that service namespace on it — the forgotten-grant footgun. Calls fail with AccessDenied at runtime. Fires only on zero coverage; never guesses specific missing actions.

How to fix

IAM Cross-Account Trust

MEDIUM

Detects IAM roles with cross-account trust relationships.

How to fix

IAM User Direct Policies

MEDIUM

Detects IAM Users with policies attached directly (inline Policies or ManagedPolicyArns). CIS AWS Foundations 1.15 requires users to inherit permissions through groups.

How to fix

IAM Permission Boundary Missing

LOW

Detects IAM roles without permission boundaries.

How to fix

ImageBuilder

1 rule

Kinesis

2 rules

KMS

2 rules

Lambda

11 rules

Lambda Permission Permits Public Access

CRITICAL

Detects AWS::Lambda::Permission and AWS::Lambda::LayerVersionPermission resources that grant invoke / use rights with a wildcard Principal, or grant a service principal without a SourceArn / SourceAccount / PrincipalOrgID restriction (confused-deputy risk).

How to fix

Lambda Deprecated Runtime

HIGH

Detects Lambda functions using runtimes that have reached or are approaching end-of-life.

How to fix

Lambda Function URL Without Authentication

HIGH

Detects Lambda Function URLs configured with AuthType NONE, which allows unauthenticated public invocation.

How to fix

Lambda Sensitive Environment Variables

HIGH

Detects Lambda functions with sensitive data in environment variables.

How to fix

Lambda Variable Runtime

MEDIUM

Detects Lambda functions using a variable runtime (Runtime.NODEJS_LATEST or useLatestRuntimeVersion) that resolves to the newest runtime at synth time, causing silent in-place runtime upgrades on the next deploy after a CDK bump.

How to fix

Lambda VPC NAT Gateway Cost Warning

MEDIUM

Warns about potential NAT Gateway costs for VPC-attached Lambda functions.

How to fix

Lambda Dead Letter Queue Missing

LOW

Detects Lambda functions without dead letter queue configuration.

How to fix

Lambda Memory Optimization

LOW

Detects Lambda functions with suboptimal memory configuration.

How to fix

Lambda Permission Scoped Wildcard Principal

LOW

Detects Lambda permissions using a wildcard Principal scoped only by a source/org condition.

How to fix

Lambda Reserved Concurrency Missing

LOW

Detects Lambda functions without reserved concurrency.

How to fix

Lambda X-Ray Tracing Disabled

LOW

Detects Lambda functions without active X-Ray tracing, reducing observability into latency and errors.

How to fix

MSK

4 rules

OpenSearch

3 rules

RDS

9 rules

RDS Publicly Accessible

CRITICAL

Detects RDS instances that are publicly accessible.

How to fix

RDS Master Password In Plaintext

HIGH

Detects RDS instances and clusters whose MasterUserPassword is a literal string in the template rather than a Secrets Manager/SSM dynamic reference or managed credential.

How to fix

RDS Backup Retention Low

MEDIUM

Detects RDS instances with insufficient backup retention.

How to fix

RDS Deletion Protection Disabled

MEDIUM

Detects RDS instances without deletion protection.

How to fix

RDS Encryption Disabled

MEDIUM

Detects RDS instances and clusters without storage encryption at rest. Aurora member instances and read replicas (which inherit encryption) are exempt.

How to fix

RDS Enhanced Monitoring Disabled

MEDIUM

Detects RDS instances without enhanced monitoring (MonitoringInterval missing or set to 0). OS-level metrics are not published to CloudWatch Logs.

How to fix

RDS Instance Using gp2 Storage

MEDIUM

Detects Multi-AZ RDS instances on gp2 storage; gp3 offers better baseline performance at lower cost.

How to fix

RDS Logging Disabled

MEDIUM

Detects RDS DBInstance and DBCluster resources without EnableCloudwatchLogsExports configured. Engine logs (error, slow query, audit) are not exported to CloudWatch for retention or analysis.

How to fix

RDS Managed Master Secret Without Customer-Managed Key

MEDIUM

Detects RDS instances/clusters using the native Secrets Manager integration (ManageMasterUserPassword) whose managed master-user secret is encrypted with the AWS-managed aws/secretsmanager key instead of a customer-managed KMS key.

How to fix

Redshift

3 rules

Route 53

3 rules

S3

10 rules

S3 Bucket Policy Grants Public Read

CRITICAL

Detects S3 bucket policies that allow object reads to a wildcard principal with no scoping condition — the bucket contents are publicly downloadable.

How to fix

S3 BucketPolicy Self-Lockout

CRITICAL

Detects AWS::S3::BucketPolicy resources containing a Deny statement on s3:DeleteBucket, s3:*, or * with a broad Principal and no NotPrincipal or aws:PrincipalArn carveout for the account root or admin role. Such a policy locks the account out of its own bucket — recovery requires breaking glass on the account root credentials, since AWS Support typically declines to intervene where customers have a self-service path via root.

How to fix

S3 BucketPolicy Permits Non-SSL Requests

HIGH

Detects AWS::S3::BucketPolicy resources that lack a Deny statement enforcing aws:SecureTransport. Without this, the bucket accepts plain HTTP requests in addition to HTTPS.

How to fix

S3 Bucket Access Logging Disabled

MEDIUM

Detects S3 buckets without server access logging configured. Required by CIS AWS Foundations 2.1.2 and useful for incident forensics.

How to fix

S3 Bucket Encryption Not Customer-Configured

MEDIUM

Detects S3 buckets without an explicit BucketEncryption configuration (SSE-S3 default applies, not customer-controlled).

How to fix

S3 Bucket Public Access Not Explicitly Blocked

MEDIUM

Detects S3 buckets that do not explicitly enable all four Block Public Access settings. New buckets are protected by service defaults since April 2023; explicit configuration makes the protection visible and portable.

How to fix

S3 Bucket Versioning Disabled

MEDIUM

Detects S3 buckets without versioning enabled, leaving overwritten or deleted objects unrecoverable.

How to fix

S3 Lifecycle Policy Missing

MEDIUM

Detects S3 buckets without lifecycle policies.

How to fix

S3 Intelligent Tiering

LOW

Recommends S3 Intelligent Tiering for cost optimization.

How to fix

S3 Replication Missing

LOW

Detects critical S3 buckets without cross-region replication.

How to fix

Secrets Manager

2 rules

SNS

2 rules

SQS

3 rules

Step Functions

1 rule

WAF

2 rules

Scan your CDK app against all 137 rules

One command, no signup. The full rule pack is free forever via npm.