Ensure CORS is configured to prevent sharing across all domains for AWS API Gateway V2 API

MEDIUM

Description

Using misconfigured CORS in AWS API Gateway V2 API Policy that allows sharing across all resources may lead to unauthorized access.

Remediation

In AWS Console -

  1. Sign in to the AWS Console and go to the API Gateway console.
  2. Select the API from the APIs list.
  3. Select a resource under Resources to enable CORS for all the methods on the resource.
  4. Alternatively, choose a method under the resource to enable CORS for just that method.
  5. Choose Enable CORS from the Actions drop-down menu.
  6. In Confirm method changes, choose Yes to overwrite existing values to confirm the new CORS settings.

In Terraform -

  1. In the aws_apigatewayv2_api resource, configure the cors_configuration block as needed, including the necessary allow field settings.

References:
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apigatewayv2_api

Policy Details

Rule Reference ID: AC_AWS_0467
CSP: AWS
Remediation Available: Yes
Resource Category: Virtual Network
Resource Type: API Gateway

Frameworks