Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Rule: API Gateway Stage Logging Should Be Enabled

This rule ensures that API Gateway stage logging is enabled to enhance security measures.

RuleAPI Gateway stage logging should be enabled
FrameworkNIST 800-53 Revision 5
Severity
High

Rule Description

The rule requires enabling logging for the API Gateway stage in accordance with the NIST 800-53 Revision 5 guidelines.

Troubleshooting Steps

If there are issues related to enabling logging for the API Gateway stage, you can follow these troubleshooting steps:

  1. 1.

    Verify AWS IAM permissions: Ensure that the user or role attempting to enable logging has appropriate permissions to modify the API Gateway stage settings and the necessary CloudWatch Logs actions.

  2. 2.

    Check CloudWatch Logs configuration: Validate that the CloudWatch Logs service is properly configured and able to receive logs from the API Gateway stage.

  3. 3.

    Review API Gateway stage settings: Confirm that the stage you intend to enable logging for is correctly identified, including the associated API resource and deployment.

  4. 4.

    Examine API Gateway execution policies: Check if there are any execution policies in place that may prevent the logging configuration from being applied. Evaluate the policies and make any necessary modifications.

Code Implementation

To enable logging for the API Gateway stage, you can use the AWS Command Line Interface (CLI) with the following steps:

  1. 1.

    Open a terminal or command prompt.

  2. 2.

    Install the AWS CLI if you haven't already. You can find the installation guide at https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html.

  3. 3.

    Configure AWS CLI with your access key and secret access key using

    aws configure
    .

  4. 4.

    To enable logging, use the

    update-stage
    command along with the
    --log-level
    and
    --access-log-destination-arn
    parameters. Update the command with your specific values.

    aws apigateway update-stage --rest-api-id <rest-api-id> --stage-name <stage-name> --patch-operations "[{\"op\":\"replace\",\"path\":\"/accessLogSettings/destinationArn\",\"value\":\"<log-group-arn>\"},{\"op\":\"replace\",\"path\":\"/accessLogSettings/format\",\"value\":\"<log-format>\"},{\"op\":\"replace\",\"path\":\"/loggingLevel\",\"value\": \"INFO\"}]"
    

    Replace

    <rest-api-id>
    with the ID of your API Gateway Rest API,
    <stage-name>
    with the name of the stage you want to enable logging for,
    <log-group-arn>
    with the ARN of the CloudWatch Logs log group to store the logs, and
    <log-format>
    with the desired log format.

  5. 5.

    Verify that the API Gateway stage logging has been enabled and check for any errors or exceptions.

Remediation Steps

To remediate the issue of the API Gateway stage logging not being enabled, follow these steps:

  1. 1.

    Enable logging at the API Gateway stage: Use the AWS CLI or AWS Management Console to enable logging for the desired API Gateway stage. Follow the instructions in the "Code Implementation" section above.

  2. 2.

    Validate logging configuration: After enabling logging, check if the logs are being successfully delivered to the specified CloudWatch Logs log group. Verify the log format and content to ensure it meets the desired requirements.

  3. 3.

    Monitor and analyze logs: Set up proper monitoring and alerting mechanisms to keep track of the logs generated by the API Gateway stage. Analyze these logs regularly to identify any security, performance, or compliance issues that may arise.

  4. 4.

    Implement necessary improvements: Based on the analysis of the logs, make any required adjustments or improvements to the API Gateway configuration, resource policies, or access controls to align with the NIST 800-53 Revision 5 guidelines and enhance the overall security posture of the API Gateway.

By following these remediation steps, you can ensure that API Gateway stage logging is enabled in compliance with NIST 800-53 Revision 5 guidelines and enhance the security and visibility of your API Gateway implementation.

Is your System Free of Underlying Vulnerabilities?
Find Out Now