Description
Identify public REST operations and those that require caller permissions. Protected methods can use a Lambda or Cognito authorizer or IAM authentication. Check the settings on the deployed method.
Potential impact
A new operation without the required check can expose sensitive data or functions to unintended callers.
Remediation
When importing OpenAPI, define the security scheme and apply it in the security field of each protected operation. API Gateway REST APIs ignore top-level security. Test that authorized requests succeed and that missing or insufficient credentials are rejected.
Examples
These excerpts omit the full specification’s info, paths and backend integrations.
Before
- name: Setup AWS API Gateway
community.aws.aws_api_gateway:
swagger_dict:
{
"openapi": "3.0.0",
"components": {
"securitySchemes": {
"request_authorizer_single_stagevar": {
"type": "apiKey",
"name": "Unused",
"in": "header"
}
}
}
}
stage: production
endpoint_type: EDGE
state: present
swagger_dict declares only a header apiKey scheme. It configures no AWS authorizer and identifies no operation that uses the scheme.
After
- name: Setup AWS API Gateway
community.aws.aws_api_gateway:
swagger_file: swaggerFile.yaml
stage: production
endpoint_type: EDGE
state: present
swagger_file imports swaggerFile.yaml. Check that the authentication settings in that file take effect on the deployed methods.