For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-alb-is-not-integrated-with-waf.md.
A documentation index is available at /llms.txt.
Externally accessible Application Load Balancers must be protected by a web application firewall (WAF) to block common web attacks such as SQL injection, cross-site scripting, and HTTP-layer abuse that can lead to data exposure or service disruption. Check AWS::ElasticLoadBalancingV2::LoadBalancer resources where Properties.Scheme is not internal and ensure there is an AWS::WAFRegional::WebACLAssociation that associates a web ACL with the load balancer by setting Properties.ResourceArn to the load balancer ARN. Resources missing a corresponding AWS::WAFRegional::WebACLAssociation where ResourceArn references the load balancer will be flagged.
Secure CloudFormation example using the ALB ARN:
MyLoadBalancer:Type:AWS::ElasticLoadBalancingV2::LoadBalancerProperties:Name:my-albScheme:internet-facing# other ALB properties...MyWebACLAssociation:Type:AWS::WAFRegional::WebACLAssociationProperties:ResourceArn:!GetAtt MyLoadBalancer.LoadBalancerArnWebACLId:!Ref MyWebACL