Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Rule: API Gateway Stage Logging Should Be Enabled

A rule stating that API Gateway stage logging must be enabled for compliance

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

Description

The rule mandates enabling logging for API Gateway stages to comply with the NIST 800-53 Revision 5 security standard. This rule ensures that all activities and requests made to the API Gateway stages are recorded and can be monitored for security and auditing purposes.

Enabling logging provides a valuable mechanism for troubleshooting, monitoring, and investigating potential security incidents or unauthorized access attempts within the API Gateway.

Troubleshooting Steps

If the API Gateway stage logging is not enabled, follow these steps to enable it:

  1. 1.
    Login to the AWS Management Console.
  2. 2.
    Go to the API Gateway service.
  3. 3.
    Choose the API containing the desired stage for which you want to enable logging.
  4. 4.
    Select the "Stages" option from the left-hand menu.
  5. 5.
    Next to the desired stage, click on the "Logs/Tracing" tab.
  6. 6.
    Under "Access logs", click on the "Edit" button.
  7. 7.
    Select "Enable CloudWatch Logs" for capturing access logs.
  8. 8.
    Choose an existing CloudWatch log group or create a new one.
  9. 9.
    Set the log format to the desired format (e.g., JSON, CSV, etc.).
  10. 10.
    Click on the "Save Changes" button to enable logging for the selected stage.

Code Example

If you prefer using the AWS Command Line Interface (CLI) for enabling API Gateway stage logging, you can use the following command:

aws apigateway update-stage \
    --rest-api-id <API_ID> \
    --stage-name <STAGE_NAME> \
    --patch-operations op=replace,path=/accessLogSettings/destinationArn,value=<LOG_GROUP_ARN> \
    --patch-operations op=replace,path=/accessLogSettings/format,value=<LOG_FORMAT>

Replace the following placeholders:

  • <API_ID>
    : The ID of the API containing the desired stage.
  • <STAGE_NAME>
    : The name of the stage for which you want to enable logging.
  • <LOG_GROUP_ARN>
    : The Amazon Resource Name (ARN) of the CloudWatch log group.
  • <LOG_FORMAT>
    : The desired format for the access logs (e.g., 'json', 'csv', etc.).

Once executed, the command will enable logging for the specified API Gateway stage.

Remediation Steps

To remediate the non-compliance issue of disabled API Gateway stage logging, follow the below steps:

  1. 1.
    Login to the AWS Management Console.
  2. 2.
    Go to the API Gateway service.
  3. 3.
    Choose the API containing the desired stage for which you want to enable logging.
  4. 4.
    Select the "Stages" option from the left-hand menu.
  5. 5.
    Next to the desired stage, click on the "Logs/Tracing" tab.
  6. 6.
    Under "Access logs", click the "Edit" button.
  7. 7.
    Select "Enable CloudWatch Logs" for capturing access logs.
  8. 8.
    Choose an existing CloudWatch log group or create a new one.
  9. 9.
    Set the log format to the desired format (e.g., JSON, CSV, etc.).
  10. 10.
    Click on the "Save Changes" button to enable logging for the selected stage.

Alternatively, you can use the AWS Command Line Interface (CLI) to enable API Gateway stage logging. Execute the following command:

aws apigateway update-stage \
    --rest-api-id <API_ID> \
    --stage-name <STAGE_NAME> \
    --patch-operations op=replace,path=/accessLogSettings/destinationArn,value=<LOG_GROUP_ARN> \
    --patch-operations op=replace,path=/accessLogSettings/format,value=<LOG_FORMAT>

Ensure you replace the placeholders mentioned earlier with the appropriate values specific to your API Gateway and logging configuration.

By following these steps, you will successfully enable logging for the API Gateway stages, ensuring compliance with the NIST 800-53 Revision 5 security standard.

Is your System Free of Underlying Vulnerabilities?
Find Out Now