이 페이지는 아직 한국어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우
언제든지 연락주시기 바랍니다. Id: cloudformation-aws-api-gateway-without-waf
Provider: AWS
Platform: CloudFormation
Severity: Medium
Category: Networking and Firewall
Learn More Description API Gateway stages must be protected by a web application firewall (WAF) to block common application-layer attacks such as SQL injection and cross-site scripting, and to reduce the risk of malicious or abusive traffic causing data exposure or service disruption.
Verify that each AWS::ApiGateway::Stage resource (its StageName) has a corresponding AWS::WAFv2::WebACLAssociation resource. The association must set Properties.ResourceArn to the API Gateway stage ARN (format: arn:aws:apigateway:{region}::/restapis/{restapi-id}/stages/{stageName}) and must reference a valid WAF via Properties.WebACLArn. Resources missing the AWS::WAFv2::WebACLAssociation, or whose ResourceArn does not reference the stage’s StageName, will be flagged.
Secure CloudFormation example:
MyWebACL :
Type : AWS::WAFv2::WebACL
Properties :
Name : my-webacl
Scope : REGIONAL
DefaultAction :
Allow : {}
MyApi :
Type : AWS::ApiGateway::RestApi
Properties :
Name : my-api
MyStage :
Type : AWS::ApiGateway::Stage
Properties :
StageName : prod
RestApiId : !Ref MyApi
MyWebACLAssociation :
Type : AWS::WAFv2::WebACLAssociation
Properties :
ResourceArn : !Sub "arn:aws:apigateway:${AWS::Region}::/restapis/${MyApi}/stages/prod"
WebACLArn : !Ref MyWebACL
Compliant Code Examples AWSTemplateFormatVersion : "2010-09-09"
Description : "BatchJobDefinition"
Resources :
Production :
Type : AWS::ApiGateway::Stage
Properties :
StageName : Production
Description : Prod Stage
RestApiId : !Ref MyRestApi
DeploymentId : !Ref TestDeployment
DocumentationVersion : !Ref MyDocumentationVersion
ClientCertificateId : !Ref ClientCertificate
Variables :
Stack : Production
MethodSettings :
- ResourcePath : /
HttpMethod : GET
MetricsEnabled : 'true'
DataTraceEnabled : 'false'
- ResourcePath : /stack
HttpMethod : POST
MetricsEnabled : 'true'
DataTraceEnabled : 'false'
ThrottlingBurstLimit : '999'
- ResourcePath : /stack
HttpMethod : GET
MetricsEnabled : 'true'
DataTraceEnabled : 'false'
ThrottlingBurstLimit : '555'
SampleWebACLAssociation :
Type : 'AWS::WAFv2::WebACLAssociation'
Properties :
WebACLArn : ExampleARNForWebACL
ResourceArn : arn:aws:apigateway:region::/restapis/api-id/stages/Production
Non-Compliant Code Examples AWSTemplateFormatVersion : "2010-09-09"
Description : "BatchJobDefinition"
Resources :
Prod :
Type : AWS::ApiGateway::Stage
Properties :
StageName : Prod
Description : Prod Stage
RestApiId : !Ref MyRestApi
DeploymentId : !Ref TestDeployment
DocumentationVersion : !Ref MyDocumentationVersion
ClientCertificateId : !Ref ClientCertificate
Variables :
Stack : Prod
MethodSettings :
- ResourcePath : /
HttpMethod : GET
MetricsEnabled : 'true'
DataTraceEnabled : 'false'
- ResourcePath : /stack
HttpMethod : POST
MetricsEnabled : 'true'
DataTraceEnabled : 'false'
ThrottlingBurstLimit : '999'
- ResourcePath : /stack
HttpMethod : GET
MetricsEnabled : 'true'
DataTraceEnabled : 'false'
ThrottlingBurstLimit : '555'
SampleWebACLAssociation :
Type : 'AWS::WAFv2::WebACLAssociation'
Properties :
WebACLArn : ExampleARNForWebACL
ResourceArn : arn:aws:apigateway:region::/restapis/api-id/stages/stage