Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Rule: Ensure a log metric filter and alarm exist for unauthorized API calls

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

RuleEnsure a log metric filter and alarm exist for unauthorized API calls
FrameworkNIST Cybersecurity Framework (CSF) v1.1
Severity
Low

Rule Description:

This rule ensures that a log metric filter and alarm exist to detect unauthorized API calls, based on the requirements of the NIST Cybersecurity Framework (CSF) v1. The CSF is a set of guidelines and best practices designed to improve the cybersecurity posture of organizations.

Troubleshooting Steps:

If the log metric filter and alarm for unauthorized API calls are not properly configured, here are a few troubleshooting steps to resolve the issue:

  1. 1.
    Verify IAM Role Permissions: Ensure that the IAM role associated with the log metric filter and alarm has the necessary permissions to access CloudWatch Logs and create/update metrics and alarms.
  2. 2.
    Check Log Group Subscription: Ensure that the log group containing API logs is properly subscribed to CloudWatch Logs. If not, create a subscription filter to forward the relevant logs to CloudWatch.
  3. 3.
    Validate Log Metric Filter: Review the log metric filter configuration to ensure it is accurately filtering and extracting the necessary information from the API logs. Check the filter pattern and field mappings.
  4. 4.
    Test Alarm Thresholds: Confirm that the alarm thresholds are set appropriately to trigger an alert when unauthorized API calls are detected. Adjust the thresholds if necessary.
  5. 5.
    Verify Alarm Actions: Check the configured actions for the alarm, such as sending a notification, triggering an AWS Lambda function, or invoking an SNS topic. Ensure that these actions are properly configured and functional.
  6. 6.
    Monitor for Log Ingestion: If there are no logs being ingested in the log group, investigate the issue with API logging configuration. Ensure that the appropriate logs are being generated by the APIs.

Necessary Code:

The following is an example CloudFormation template code snippet to create a log metric filter and alarm for unauthorized API calls. Modify the code as per your AWS CloudFormation configuration:

Resources:
  LogMetricFilter:
    Type: AWS::Logs::MetricFilter
    Properties:
      LogGroupName: /aws/apigateway/{your-log-group-name}
      FilterPattern: '{your-filter-pattern}'
      MetricTransformations:
        - MetricName: UnauthorizedApiCalls
          MetricNamespace: NIST/CSF
          MetricValue: '1'
  UnauthorizedApiCallsAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: UnauthorizedApiCallsAlarm
      AlarmDescription: Unauthorized API Calls Alarm
      MetricName: UnauthorizedApiCalls
      Namespace: NIST/CSF
      Statistic: SampleCount
      Period: 300
      EvaluationPeriods: 1
      Threshold: 1
      ComparisonOperator: GreaterThanOrEqualToThreshold
      AlarmActions:
        - arn:aws:sns:us-east-1:1234567890:your-sns-topic
      AlarmDescription: Unauthorized API Calls Alarm
      Dimensions:
        - Name: LogGroupName
          Value: /aws/apigateway/{your-log-group-name}

Note: Replace the placeholders

{your-log-group-name}
,
{your-filter-pattern}
, and
arn:aws:sns:us-east-1:1234567890:your-sns-topic
with your actual values.

Remediation Steps:

Follow these steps to remediate the rule violation and ensure the log metric filter and alarm are in place for unauthorized API calls:

  1. 1.
    Navigate to the AWS Management Console and open the CloudFormation service.
  2. 2.
    Create a new CloudFormation stack or select an existing one where you want to add the log metric filter and alarm.
  3. 3.
    Copy and paste the necessary code provided above into the CloudFormation template section.
  4. 4.
    Modify the code to specify the correct log group name, filter pattern, and alarm actions.
  5. 5.
    Click on "Next" and proceed through the CloudFormation steps, providing any required parameters.
  6. 6.
    Review the stack details and click on "Create" to initiate the creation/update of the CloudFormation stack.
  7. 7.
    Wait for the stack creation/update to complete, ensuring there are no errors during the process.
  8. 8.
    Once the stack is created/updated successfully, the log metric filter and alarm for unauthorized API calls will be in place.
  9. 9.
    Verify the alarm is properly functioning by intentionally triggering unauthorized API calls and confirming the alarm triggers and sends the defined notification.

By following these steps, you will successfully implement the log metric filter and alarm for unauthorized API calls in accordance with the NIST Cybersecurity Framework (CSF) v1.

Is your System Free of Underlying Vulnerabilities?
Find Out Now