A rule stating that API Gateway stage logging must be enabled for compliance
Rule | API Gateway stage logging should be enabled |
Framework | NIST 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:
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:
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.