920160 - Content-Length HTTP header is not numeric triggered on WAF

_Jaydeep Choudhari.AZ 0 Reputation points
2023-08-15T06:00:36.5766667+00:00

Hello everyone,

I'm encountering an issue with my Azure-hosted application. It's hosted on Azure app service, and I have the OSWAP_3.2 WAF policy enabled on my application gateway.

Recently, I've started receiving a 403 Forbidden error when making an API POST request. I'm using Postman for this request, and I believe the "Content-Length" header is automatically added by Postman.

Here are the details of the error from the firewall logs:

{
    "timeStamp": "2023-08-15T05:25:12+00:00",
    "resourceId": "/SUBSCRIPTIONS/XXXXX-XXXX-XX-AA76-391CEB2CFDBA/RESOURCEGROUPS/OSS-XXX-USE2-XXXXXSVC-DEV-RG01/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/AZUSWAXXXXX",
    "operationName": "ApplicationGatewayFirewall",
    "category": "ApplicationGatewayFirewallLog",
    "properties": {
        "instanceId": "appgw_0",
        "clientIp": "20.187.22.22",
        "requestUri": "\/connect\/token",
        "ruleSetType": "OWASP CRS",
        "ruleSetVersion": "3.2",
        "ruleId": "920160",
        "ruleGroup": "REQUEST-920-PROTOCOL-ENFORCEMENT",
        "message": "Content-Length HTTP header is not numeric.",
        "action": "Matched",
        "details": {
            "message": "Pattern match ^\\d+$ at REQUEST_HEADERS:content-length.",
            "data": "{ found within [REQUEST_HEADERS:]}",
            "file": "REQUEST-920-PROTOCOL-ENFORCEMENT.conf",
            "line": "130"
        },
        "hostname": "dev.xyz.com",
        "transactionId": "23e63bed8a6e218e2d286ca237216051",
        "policyId": "154#_subscriptions_xxxxx-xxx-xxx-aa76-391ceb2cfdba_resourceGroups_OSS-XXX-USE2-XXXX-DEV-RG01_providers_Microsoft.Network_ApplicationGatewayWebApplicationFirewallPolicies_WAF-azuswa1xxxxxx",
        "policyScope": "Global",
        "policyScopeName": "Global",
        "engine": "Azwaf"
    }
}

I tried adding an exclusion to stop checking the "Content-Length" header, but that didn't work. Could this be a false positive?

Any advice or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated.

Thank you in advance for your assistance!

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,213 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.