Verify that Azure Application Gateways have the Web Application Firewall (WAF) enabled to protect against common vulnerabilities and enforce access restrictions.
Step-by-Step Guide
Step 1: Determine what attributes are required
First, confirm that the Application Gateway resource type has been discovered and that its attributes are available. According to the schema, we know table is azure_application_gateway and column web_application_firewall_configuration contains the necessary configuration details.
Having worked with Azure, the key identifers are: Subscription Name, ID, Region, WAF
Step 2: Build the Query
Retrieve all Azure Application Gateways to evaluate their WAF status.
SELECT ag.id ASresource, ag.platform_account_id, ag.platform_resource_id, ag.resource_group, ag.web_application_firewall_configuration sub.display_name AS subscription FROM azure_application_gateway ag JOIN azure_subscription sub ON sub.subscription_id = ag.subscription_id;
b. Identify conditions of compliance and non-compliance
Find gateways with WAF enabled.
SELECT ag.id ASresourceFROM azure_application_gateway ag WHERE ag.web_application_firewall_configuration IS NOT NULL;
Find gateways without WAF enabled.
SELECT ag.id ASresourceFROM azure_application_gateway ag WHERE ag.web_application_firewall_configuration ISNULL;
c. Compile Compliance Status
Generate a report indicating compliance status and reasons.
SELECT ag.id ASresource, ag.platform_account_id AS platform_account_id, ag.platform_resource_id AS platform_resource_id,CASEWHEN web_application_firewall_configuration IS NOT NULLTHEN'ok'ELSE'alarm'ENDASstatus,CASEWHEN web_application_firewall_configuration IS NOT NULLTHEN ag.name ||' WAF enabled.'ELSE ag.name ||' WAF disabled.'ENDAS reason, ag.resource_group AS resource_group, sub.display_name AS subscriptionFROM azure_application_gateway AS agJOIN azure_subscription AS subON sub.subscription_id = ag.subscription_id;
Step 3: Build the Control
ID:azure_application_gateway_waf_enabledTitle:Web Application Firewall (WAF) should be enabled for Application GatewayDescription: Deploy Azure Web Application Firewall (WAF) in front of public facing web applications for additional inspection of incoming traffic. Web Application Firewall (WAF) provides centralized protection of your web applications from common exploits and vulnerabilities such as SQL injections, Cross-Site Scripting, local and remote file executions. You can also restrict access to your web applications by countries, IP address ranges, and other http(s) parameters via custom rules.
IntegrationType: - azure_subscriptionQuery:Engine:CloudQL-v0.0.1ListOfTables: - azure_application_gateway - azure_subscriptionParameters: []PrimaryTable:azure_application_gatewayQueryToExecute:| SELECT ag.id AS resource, ag.platform_account_id AS platform_account_id, ag.platform_resource_id AS platform_resource_id, CASE WHEN web_application_firewall_configuration IS NOT NULL THEN 'ok' ELSE 'alarm' END AS status, CASE WHEN web_application_firewall_configuration IS NOT NULL THEN ag.name || ' WAF enabled.' ELSE ag.name || ' WAF disabled.' END AS reason, ag.resource_group AS resource_group, sub.display_name AS subscription FROM azure_application_gateway AS ag JOIN azure_subscription AS sub ON sub.subscription_id = ag.subscription_id;Severity:highTags:nist_sp_800_53_rev_5: - "true"service: - Azure/Network
By following these five steps, you can effectively create and implement a control to ensure that WAF is enabled on all Azure Application Gateways, enhancing your security posture and maintaining compliance.