turbot/steampipe-mod-aws-compliance

Control: 10 AWS WAF web ACLs should have at least one rule or rule group

Description

This control checks whether a WAFV2 web access control list (web ACL) contains at least one WAF rule or WAF rule group. The control fails if a web ACL does not contain any WAF rules or rule groups.

A web ACL gives you fine-grained control over all of the HTTP(S) web requests that your protected resource responds to. A web ACL should contain a collection of rules and rule groups that inspect and control web requests. If a web ACL is empty, the web traffic can pass without being detected or acted upon by WAF depending on the default action.

Remediation

To add rules or rule groups to an empty WAFV2 web ACL, see Editing a Web ACL in the AWS WAF Developer Guide.

Usage

Run the control in your terminal:

powerpipe control run aws_compliance.control.foundational_security_waf_10

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run aws_compliance.control.foundational_security_waf_10 --share

SQL

This control uses a named query:

with rule_group_count as (
select
arn,
count(*) as rule_group_count
from
aws_wafv2_web_acl,
jsonb_array_elements(rules) as r
where
r -> 'Statement' -> 'RuleGroupReferenceStatement' ->> 'ARN' is not null
group by
arn
)
select
a.arn as resource,
case
when rules is null or jsonb_array_length(rules) = 0 then 'alarm'
else 'ok'
end as status,
case
when rules is null or jsonb_array_length(rules) = 0 then title || ' has no attached rules.'
else title || ' has ' || c.rule_group_count || ' rule group(s) and ' || (jsonb_array_length(rules) - c.rule_group_count) || ' rule(s) attached.'
end as reason
, region, account_id
from
aws_wafv2_web_acl as a
left join rule_group_count as c on c.arn = a.arn;

Tags