| ##################################### |
| # Rule Identifier: |
| # IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS |
| # |
| # Description: |
| # Checks the IAM policies that you create for Allow statements that grant permissions to all actions on all resources. |
| # |
| # Reports on: |
| # AWS::IAM::Policy |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no IAM Policies present |
| # b) PASS: when all IAM Policies do not grant permissions to all actions on all resources |
| # c) FAIL: when any IAM Policies grant permissions to all actions on all resources |
| # d) SKIP: when metada has rule suppression for IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS |
|
|
| # |
| # Select all IAM Policy resources from incoming template (payload) |
| # |
| let aws_iam_policies_no_statements_with_admin_access = Resources.*[ Type == 'AWS::IAM::Policy' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS" |
| ] |
|
|
| rule IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS when %aws_iam_policies_no_statements_with_admin_access !empty { |
| let violations = Resources.*[ |
| Type == 'AWS::IAM::Policy' |
| some Properties.PolicyDocument.Statement[*] { |
| some Action[*] == "*" |
| Effect == "Allow" |
| Resource == "*" |
| } |
| ] |
| %violations empty |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.4,CIS.16 |
| Violation: One or more IAM policies contain allow statements that grant permissions to all actions on all resources |
| Fix: Remove policy statements that match {"Effect": "Allow", "Action": "*", "Resource": "*"} |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # REDSHIFT_CLUSTER_CONFIGURATION_CHECK |
| # |
| # Description: |
| # Checks whether Amazon Redshift clusters have the specified settings (Encrypted Only) |
| # |
| # Reports on: |
| # AWS::Redshift::Cluster |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no Redshift Cluster resource present |
| # b) PASS: when Redshift Cluster resources have the Encrypted property set to true |
| # c) FAIL: when any Redshift Cluster resources do not have Encrypted property set (default false) |
| # d) FAIL: when any Redshift Cluster resources have Encrypted property set to false |
| # e) SKIP: when metadata includes the suppression for rule REDSHIFT_CLUSTER_CONFIGURATION_CHECK |
|
|
| # |
| # Select all Redshift Cluster resources from incoming template (payload) |
| # |
| let redhshift_clusters_configuration_check = Resources.*[ Type == 'AWS::Redshift::Cluster' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "REDSHIFT_CLUSTER_CONFIGURATION_CHECK" |
| ] |
|
|
| rule REDSHIFT_CLUSTER_CONFIGURATION_CHECK when %redhshift_clusters_configuration_check !empty { |
| %redhshift_clusters_configuration_check.Properties.Encrypted == true |
|
|
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.5,CIS.6,CIS.13 |
| Violation: Amazon Redshift configuration should have encryption enabled |
| Fix: Set the Encrypted property to true |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK |
| # |
| # Description: |
| # Checks whether Amazon Redshift clusters have the specified maintenance settings (AllowVersionUpgrade, PreferredMaintenanceWindow, AutomatedSnapshotRetentionPeriod) |
| # |
| # Reports on: |
| # AWS::Redshift::Cluster |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no Redshift Cluster resource present |
| # b) PASS: when Redshift Cluster resources have properties PreferredMaintenanceWindow set, AllowVersionUpgrade either not set (default true) or set to true, and AutomatedSnapshotRetentionPeriod either not set (default 1 day) or set to greated than 0. |
| # c) FAIL: when any Redshift Cluster resources do not have PreferredMaintenanceWindow property set |
| # d) FAIL: when any Redshift Cluster resources have AllowVersionUpgrade property set to false |
| # e) FAIL: when any Redshift Cluster resources have AutomatedSnapshotRetentionPeriod property set to 0 |
| # f) SKIP: when metadata includes the suppression for rule REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK |
|
|
| # |
| # Select all Redshift Cluster resources from incoming template (payload) |
| # |
| let redhshift_clusters_maintenancesettings_check = Resources.*[ Type == 'AWS::Redshift::Cluster' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK" |
| ] |
|
|
| rule REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK when %redhshift_clusters_maintenancesettings_check !empty { |
| %redhshift_clusters_maintenancesettings_check.Properties.PreferredMaintenanceWindow exists |
| |
| %redhshift_clusters_maintenancesettings_check.Properties.AllowVersionUpgrade not exists or |
| %redhshift_clusters_maintenancesettings_check.Properties.AllowVersionUpgrade == true |
|
|
|
|
| %redhshift_clusters_maintenancesettings_check.Properties.AutomatedSnapshotRetentionPeriod not exists or |
| %redhshift_clusters_maintenancesettings_check.Properties.AutomatedSnapshotRetentionPeriod > 0 |
|
|
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.5 |
| Violation: Amazon Redshift maintenance settings must be configured |
| Fix: set the PreferredMaintenanceWindow property, remove the AllowVersionUpgrade property (default true) or set it to true, and remove the AutomatedSnapshotRetentionPeriod property (default 1 day) or set it to greated than 0. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # API_GW_EXECUTION_LOGGING_ENABLED |
| # |
| # Description: |
| # Checks that all methods in Amazon API Gateway stage has logging enabled. The rule is NON_COMPLIANT if logging is not enabled. |
| # |
| # Reports on: |
| # AWS::ApiGateway::Stage |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no API GW Stage present |
| # b) PASS: when all API GW Stage Methods have logginglevel set to "ERROR" OR "INFO" |
| # c) FAIL: when API GW Domain Names doesn't have logginglevel set to "ERROR" OR "INFO" |
| # d) SKIP: when metadata includes the suppression for rule API_GW_EXECUTION_LOGGING_ENABLED |
| |
| let api_gw_execution_logging_enabled = Resources.*[ Type == 'AWS::ApiGateway::Stage' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "API_GW_EXECUTION_LOGGING_ENABLED" |
| ] |
| |
| rule API_GW_EXECUTION_LOGGING_ENABLED when %api_gw_execution_logging_enabled !empty { |
| when %api_gw_execution_logging_enabled.Properties.MethodSettings !empty { |
| %api_gw_execution_logging_enabled.Properties.MethodSettings.*.LoggingLevel == "ERROR" OR |
| %api_gw_execution_logging_enabled.Properties.MethodSettings.*.LoggingLevel == "INFO" |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.6 |
| Violation: Logging Level for API GW Method Setting not set |
| Fix: API GW Stage Method Setting logging level must be set to "ERROR" or "INFO" |
| >> |
| } |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED |
| # |
| # Description: |
| # Checks whether AWS CloudTrail trails are configured to send logs to Amazon CloudWatch logs. |
| # The trail is non-compliant if the CloudWatchLogsLogGroupArn property of the trail is empty. |
| # |
| # Reports on: |
| # AWS::CloudTrail::Trail |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no CloudTrail Trails present |
| # b) PASS: when all CloudTrail Trails have CloudWatchLogsLogGroupArn parameter set |
| # c) FAIL: when there are CloudTrail Trails with CloudWatchLogsLogGroupArn property not present |
| # d) SKIP: when metada has rule suppression for CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED |
| |
| # |
| # Select all CloudTrail Trail resources from incoming template (payload) |
| # |
| let cloudtrail_trails_cw_logs_enabled = Resources.*[ Type == 'AWS::CloudTrail::Trail' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED" |
| ] |
| |
| rule CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED when %cloudtrail_trails_cw_logs_enabled !empty { |
| %cloudtrail_trails_cw_logs_enabled.Properties.CloudWatchLogsLogGroupArn exists |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.6 |
| Violation: CloudTrail Trail should have logs exported to cloudwatch logs. |
| Fix: Set the CloudWatchLogsLogGroupArn parameter to enable exporting to CloudWatch Logs. |
| >> |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED |
| # |
| # Description: |
| # Checks whether AWS CloudTrail creates a signed digest file with logs. |
| # |
| # Reports on: |
| # AWS::CloudTrail::Trail |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no CloudTrail Trails present |
| # b) PASS: when all CloudTrail Trails have EnableLogFileValidation parameter set true |
| # c) FAIL: when there are CloudTrail Trails with the EnableLogFileValidation parameter is set to false |
| # d) FAIL: when there are CloudTrail Trails with EnableLogFileValidation property not present |
| # e) SKIP: when metada has rule suppression for CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED |
| |
| |
| # |
| # Select all CloudTrail Trail resources from incoming template (payload) |
| # |
| let cloudtrail_trails_log_validation = Resources.*[ Type == 'AWS::CloudTrail::Trail' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED" |
| ] |
| |
| rule CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED when %cloudtrail_trails_log_validation !empty { |
| %cloudtrail_trails_log_validation.Properties.EnableLogFileValidation EXISTS |
| %cloudtrail_trails_log_validation.Properties.EnableLogFileValidation == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.6 |
| Violation: CloudTrail Trail should have Log File Validation enabled. |
| Fix: Set the EnableLogFileValidation parameter to true. |
| >> |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # CLOUDTRAIL_S3_DATAEVENTS_ENABLED |
| # |
| # Description: |
| # Checks whether at least one AWS CloudTrail trail is logging Amazon S3 data events for all S3 buckets. |
| # |
| # Reports on: |
| # AWS::CloudTrail::Trail |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no CloudTrail Trails present |
| # b) PASS: when all CloudTrail Trails have EventSelectors parameter set |
| # c) FAIL: when there are CloudTrail Trails with EventSelectors property not present |
| # d) SKIP: when metada has rule suppression for CLOUDTRAIL_S3_DATAEVENTS_ENABLED |
| |
| # |
| # Select all CloudTrail Trail resources from incoming template (payload) |
| # |
| let cloudtrail_trails_dataevents = Resources.*[ Type == 'AWS::CloudTrail::Trail' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "CLOUDTRAIL_S3_DATAEVENTS_ENABLED" |
| ] |
| |
| rule CLOUDTRAIL_S3_DATAEVENTS_ENABLED when %cloudtrail_trails_dataevents !empty { |
| %cloudtrail_trails_dataevents.Properties.EventSelectors EXISTS |
| some %cloudtrail_trails_dataevents.Properties.EventSelectors.* == {DataResources:[{Type:'AWS::S3::Object',Values:['arn:aws:s3:::']}],IncludeManagementEvents:true,ReadWriteType:'All'} |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.6 |
| Violation: CloudTrail Trail should have data events being logged. |
| Fix: Set the EventSelectors parameter to enable encryption. The value can be an alias name prefixed by "alias/", a fully specified ARN to an alias, a fully specified ARN to a key, or a globally unique identifier. |
| >> |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # CLOUDWATCH_ALARM_ACTION_CHECK |
| # |
| # Description: |
| # Checks whether CloudWatch alarms have at least one alarm action, |
| # one Insufficient Data Actions action, or one OK action enabled. |
| # |
| # Reports on: |
| # AWS::Logs::LogGroup |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no cloudwatch alarm resources present |
| # b) PASS: when resource Metadata is set with rule suppressed |
| # c) PASS: when all cloudwatch alarm resources property Alarm Actions, Insufficient Data Actions, or OK Action set |
| # d) FAIL: when all cloudwatch alarms resources property Alarm Actions, Insufficient Data Actions, or OK Action are not set with valid value |
| # e) SKIP: when metada has rule suppression for CLOUDWATCH_ALARM_ACTION_CHECK |
| |
| # |
| # Select all cloudwatch logs log group resources from incoming template (payload) |
| # |
| let cloudwatch_alarm_action_check = Resources.*[ Type == 'AWS::CloudWatch::Alarm' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "CLOUDWATCH_ALARM_ACTION_CHECK" |
| ] |
| |
| rule CLOUDWATCH_ALARM_ACTION_CHECK when %cloudwatch_alarm_action_check !empty { |
| %cloudwatch_alarm_action_check.Properties.AlarmActions exists or |
| %cloudwatch_alarm_action_check.Properties.OKActions exists or |
| %cloudwatch_alarm_action_check.Properties.InsufficientDataActions exists |
| |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.6,CIS.16 |
| Violation: CloudWatch Alarms should have at least one Alarm Action, one Insufficient Data Actions action, or one OK Action enabled. |
| Fix: Set one Alarm Action, one Insufficient Data Actions action, or one OK Action on the CloudWatch Alarm resource. |
| >> |
| } |
| |
| |
| ## Config Rule Name : elb-logging-enabled |
| ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-logging-enabled.html" |
| |
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_LOGGING_ENABLED |
| # |
| # Description: |
| # Checks whether logging is enabled for your S3 buckets. |
| # |
| # Reports on: |
| # AWS::S3::Bucket |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 resource present |
| # b) PASS: when all S3 resources Logging Configuration exists |
| # c) FAIL: when all S3 resources have Logging Configuration is not set |
| # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_LOGGING_ENABLED |
| |
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
| |
| let s3_buckets_bucket_logging_enabled = Resources.*[ Type == 'AWS::S3::Bucket' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_LOGGING_ENABLED" |
| ] |
| |
| rule S3_BUCKET_LOGGING_ENABLED when %s3_buckets_bucket_logging_enabled !empty { |
| %s3_buckets_bucket_logging_enabled.Properties.LoggingConfiguration exists |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.6 |
| Violation: S3 Bucket Logging needs to be configured to enable logging. |
| Fix: Set the S3 Bucket property LoggingConfiguration to start logging into S3 bucket. |
| >> |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # DMS_REPLICATION_NOT_PUBLIC |
| # |
| # Description: |
| # Checks whether AWS Database Migration Service replication instances are not set to allow public. |
| # |
| # Reports on: |
| # AWS::DMS::ReplicationInstance |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there is no DMS Replication Instance present |
| # b) FAIL: When DMS Replication Instance is present and PubliclyAccessible property is set to true |
| # c) PASS: When DMS Replication Instance is present and PubliclyAccessible property is set to false |
| # c) PASS: When DMS Replication Instance is present and PubliclyAccessible property is not set |
| # d) SKIP: when metada has rule suppression for DMS_REPLICATION_NOT_PUBLIC |
| |
| # |
| # Select all Redshift cluster resources from incoming template |
| # |
| |
| let dms_replication_instances = Resources.*[ Type == 'AWS::DMS::ReplicationInstance' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "DMS_REPLICATION_NOT_PUBLIC" |
| ] |
| |
| rule DMS_REPLICATION_NOT_PUBLIC when %dms_replication_instances !empty { |
| %dms_replication_instances.Properties.PubliclyAccessible exists |
| %dms_replication_instances.Properties.PubliclyAccessible == false |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12,CIS.14 |
| Violation: AWS Database Migration Service replication instances should not be public. |
| Fix: Set the DMS Replication Instance property PubliclyAccessible parameter to true. |
| >> |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # EC2_INSTANCE_NO_PUBLIC_IP |
| # |
| # Description: |
| # Checks whether Amazon Elastic Compute Cloud (Amazon EC2) instances have a public IP association. |
| # |
| # Reports on: |
| # AWS::EC2::Instance |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when no EC2 Instance resources are present |
| # b) SKIP: when no EC2 Instances have network interfaces defined |
| # c) PASS: when no EC2 Instances with network interfaces have associated public IP addresses |
| # d) FAIL: when any EC2 Instances with network interfaces have associated public IP addresses |
| # e) SKIP: hen metadata includes the suppression for rule EC2_INSTANCE_NO_PUBLIC_IP |
| |
| # |
| # Select all EC2 Instance resources from incoming template (payload) |
| # |
| let ec2_instances_no_public_ip = Resources.*[Type == 'AWS::EC2::Instance' |
| Properties.NetworkInterfaces[*] !empty |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "EC2_INSTANCE_NO_PUBLIC_IP" |
| ] |
| |
| rule EC2_INSTANCE_NO_PUBLIC_IP when %ec2_instances_no_public_ip !empty { |
| %ec2_instances_no_public_ip.Properties.NetworkInterfaces[*] { |
| AssociatePublicIpAddress !exists OR |
| AssociatePublicIpAddress == false |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12,CIS.14 |
| Violation: EC2 Instances cannot have public IP addresses associated with their network interfaces |
| Fix: remove the AssociatePublicIpAddress property from NetworkInterfaces list or set it to false |
| >> |
| } |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # ELASTICSEARCH_IN_VPC_ONLY |
| # |
| # Description: |
| # Elasticsearch domains must be in a VPC |
| # |
| # Reports on: |
| # AWS::Elasticsearch::Domain |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there is no elasticsearch domain present |
| # b) FAIL: when elasticsearch domain does not have VPCOptions or Endpoint properties |
| # c) PASS: when elasticsearch domain has VPCOptions or Endpoint properties |
| # d) SKIP: when metada has rule suppression for ELASTICSEARCH_IN_VPC_ONLY |
| |
| # |
| # Select all elasticsearch domains from incoming template |
| # |
| let elasticsearch_domains_vpc_required = Resources.*[ Type == 'AWS::Elasticsearch::Domain' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "ELASTICSEARCH_IN_VPC_ONLY" |
| ] |
| |
| rule ELASTICSEARCH_IN_VPC_ONLY when %elasticsearch_domains_vpc_required !empty { |
| %elasticsearch_domains_vpc_required.Properties.VPCOptions EXISTS |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12 |
| Violation: Elasticsearch domains must be in a VPC. |
| Fix: Provide VPCOptions object to enable opensearch to function in a VPC. |
| >> |
| } |
| ## Config Rule Name : emr-master-no-public-ip |
| ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/emr-master-no-public-ip.html" |
| |
| ##################################### |
| # Rule Identifier: |
| # INCOMING_SSH_DISABLED |
| # |
| # Description: |
| # Checks if the incoming SSH traffic for the security groups is accessible. |
| # |
| # Reports on: |
| # AWS::EC2::SecurityGroup |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when no Security Group resources are present |
| # b) SKIP: when no SSH ingress is defined (port 22) |
| # c) PASS: when all Security Groups resources restrict the IP address of the incoming SSH traffic |
| # d) FAIL: when a Security Group allows SSH traffic from any IP address (0.0.0.0/0). |
| # e) SKIP: hen metadata includes the suppression for rule INCOMING_SSH_DISABLED |
| |
| # |
| # Select all Security Group resources from incoming template (payload) |
| # |
| let aws_security_groups_restricted_ssh = Resources.*[ |
| Type == 'AWS::EC2::SecurityGroup' |
| some Properties.SecurityGroupIngress[*] { |
| ToPort == 22 |
| FromPort == 22 |
| IpProtocol == "tcp" |
| } |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "INCOMING_SSH_DISABLED" |
| ] |
| |
| rule INCOMING_SSH_DISABLED when %aws_security_groups_restricted_ssh !empty { |
| %aws_security_groups_restricted_ssh.Properties.SecurityGroupIngress[*] != {CidrIp:"0.0.0.0/0", ToPort:22, FromPort:22, IpProtocol:"tcp"} |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.11,CIS.12 |
| Violation: IP addresses of the incoming SSH traffic in the security groups are restricted (CIDR other than 0.0.0.0/0) |
| Fix: set SecurityGroupIngress.CidrIp property to a more restrictive CIDR than 0.0.0.0/0 |
| >> |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # EC2_INSTANCES_IN_VPC |
| # |
| # Description: |
| # Checks if your EC2 instances belong to a virtual private cloud (VPC). |
| # |
| # Reports on: |
| # AWS::EC2::Instance |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no EC2 resource present |
| # b) PASS: when all EC2 resources have the SubnetId property set |
| # c) FAIL: when any EC2 resources do not have the SubnetId property set |
| # d) SKIP: when metadata includes the suppression for rule EC2_INSTANCES_IN_VPC |
| |
| # |
| # Select all ECS Instance resources from incoming template (payload) |
| # |
| let ec2_instances_in_vpc = Resources.*[ Type == 'AWS::EC2::Instance' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "EC2_INSTANCES_IN_VPC" |
| ] |
| |
| rule EC2_INSTANCES_IN_VPC when %ec2_instances_in_vpc !empty { |
| %ec2_instances_in_vpc.Properties.SubnetId !empty |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12 |
| Violation: EC2 Instances must belong to a VPC |
| Fix: set the SubnetId property to a subnet ID |
| >> |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED |
| # |
| # Description: |
| # Checks if the AWS Lambda function policy attached to the Lambda resource prohibits public access. |
| # |
| # Reports on: |
| # AWS::Lambda::Permission |
| # AWS::Lambda::LayerVersionPermission |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when no AWS Lambda permission policies are present |
| # b) PASS: when all AWS Lambda permission policies prohibit public access |
| # c) FAIL: when any AWS Lambda permission policies allow public access |
| # d) SKIP: hen metadata includes the suppression for rule LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED |
| |
| # |
| # Select all AWS Lambda Permission resources from incoming template (payload) |
| # |
| let aws_lambda_permissions_public_access_prohibited = Resources.*[ |
| Type in [ /AWS::Lambda::Permission/, |
| /AWS::Lambda::LayerVersionPermission/ ] |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED" |
| ] |
| |
| rule LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED when %aws_lambda_permissions_public_access_prohibited !empty { |
| |
| # Lambda permission policy where principal is an account id |
| %aws_lambda_permissions_public_access_prohibited { |
| Type == 'AWS::Lambda::Permission' |
| Properties { |
| Principal in [ /^\d{12}$/, "AWS::AccountId" ] |
| OR Principal > 0 |
| } |
| } |
| |
| # Lambda permission policy where principal is a service (not s3) |
| OR %aws_lambda_permissions_public_access_prohibited { |
| Type == 'AWS::Lambda::Permission' |
| Properties { |
| Principal != 's3.amazonaws.com' |
| PrincipalOrgID !empty |
| OR SourceAccount exists |
| OR SourceArn !empty |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12 |
| Violation: All Lambda permission policies attached to Lambda resources must prohibit public access. |
| Fix: Limit permission policies by setting the Principal property to an account ID, |
| or limiting a service principal by setting the SourceArn, SourceAccount, or PrincipalOrgID properties. |
| >> |
| } |
| } |
| |
| # Lambda permission policy where principal is s3 service |
| OR %aws_lambda_permissions_public_access_prohibited { |
| Type == 'AWS::Lambda::Permission' |
| Properties { |
| Principal == 's3.amazonaws.com' |
| PrincipalOrgID !empty |
| OR SourceAccount exists |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12 |
| Violation: All Lambda permission policies attached to Lambda resources must prohibit public access. |
| Fix: Limit permission policies by setting the Principal property to an account ID, |
| or for S3 as the principal specify either a SourceAccount or PrincipalOrgID. |
| Note: It is possible for an S3 bucket to be deleted by its owner and recreated by another account. |
| >> |
| } |
| } |
| |
| # Lambda layer version permission policies |
| OR %aws_lambda_permissions_public_access_prohibited { |
| Type == 'AWS::Lambda::LayerVersionPermission' |
| Properties { |
| OrganizationId !empty |
| OR Principal in [ /^\d{12}$/, "AWS::AccountId" ] |
| OR Principal > 0 |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12 |
| Violation: All Lambda permission policies attached to Lambda resources must prohibit public access. |
| Fix: For Lambda layer version permission policies, either limit permissions by the OrganizationId property |
| or set the Principal property to an account ID rather than using a wildcard (*). |
| >> |
| } |
| } |
| } |
| |
| ##################################### |
| # Rule Identifier: |
| # LAMBDA_INSIDE_VPC |
| # |
| # Description: |
| # Checks whether an AWS Lambda function is allowed access to an Amazon Virtual Private Cloud. |
| # |
| # Reports on: |
| # AWS::Lambda::Function |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when no AWS Lambda functions are present |
| # b) PASS: when all AWS Lambda functions are VPC enabled |
| # c) FAIL: when any AWS Lambda functions are not VPC enabled |
| # d) SKIP: hen metadata includes the suppression for rule LAMBDA_INSIDE_VPC |
| |
| # |
| # Select all AWS Lambda Function resources from incoming template (payload) |
| # |
| let aws_lambda_functions_inside_vpc = Resources.*[ Type == 'AWS::Lambda::Function' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "LAMBDA_INSIDE_VPC" |
| ] |
| |
| rule LAMBDA_INSIDE_VPC when %aws_lambda_functions_inside_vpc !empty { |
| %aws_lambda_functions_inside_vpc.Properties.VpcConfig.SecurityGroupIds !empty |
| %aws_lambda_functions_inside_vpc.Properties.VpcConfig.SubnetIds !empty |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12 |
| Violation: All AWS Lambda Functions must be configured with access to a VPC |
| Fix: set the VpcConfig.SecurityGroupIds and VpcConfig.SubnetIds parameters with a list of security groups and subnets. |
| Lambda creates an elastic network interface for each combination of security group and subnet in the function's VPC configuration. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # RDS_INSTANCE_PUBLIC_ACCESS_CHECK |
| # |
| # Description: |
| # Checks if an RDS instances has Publicly Accessible not set. |
| # |
| # Reports on: |
| # AWS::RDS::DBInstance |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no RDS instances present |
| # b) PASS: when all RDS instances have PubliclyAccessible set to true |
| # c) FAIL: when all RDS instances have PubliclyAccessible set to false |
| # d) FAIL: when there are RDS instances with PubliclyAccessible property is not present |
| # e) SKIP: when metadata includes the suppression for rule RDS_INSTANCE_PUBLIC_ACCESS_CHECK |
|
|
| # |
| # Select all RDS instance resources from incoming template (payload) |
| # |
| let aws_rds_instances_not_public = Resources.*[ Type == 'AWS::RDS::DBInstance' |
| Properties.SourceDBInstanceIdentifier !exists |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "RDS_INSTANCE_PUBLIC_ACCESS_CHECK" |
| ] |
|
|
| rule RDS_INSTANCE_PUBLIC_ACCESS_CHECK when %aws_rds_instances_not_public !empty { |
| # ALL RDS instances must have PubliclyAccessible set to false |
| %aws_rds_instances_not_public.Properties.PubliclyAccessible == false |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12,CIS.14 |
| Violation: All RDS instances must not be publicly accessible. |
| Fix: Set the PubliclyAccessible to false. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK |
| # |
| # Description: |
| # Redshift cluster should not be publicly accessible on the internet. |
| # |
| # Reports on: |
| # AWS::EKS::Cluster |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there is no Redshift cluster present |
| # b) PASS: when Redshift Cluster resources do not have the publiclyAccessible property set (default false) |
| # c) PASS: when Redshift Cluster resources have the PubliclyAccessible property set to false |
| # d) FAIL: when any Redshift Cluster resources have the PubliclyAccessible property set to true |
| # e) SKIP: when metada includes the suppression for rule REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK |
|
|
| # |
| # Select all Redshift cluster resources from incoming template |
| # |
|
|
| let aws_redshift_clusters_resources_public_access_check = Resources.*[ Type == 'AWS::Redshift::Cluster' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK" |
| ] |
|
|
|
|
| rule REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK when %aws_redshift_clusters_resources_public_access_check !empty { |
| %aws_redshift_clusters_resources_public_access_check.Properties.PubliclyAccessible not exists or |
| %aws_redshift_clusters_resources_public_access_check.Properties.PubliclyAccessible == false |
|
|
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12,CIS.14 |
| Violation: Redshift cluster should not be available to public. |
| Fix: Set the Redshift property PubliclyAccessible parameter to false. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # RESTRICTED_INCOMING_TRAFFIC |
| # |
| # Description: |
| # Checks if the security groups in use do not allow unrestricted incoming TCP traffic to the specified ports. |
| # |
| # Reports on: |
| # AWS::EC2::SecurityGroup |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no Security Groups resource present |
| # b) SKIP when there are no TCP or UDP ingress rules |
| # c) PASS: when all Security Groups do no allow any of the restricted common ports |
| # d) FAIL: when a Security Group allows any of the restricted common ports |
| # e) SKIP: when metadata includes the suppression for rule RESTRICTED_INCOMING_TRAFFIC |
|
|
| # |
| # Select all Security Group resources from incoming template (payload) |
| # |
| let aws_security_groups_restricted_incoming_traffic = Resources.*[ Type == 'AWS::EC2::SecurityGroup' |
| some Properties.SecurityGroupIngress[*] { |
| IpProtocol in ['tcp', 'udp'] |
| } |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "RESTRICTED_INCOMING_TRAFFIC" |
| ] |
|
|
| rule RESTRICTED_INCOMING_TRAFFIC when %aws_security_groups_restricted_incoming_traffic !empty { |
| let violations = Resources.*[ |
| Type == 'AWS::EC2::SecurityGroup' |
| some Properties.SecurityGroupIngress[*] { |
| FromPort in [ 20, 21, 3389, 3306, 4333 ] |
| ToPort in [ 20, 21, 3389, 3306, 4333 ] |
| } |
| ] |
| %violations empty |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.11,CIS.12 |
| Violation: Security groups must not allow unrestricted incoming TCP/UDP traffic to the specified ports [20, 21, 3389, 3306, 4333]. |
| Fix: change the FromPort and ToPort properties in the SecurityGroupIngress list |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_PUBLIC_READ_PROHIBITED |
| # |
| # Description: |
| # Checks if your Amazon S3 buckets do not allow public read access. The rule checks the Block Public |
| # Access settings, the bucket policy, and the bucket access control list (ACL). |
| # |
| # Reports on: |
| # AWS::S3::Bucket |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 resource present |
| # b) PASS: when all S3 resources Public Access Block Configuration element is present and properties are set to true |
| # c) FAIL: when all S3 resources do not have the Public Access Block Configuration element present or all properties set to true |
| # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_PUBLIC_READ_PROHIBITED |
|
|
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
| let s3_bucket_public_read_prohibited = Resources.*[ Type == 'AWS::S3::Bucket' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_PUBLIC_READ_PROHIBITED" |
| ] |
|
|
| rule S3_BUCKET_PUBLIC_READ_PROHIBITED when %s3_bucket_public_read_prohibited !empty { |
| %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration exists |
| %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicAcls == true |
| %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicPolicy == true |
| %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.IgnorePublicAcls == true |
| %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.RestrictPublicBuckets == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12,CIS.14 |
| Violation: S3 Bucket Public Write Access controls need to be restricted. |
| Fix: Set S3 Bucket PublicAccessBlockConfiguration properties for BlockPublicAcls, BlockPublicPolicy, IgnorePublicAcls, RestrictPublicBuckets parameters to true. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_PUBLIC_WRITE_PROHIBITED |
| # |
| # Description: |
| # Checks if your Amazon S3 buckets do not allow public write access. The rule checks the Block Public |
| # Access settings, the bucket policy, and the bucket access control list (ACL). |
| # |
| # Reports on: |
| # AWS::S3::Bucket |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 resource present |
| # b) PASS: when all S3 resources Public Access Block Configuration element is present and properties are set to true |
| # c) FAIL: when all S3 resources do not have the Public Access Block Configuration element present or all properties set to true |
| # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_PUBLIC_WRITE_PROHIBITED |
|
|
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
| let s3_buckets_public_write_prohibited = Resources.*[ Type == 'AWS::S3::Bucket' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_PUBLIC_WRITE_PROHIBITED" |
| ] |
|
|
| rule S3_BUCKET_PUBLIC_WRITE_PROHIBITED when %s3_buckets_public_write_prohibited !empty { |
| %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration exists |
| %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicAcls == true |
| %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicPolicy == true |
| %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.IgnorePublicAcls == true |
| %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.RestrictPublicBuckets == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.9,CIS.12,CIS.14 |
| Violation: S3 Bucket Public Write Access controls need to be restricted. |
| Fix: Set S3 Bucket PublicAccessBlockConfiguration properties for BlockPublicAcls, BlockPublicPolicy, IgnorePublicAcls, RestrictPublicBuckets parameters to true. |
| >> |
| } |
| ## Config Rule Name : sagemaker-notebook-no-direct-internet-access |
| ## Config Rule URL: https: |
|
|
| ##################################### |
| # Rule Identifier: |
| # DB_INSTANCE_BACKUP_ENABLED |
| # |
| # Description: |
| # Checks if RDS DB instances have backups enabled. |
| # |
| # Reports on: |
| # AWS::RDS::DBInstance |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no RDS instances present |
| # b) PASS: when all RDS instances have BackupRetentionPeriod set to a positive number |
| # c) FAIL: when all RDS instances have BackupRetentionPeriod set to 0 |
| # d) FAIL: when there are RDS instances with BackupRetentionPeriod property is not present |
| # e) SKIP: when metadata includes the suppression for rule DB_INSTANCE_BACKUP_ENABLED |
|
|
| # |
| # Select all RDS instance resources from incoming template (payload) |
| # |
|
|
| let aws_rds_instances_db_instance_backup_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance' |
| Properties.SourceDBInstanceIdentifier !exists |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "DB_INSTANCE_BACKUP_ENABLED" |
| ] |
|
|
|
|
| rule DB_INSTANCE_BACKUP_ENABLED when %aws_rds_instances_db_instance_backup_enabled !empty { |
| %aws_rds_instances_db_instance_backup_enabled.Properties.BackupRetentionPeriod EXISTS |
| %aws_rds_instances_db_instance_backup_enabled.Properties.BackupRetentionPeriod >= 1 |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.10 |
| Violation: All RDS instances must have automated backup enabled. |
| Fix: Set the BackupRetentionPeriod to values of 1 to 35 to enable backups. |
| >> |
| } |
|
|
| ## Config Rule Name : dynamodb-pitr-enabled |
| ## Config Rule URL: https: |
|
|
| # Rule Intent: All DynamoDB Tables must have Point-In-Time-Recovery enabled |
|
|
| # Expectations: |
| # a) SKIP: when there are no DynamoDB Tables present |
| # b) PASS: when all DynamoDB Tables have PITR enabled |
| # c) FAIL: when all DynamoDB Tables have PITR disabled |
|
|
| # |
| # Select all DynamoDB Table resources from incoming template (payload) |
| # |
| let aws_dynamodb_table_resources = Resources.*[ Type == 'AWS::DynamoDB::Table' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "DYNAMODB_PITR_ENABLED" |
| ] |
|
|
| rule DYNAMODB_PITR_ENABLED when %aws_dynamodb_table_resources !empty { |
| # Ensure ALL DynamoDB Tables have Point-In-Time-Recovery enabled |
| %aws_dynamodb_table_resources.Properties.PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.10 |
| Violation: All DynamoDB Tables must have Point-In-Time-Recovery enabled. |
| Fix: Set the dynamodb table property PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled to true. |
| >> |
| } |
|
|
| ## Config Rule Name : elasticache-redis-cluster-automatic-backup-check |
| ## Config Rule URL: https: |
|
|
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_REPLICATION_ENABLED |
| # |
| # Description: |
| # Checks whether the Amazon S3 buckets have cross-region replication enabled. |
| # |
| # Reports on: |
| # AWS::S3::Bucket |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 resource present |
| # b) PASS: when all S3 resources replication configuration set status is set to Enabled |
| # c) FAIL: when all S3 resources have Versioning Configuration status property not set or set to Suspended |
| # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_REPLICATION_ENABLED |
|
|
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
|
|
| let s3_buckets_replication_enabled = Resources.*[ Type == 'AWS::S3::Bucket' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_REPLICATION_ENABLED" |
| ] |
|
|
| rule S3_BUCKET_REPLICATION_ENABLED when %s3_buckets_replication_enabled !empty { |
| %s3_buckets_replication_enabled.Properties.ReplicationConfiguration exists |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.10 |
| Violation: S3 Bucket replication should be enabled. |
| Fix: Set S3 Bucket ReplicationConfiguration to another S3 Bucket. |
| >> |
| ## TODO regex to identify cross-region |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_VERSIONING_ENABLED |
| # |
| # Description: |
| # Checks if versioning is enabled for your S3 buckets. |
| # |
| # Reports on: |
| # AWS::S3::Bucket |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 resource present |
| # b) PASS: when all S3 resources Versioning Configuration status is set to Enabled |
| # c) FAIL: when all S3 resources have Versioning Configuration status property not set or set to Suspended |
| # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_VERSIONING_ENABLED |
|
|
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
| let s3_buckets_versioning_enabled = Resources.*[ Type == 'AWS::S3::Bucket' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_VERSIONING_ENABLED" |
| ] |
|
|
| rule S3_BUCKET_VERSIONING_ENABLED when %s3_buckets_versioning_enabled !empty { |
| %s3_buckets_versioning_enabled.Properties.VersioningConfiguration exists |
| %s3_buckets_versioning_enabled.Properties.VersioningConfiguration.Status == 'Enabled' |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.10 |
| Violation: S3 Bucket Versioning must be enabled. |
| Fix: Set the S3 Bucket property VersioningConfiguration.Status to 'Enabled' . |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # API_GW_CACHE_ENABLED_AND_ENCRYPTED |
| # |
| # Description: |
| # Checks that all methods in Amazon API Gateway stages have cache enabled and cache encrypted. |
| # |
| # Reports on: |
| # AWS::ApiGateway::Stage |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no API GW Stage Methods present |
| # b) PASS: when all API Stage Method has caching enabled and encrypted |
| # c) FAIL: when API Stage Method does not have caching enabled and encrypted |
| # d) SKIP: when metadata includes the suppression for rule API_GW_CACHE_ENABLED_AND_ENCRYPTED |
|
|
| let api_gw_cache_enabled_encrypted = Resources.*[ Type == 'AWS::ApiGateway::Stage' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "API_GW_CACHE_ENABLED_AND_ENCRYPTED" |
| ] |
|
|
| rule API_GW_CACHE_ENABLED_AND_ENCRYPTED when %api_gw_cache_enabled_encrypted !empty { |
| when %api_gw_cache_enabled_encrypted.Properties.MethodSettings exists { |
| %api_gw_cache_enabled_encrypted.Properties.MethodSettings.*.CacheDataEncrypted == true |
| %api_gw_cache_enabled_encrypted.Properties.MethodSettings.*.CachingEnabled == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: API Gateway Stage Method not set with caching and caching encrypted |
| Fix: API GW Stage Method property CacheDataEncrypted and CachingEnabled set to true |
| >> |
| } |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # CLOUD_TRAIL_ENCRYPTION_ENABLED |
| # |
| # Description: |
| # Checks if AWS CloudTrail is configured to use the server side encryption (SSE) |
| # AWS Key Management Service KMS key encryption. |
| # |
| # Reports on: |
| # AWS::CloudTrail::Trail |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no CloudTrail Trails present |
| # b) PASS: when all CloudTrail Trails have KMSKeyId parameter set |
| # c) FAIL: when there are CloudTrail Trails with KMSKeyId property not present |
| # d) SKIP: when metada has rule suppression for CLOUD_TRAIL_ENCRYPTION_ENABLED |
|
|
| # |
| # Select all CloudTrail Trail resources from incoming template (payload) |
| # |
| let cloudtrail_trails_encryption = Resources.*[ Type == 'AWS::CloudTrail::Trail' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "CLOUD_TRAIL_ENCRYPTION_ENABLED" |
| ] |
|
|
| rule CLOUD_TRAIL_ENCRYPTION_ENABLED when %cloudtrail_trails_encryption !empty { |
| %cloudtrail_trails_encryption.Properties.KMSKeyId EXISTS |
| %cloudtrail_trails_encryption.Properties.KMSKeyId is_string |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: CloudTrail Trail should be used to encrypt logs delivered by CloudTrail. |
| Fix: Set the KMSKeyId parameter to enable encryption. The value can be an alias name prefixed by "alias/", a fully specified ARN to an alias, a fully specified ARN to a key, or a globally unique identifier. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # CLOUDWATCH_LOG_GROUP_ENCRYPTED |
| # |
| # Description: |
| # Checks if a log group in Amazon CloudWatch Logs is encrypted with a |
| # AWS Key Management Service (KMS) managed Customer Master Keys (CMK). |
| # |
| # Reports on: |
| # AWS::Logs::LogGroup |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no cloudwatch logs log group resources present |
| # b) PASS: when all cloudwatch logs log group resources property KmsKeyId is set |
| # c) FAIL: when all cloudwatch logs log group resources property KmsKeyId is not set with valid value |
| # d) SKIP: when metada has rule suppression for CLOUDWATCH_LOG_GROUP_ENCRYPTED |
|
|
| # |
| # Select all cloudwatch logs log group resources from incoming template (payload) |
| # |
| let cloudwatch_logs = Resources.*[ Type == 'AWS::Logs::LogGroup' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "CLOUDWATCH_LOG_GROUP_ENCRYPTED" |
| ] |
|
|
| rule CLOUDWATCH_LOG_GROUP_ENCRYPTED when %cloudwatch_logs !empty { |
| %cloudwatch_logs.Properties.KmsKeyId exists |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: CloudWatch Log LogsGroup does not have KmsKeyId set. |
| Fix: Set the KmsKeyId parameter to a ARN. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # EC2_EBS_ENCRYPTION_BY_DEFAULT |
| # |
| # Description: |
| # Check that Amazon Elastic Block Store (EBS) encryption is enabled by default |
| # Reports on: |
| # AWS::EC2::Volume |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when no EC2 Volume resources are present |
| # b) PASS: when all EC2 Volume resources have the Encrypted property set to true |
| # c) FAIL: when any EC2 Volumes resources do not have the Encrypted property set to true |
| # e) SKIP: when metadata includes the suppression for rule EC2_EBS_ENCRYPTION_BY_DEFAULT |
|
|
| # |
| # Select all EC2 Volume resources from incoming template (payload) |
| # |
| let ec2_ebs_volumes_encrypted_by_default = Resources.*[ Type == 'AWS::EC2::Volume' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "EC2_EBS_ENCRYPTION_BY_DEFAULT" |
| ] |
|
|
| rule EC2_EBS_ENCRYPTION_BY_DEFAULT when %ec2_ebs_volumes_encrypted_by_default !empty { |
| %ec2_ebs_volumes_encrypted_by_default.Properties.Encrypted == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: All EBS Volumes should be encryped |
| Fix: Set Encrypted property to true |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # EFS_ENCRYPTED_CHECK |
| # |
| # Description: |
| # Checks if Amazon Elastic File System (Amazon EFS) is configured to encrypt the file data |
| # using AWS Key Management Service (AWS KMS). The rule is NON_COMPLIANT if the encrypted |
| # key is set to false on DescribeFileSystems or if the KmsKeyId key on DescribeFileSystems |
| # does not match the KmsKeyId parameter. |
| # |
| # Reports on: |
| # AWS::EFS::FileSystem |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no EFS resource present |
| # b) PASS: when all EFS resources have encrypted key property set to true |
| # c) FAIL: when all EFS resources have encrypted key property not set or set to false |
| # d) SKIP: when guard metadata states EFS_ENCRYPTED_CHECK to be suppressed |
|
|
| # |
| # Select all EFS resources from incoming template (payload) |
| # |
| let efs_file_systems_encrypted_check = Resources.*[ Type == 'AWS::EFS::FileSystem' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "EFS_ENCRYPTED_CHECK" |
| ] |
|
|
| rule EFS_ENCRYPTED_CHECK when %efs_file_systems_encrypted_check !empty { |
| %efs_file_systems_encrypted_check.Properties.Encrypted == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: EFS filesystem must be encrypted. |
| Fix: Set the EFS Filesystem property Encrypted parameter to true. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # ELASTICSEARCH_ENCRYPTED_AT_REST |
| # |
| # Description: |
| # Elasticsearch domains must enforce server side encryption |
| # |
| # Reports on: |
| # AWS::Elasticsearch::Domain |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there is no elasticsearch domain present |
| # b) FAIL: when elasticsearch domain has server side encryption set to false |
| # c) PASS: when elasticsearch domain has server side encryption set to true |
| # d) FAIL: when elasticsearch domain has server side encryption property is missing |
| # e) SKIP: when metada has rule suppression for ELASTICSEARCH_ENCRYPTED_AT_REST |
|
|
| # |
| # Select all elasticsearch domains from incoming template |
| # |
| let elasticsearch_domains_encrypted = Resources.*[ Type == 'AWS::Elasticsearch::Domain' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "ELASTICSEARCH_ENCRYPTED_AT_REST" |
| ] |
|
|
| rule ELASTICSEARCH_ENCRYPTED_AT_REST when %elasticsearch_domains_encrypted !empty { |
| %elasticsearch_domains_encrypted.Properties.EncryptionAtRestOptions.Enabled == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: Elasticsearch domains must enforce server side encryption. |
| Fix: Set the EncryptionAtRestOptions.Enabled parameter to true. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # ENCRYPTED_VOLUMES |
| # |
| # Description: |
| # Checks if the EBS volumes that are in an attached state are encrypted. |
| # |
| # Reports on: |
| # AWS::EC2::Volume |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no EBS volume resources present |
| # b) PASS: when all EBS volumes have the KmsKeyId property set or the Encrypted property set to true |
| # c) FAIL: when any EC2 volumes do not have the KmsKeyId or Encrypted property set |
| # e) SKIP: hen metadata includes the suppression for rule ENCRYPTED_VOLUMES |
|
|
| # |
| # Select all EC2 Instance resources from incoming template (payload) |
| # |
| let ebs_volumes_encrypted = Resources.*[ Type == 'AWS::EC2::Volume' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "ENCRYPTED_VOLUMES" |
| ] |
|
|
| rule ENCRYPTED_VOLUMES when %ebs_volumes_encrypted !empty { |
| %ebs_volumes_encrypted.Properties.KmsKeyId !empty |
| OR %ebs_volumes_encrypted.Properties.Encrypted == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: EBS volumes in an attached state must encrypted. |
| Fix: either set the KmsKeyId property to a key ID, key alias, key ARN, or alias ARN |
| or set the Encrypted property to true to encrypt the volume with the account default key or AWS managed key. |
| >> |
| } |
| ## Config Rule Name : kms-cmk-not-scheduled-for-deletion |
| ## Config Rule URL: https: |
|
|
| ##################################### |
| # Rule Identifier: |
| # RDS_SNAPSHOT_ENCRYPTED |
| # |
| # Description: |
| # Checks whether Amazon Relational Database Service (Amazon RDS) DB snapshots are encrypted. |
| # |
| # |
| # Reports on: |
| # AWS::RDS::DBInstance |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no RDS instances present |
| # b) PASS: when all RDS instances have StorageEncrypted set to true |
| # c) FAIL: when all RDS instances have StorageEncrypted set to false |
| # d) FAIL: when there are RDS instances with StorageEncrypted property is not present |
| # e) SKIP: when metadata includes the suppression for rule RDS_SNAPSHOT_ENCRYPTED |
|
|
| # |
| # Select all RDS instance resources from incoming template (payload) |
| # |
| let aws_rds_instances_snapshot_encrypted = Resources.*[ Type == 'AWS::RDS::DBInstance' |
| Properties.SourceDBInstanceIdentifier !exists |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "RDS_SNAPSHOT_ENCRYPTED" |
| ] |
|
|
|
|
| rule RDS_SNAPSHOT_ENCRYPTED when %aws_rds_instances_snapshot_encrypted !empty { |
| %aws_rds_instances_snapshot_encrypted.Properties.StorageEncrypted EXISTS |
| %aws_rds_instances_snapshot_encrypted.Properties.StorageEncrypted == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: All RDS instances must have snapshots encrypted. |
| Fix: Set the StorageEncrypted parameter to true so by default all snapshots are encrypted. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # RDS_STORAGE_ENCRYPTED |
| # |
| # Description: |
| # Checks whether storage encryption is enabled for your RDS DB instances. |
| # |
| # |
| # Reports on: |
| # AWS::RDS::DBInstance |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no RDS instances present |
| # b) PASS: when all RDS instances have StorageEncrypted set to true |
| # c) FAIL: when all RDS instances have StorageEncrypted set to false |
| # d) FAIL: when there are RDS instances with StorageEncrypted property is not present |
| # e) SKIP: when metadata includes the suppression for rule RDS_STORAGE_ENCRYPTED |
|
|
| # |
| # Select all RDS instance resources from incoming template (payload) |
| # |
| let aws_rds_instances_storage_encrypted = Resources.*[ Type == 'AWS::RDS::DBInstance' |
| Properties.SourceDBInstanceIdentifier !exists |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "RDS_STORAGE_ENCRYPTED" |
| ] |
|
|
|
|
| rule RDS_STORAGE_ENCRYPTED when %aws_rds_instances_storage_encrypted !empty { |
| %aws_rds_instances_storage_encrypted.Properties.StorageEncrypted EXISTS |
| %aws_rds_instances_storage_encrypted.Properties.StorageEncrypted == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: All RDS instances must have encrypted storage. |
| Fix: Set the StorageEncrypted parameter to true. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_DEFAULT_LOCK_ENABLED |
| # |
| # Description: |
| # Checks whether Amazon S3 bucket has lock enabled, by default |
| # |
| # Reports on: |
| # AWS::S3::Bucket |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 resource present |
| # b) PASS: when all S3 resources ObjectLockEnabled property is set to true |
| # c) FAIL: when all S3 resources do not have the ObjectLockEnabled property is set to true or is missing |
| # d) SKIP: when metada has rule suppression for S3_BUCKET_DEFAULT_LOCK_ENABLED |
|
|
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
| let s3_buckets_default_lock_enabled = Resources.*[ Type == 'AWS::S3::Bucket' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_DEFAULT_LOCK_ENABLED" |
| ] |
|
|
| rule S3_BUCKET_DEFAULT_LOCK_ENABLED when %s3_buckets_default_lock_enabled !empty { |
| %s3_buckets_default_lock_enabled.Properties.ObjectLockEnabled exists |
| %s3_buckets_default_lock_enabled.Properties.ObjectLockEnabled == true |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: S3 Bucket ObjectLockEnabled must be set to true. |
| Fix: Set the S3 property ObjectLockEnabled parameter to true. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED |
| # |
| # Description: |
| # Checks if your Amazon S3 bucket either has the Amazon S3 default encryption enabled or that the Amazon S3 bucket policy |
| # explicitly denies put-object requests without server side encryption that uses AES-256 or AWS Key Management Service. |
| # |
| # Reports on: |
| # AWS::S3::Bucket |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 resource present |
| # b) PASS: when all S3 resources Bucket Encryption ServerSideEncryptionByDefault is set to either "aws:kms" or "AES256" |
| # c) FAIL: when all S3 resources have Bucket Encryption ServerSideEncryptionByDefault is not set or does not have "aws:kms" or "AES256" configurations |
| # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED |
|
|
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
|
|
| let s3_buckets_server_side_encryption = Resources.*[ Type == 'AWS::S3::Bucket' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED" |
| ] |
|
|
| rule S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED when %s3_buckets_server_side_encryption !empty { |
| %s3_buckets_server_side_encryption.Properties.BucketEncryption exists |
| %s3_buckets_server_side_encryption.Properties.BucketEncryption.ServerSideEncryptionConfiguration[*].ServerSideEncryptionByDefault.SSEAlgorithm in ["aws:kms","AES256"] |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: S3 Bucket must enable server-side encryption. |
| Fix: Set the S3 Bucket property BucketEncryption.ServerSideEncryptionConfiguration.ServerSideEncryptionByDefault.SSEAlgorithm to either "aws:kms" or "AES256" |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # S3_BUCKET_SSL_REQUESTS_ONLY |
| # |
| # Description: |
| # Checks if Amazon S3 buckets have policies that require requests to use Secure Socket Layer (SSL). |
| # |
| # Reports on: |
| # AWS::S3::BucketPolicy |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no S3 Bucket Policy Document resource present |
| # b) PASS: when all S3 Bucket Policy Document set to deny if condition SecureTransport not true |
| # c) FAIL: when all S3 Bucket Policy Document does not have deny on insecure transport actions |
| # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_SSL_REQUESTS_ONLY |
|
|
| # |
| # Select all S3 resources from incoming template (payload) |
| # |
| let s3_buckets_policies_ssl_requests_only = Resources.*[ Type == 'AWS::S3::BucketPolicy' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "S3_BUCKET_SSL_REQUESTS_ONLY" |
| ] |
|
|
| let ssl_secure_bucket_policies = %s3_buckets_policies_ssl_requests_only[ |
| Properties.PolicyDocument { |
| some Statement[*] { |
| Effect == 'Deny' |
| Condition { |
| Bool.'aws:SecureTransport' == false |
| } |
| } |
| } |
| ] |
|
|
| rule S3_BUCKET_SSL_REQUESTS_ONLY when %s3_buckets_policies_ssl_requests_only !empty { |
| %ssl_secure_bucket_policies !empty |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.13,CIS.14 |
| Violation: Bucket policies must feature a statement to enforce TLS usage. |
| Fix: Set a bucket policy statement to include "Condition":{"Bool":{"aws:SecureTransport":false}}. |
| >> |
| } |
|
|
| ##################################### |
| # Rule Identifier: |
| # IAM_USER_NO_POLICIES_CHECK |
| # |
| # Description: |
| # Checks that none of your IAM users have policies attached. IAM users must inherit permissions from IAM groups or roles. |
| # |
| # Reports on: |
| # AWS::IAM::User |
| # |
| # Evaluates: |
| # AWS CloudFormation |
| # |
| # Rule Parameters: |
| # NA |
| # |
| # Scenarios: |
| # a) SKIP: when there are no IAM Users present |
| # b) PASS: when all IAM Users do not have policies attached |
| # c) FAIL: when any IAM User have policies attached |
| # d) SKIP: when metada has rule suppression for IAM_USER_NO_POLICIES_CHECK |
|
|
| # |
| # Select all IAM User resources from incoming template (payload) |
| # |
| let aws_iam_users_no_policies = Resources.*[ Type == 'AWS::IAM::User' |
| Metadata.guard.SuppressedRules not exists or |
| Metadata.guard.SuppressedRules.* != "IAM_USER_NO_POLICIES_CHECK" |
| ] |
|
|
| rule IAM_USER_NO_POLICIES_CHECK when %aws_iam_users_no_policies !empty { |
| %aws_iam_users_no_policies.Properties.Policies empty |
| << |
| Guard Rule Set: cis-top-20 |
| Controls: CIS.16 |
| Violation: Inline policies are not allowed on IAM Users. IAM users must inherit permissions from IAM groups or roles. |
| Fix: Remove the Policies list property from any IAM Users. |
| >> |
| } |
|
|
| let lambda_functions = Resources.*[ |
| Type == "AWS::Lambda::Function" |
| ] |
|
|
| rule LAMBDA_DEPRECATED_RUNTIME when %lambda_functions !empty { |
| %lambda_functions { |
| Properties { |
| when Runtime exists { |
| Runtime !in ["dotnetcore3.1", "nodejs12.x", "python3.6", "python2.7", "dotnet5.0", "dotnetcore2.1", "ruby2.5", "nodejs10.x", "nodejs8.10", "nodejs4.3", "nodejs6.10", "dotnetcore1.0", "dotnetcore2.0", "nodejs4.3-edge", "nodejs"] |
| << |
| Lambda function is using a deprecated runtime. |
| >> |
| } |
| } |
| } |
| } |
|
|
| rule LAMBDA_DEPRECATED_SOON_RUNTIME when %lambda_functions !empty { |
| %lambda_functions { |
| Properties { |
| when Runtime exists { |
| Runtime !in ["nodejs16.x", "nodejs14.x", "python3.7", "java8", "dotnet7", "go1.x", "ruby2.7", "provided"] |
| << |
| Lambda function is using a runtime that is targeted for deprecation. |
| >> |
| } |
| } |
| } |
| } |
|
|