Project: KICS (Provisioning / Security & Compliance)
File: 5864d189-ee9a-4009-ac0c-8a582e6b7919.md

title: CloudWatch Management Console Auth Failed Alarm Missing hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 5864d189-ee9a-4009-ac0c-8a582e6b7919 Query name: CloudWatch Management Console Auth Failed Alarm Missing Platform: Terraform Severity: <span style="color:#ff7213">Medium</span> Category: Observability URL: Ensure a log metric filter and alarm exist for AWS Management Console authentication failures<br> ```tf title="Positive test num. 1 - tf file" hl_lines="1" resource "awscloudwatchlogmetricfilter" "cisconsoleauthnfailuremetric_filter" { name = "CIS-ConsoleAuthenticationFailure" pattern = "{ ($.eventName = ConsoleLogin) && ($.errorMessage = \"Failed authentication\") }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleAuthenticationFailure" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisconsoleauthnfailurecwalarm" { alarm_name = "CIS-3.6-ConsoleAuthenticationFailure" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metric_name = "XXX NOT YOUR FILTER" namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring failed console logins may decrease lead time to detect an attempt to brute force a credential, which may provide an indicator, such as source IP, that can be used in other event correlation." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cisnomfaconsolesigninmetricfilter" { name = "CIS-ConsoleSigninWithoutMFA" pattern = "{ ($.eventName = \"ConsoleLogin\") && ($.additionalEventData.MFAUsed != \"Yes\") }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleSigninWithoutMFA" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisnomfaconsolesignincw_alarm" { alarm_name = "CIS-3.2-ConsoleSigninWithoutMFA" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisnomfaconsolesigninmetric_filter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring for single-factor console logins will increase visibility into accounts that are not protected by MFA." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ``` ```tf title="Positive test num. 2 - tf file" hl_lines="1" resource "awscloudwatchlogmetricfilter" "cisconsoleauthnfailuremetric_filter" { name = "CIS-ConsoleAuthenticationFailure" pattern = "{ (($.eventName = ConsoleLogin)) && ($.errorMessage != \"Failed authentication\") }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleAuthenticationFailure" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisconsoleauthnfailurecwalarm" { alarm_name = "CIS-3.6-ConsoleAuthenticationFailure" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisconsoleauthnfailuremetricfilter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring failed console logins may decrease lead time to detect an attempt to brute force a credential, which may provide an indicator, such as source IP, that can be used in other event correlation." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ``` ```tf title="Positive test num. 3 - tf file" hl_lines="1" resource "awscloudwatchlogmetricfilter" "cisconsoleauthnfailuremetric_filter" { name = "CIS-ConsoleAuthenticationFailure" pattern = "{ $.eventName != ConsoleLogin &&

= \"Failed authentication\" }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleAuthenticationFailure" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisconsoleauthnfailurecwalarm" { alarm_name = "CIS-3.6-ConsoleAuthenticationFailure" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisconsoleauthnfailuremetricfilter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring failed console logins may decrease lead time to detect an attempt to brute force a credential, which may provide an indicator, such as source IP, that can be used in other event correlation." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ``` <details><summary>Positive test num. 4 - tf file</summary> ```tf hl_lines="1" resource "awscloudwatchlogmetricfilter" "cisconsoleauthnfailuremetric_filter" { name = "CIS-ConsoleAuthenticationFailure" pattern = "{ $.eventName = ConsoleLogin || $.errorMessage = \"Failed authentication\" }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleAuthenticationFailure" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisconsoleauthnfailurecwalarm" { alarm_name = "CIS-3.6-ConsoleAuthenticationFailure" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisconsoleauthnfailuremetricfilter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring failed console logins may decrease lead time to detect an attempt to brute force a credential, which may provide an indicator, such as source IP, that can be used in other event correlation." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ``` </details> ```tf title="Negative test num. 1 - tf file" resource "awscloudwatchlogmetricfilter" "cisconsoleauthnfailuremetric_filter" { name = "CIS-ConsoleAuthenticationFailure" pattern = "{ (($.eventName = ConsoleLogin) && ($.errorMessage = \"Failed authentication\")) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleAuthenticationFailure" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisconsoleauthnfailurecwalarm" { alarm_name = "CIS-3.6-ConsoleAuthenticationFailure" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisconsoleauthnfailuremetricfilter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring failed console logins may decrease lead time to detect an attempt to brute force a credential, which may provide an indicator, such as source IP, that can be used in other event correlation." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cisnomfaconsolesigninmetricfilter" { name = "CIS-ConsoleSigninWithoutMFA" pattern = "{ ($.eventName = \"ConsoleLogin\") && ($.additionalEventData.MFAUsed != \"Yes\") }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleSigninWithoutMFA" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisnomfaconsolesignincw_alarm" { alarm_name = "CIS-3.2-ConsoleSigninWithoutMFA" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisnomfaconsolesigninmetric_filter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring for single-factor console logins will increase visibility into accounts that are not protected by MFA." alarmactions = ["awssnstopic.CISAlertsSNSTopic.arn"] insufficientdataactions = [] } ```