Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Ensure a Log Metric Filter and Alarm Exist for Unauthorized API Calls Rule

This rule ensures the presence of a log metric filter and alarm for unauthorized API calls.

RuleEnsure a log metric filter and alarm exist for unauthorized API calls
Frameworkcis_v140
Severity
Low

Rule Description:

In order to maintain a secure environment, it is crucial to track and monitor any unauthorized API calls. This rule ensures the existence of a log metric filter and alarm for unauthorized API calls, as per the CIS benchmark version 1.40 (cis_v140).

Troubleshooting Steps:

If the log metric filter and alarm for unauthorized API calls are not present, follow the steps below for troubleshooting:

  1. 1.

    Check if CloudTrail is enabled: Ensure that CloudTrail, the AWS service responsible for logging API activity, is enabled for your account. If not, enable it by following the AWS documentation for CloudTrail setup.

  2. 2.

    Verify log metric filter existence: In the CloudWatch console, navigate to the "Log groups" section and locate the CloudTrail log group for your AWS account. Check if a log metric filter with the following configuration exists:

    Filter pattern: {($.errorCode = "UnauthorizedOperation") || ($.errorCode = "AccessDenied")}

    If the filter is missing, proceed to the next step.

  3. 3.

    Create a log metric filter: In the CloudWatch console, select your CloudTrail log group and click on "Create metric filter." Configure the filter using the following information:

    Filter pattern: {($.errorCode = "UnauthorizedOperation") || ($.errorCode = "AccessDenied")}

    Assign a metric namespace and name for the filter.

    Choose a metric value (e.g., "1") to denote unauthorized calls.

    Check if the log metric filter is now created successfully.

  4. 4.

    Verify alarm existence: In the CloudWatch console, navigate to the "Alarms" section and check if an alarm with the following criteria exists:

    Alarm state: ALARM Alarm name: Unauthorized_API_Calls

    If the alarm is missing, proceed to the next step.

  5. 5.

    Create an alarm: In the CloudWatch console, select "Create alarm" and configure the alarm with the following information:

    Alarm name: Unauthorized_API_Calls

    Select the metric filter you created earlier as the source for the alarm.

    Set the threshold to "Greater/Equal" and specify the value (e.g., "1") to denote unauthorized calls.

    Choose the action to be taken when the alarm state is triggered (e.g., sending a notification email).

    Ensure the alarm is created successfully.

Necessary Code:

No code is necessary for this rule. Configuration and setup involve using the AWS Management Console.

Step-by-Step Guide for Remediation:

  1. 1.

    Go to the AWS Management Console and log in to your AWS account.

  2. 2.

    Ensure that CloudTrail is enabled. If not, follow the AWS documentation to enable CloudTrail for your AWS account.

  3. 3.

    Open the CloudWatch console and navigate to the "Log groups" section.

  4. 4.

    Locate the CloudTrail log group associated with your AWS account.

  5. 5.

    Verify if a log metric filter with the provided filter pattern exists. If not, follow the steps below to create one:

    • Select the CloudTrail log group.
    • Click on the "Create metric filter" button.
    • Configure the filter with the provided filter pattern.
    • Assign a metric namespace and name for the filter.
    • Choose a metric value to denote unauthorized calls (e.g., "1").
    • Confirm and create the log metric filter.
  6. 6.

    Once the log metric filter is created, go to the "Alarms" section in the CloudWatch console.

  7. 7.

    Check if an alarm with the name "Unauthorized_API_Calls" exists. If not, follow the steps below to create one:

    • Click on the "Create alarm" button.
    • Configure the alarm with the provided criteria, using the log metric filter as the source.
    • Set the threshold to "Greater/Equal" and specify the metric value for unauthorized calls.
    • Select an action to be taken when the alarm state is triggered (e.g., sending a notification email).
    • Confirm and create the alarm.
  8. 8.

    Ensure that the alarm is now successfully created and will trigger whenever unauthorized API calls occur.

By following the above steps, you can ensure the existence of a log metric filter and alarm for unauthorized API calls, helping you effectively monitor and prevent potential security breaches.

Is your System Free of Underlying Vulnerabilities?
Find Out Now