Cloud
Azure WAF: diagnose a rejected JSON body before disabling inspection
A runbook for separating body parsing, WAF rules and size limits on Application Gateway, then restoring the flow without losing security visibility.
An orders API receives JSON through Application Gateway WAF. After a client update, some legitimate requests are rejected and the team considers turning off body inspection. The cause could instead be malformed JSON, a size limit, a security rule or another layer. Disabling inspection obscures that distinction and removes protection from other routes.
In this fictional scenario, the API accepts a JSON order object. The objective is to locate the failing boundary, correct the client contract or the relevant configuration, and validate recovery without sending sensitive data or dangerous payloads into production.
Freeze the path and evidence
Record the UTC time, hostname, path, method, client version, status and transaction ID. Identify the gateway, listener, routing rule and effective WAF policy, including any more specific association. Preserve the deployed version, Detection or Prevention mode, ruleset, exclusions, custom rules and provisioning state.
Correlate access logs, firewall logs and application traces using the transaction and time. A 403 alone does not prove the WAF caused the rejection; a missing backend trace does not prove a parsing error. Check log availability and ingestion delay. Restrict access to captures: URLs, headers and bodies can contain secrets or personal data.
Separate the failure modes
| Evidence | Next check |
|---|---|
| WAF logs report a body parsing failure | Compare the actual JSON and Content-Type with the API contract in a controlled environment. |
| A managed or custom rule is identified | Inspect its message, scope and affected field; qualify the content before calling it a false positive. |
| A size limit is reached | Measure body bytes and compare the effective acceptance and inspection limits. |
| No usable WAF evidence | Verify the request path, logging and other layers before changing the policy. |
Microsoft documents body parsing failure as a mandatory blocking condition in Prevention mode. Disabling a managed rule is therefore not a general fix for a parsing failure. Detection mode logs exceptions, but does not prove the backend receives a valid request.
For policies using CRS 3.2 or later, inspection, inspection depth and size enforcement can be configured independently. An accepted body is not necessarily inspected in full. A higher-priority custom Allow rule can also change the evaluation path: review its priority and conditions, and do not add a broad Allow merely to bypass the symptom.
Reproduce without production data
Use a representative test gateway and API with matching policy, ruleset, mode, limits and client version. Send harmless synthetic payloads with unique correlation identifiers. Do not replay real orders or trigger business side effects.
- Send a small valid JSON body with the expected Content-Type. Check the response, WAF transaction and backend receipt.
- Send deliberately malformed JSON to the same test endpoint and verify WAF behavior and the absence of business effects.
- Compare Content-Type, encoding and actual transmitted bytes between healthy and failing client versions. Test an out-of-contract content type separately, without assuming the WAF and application interpret it identically.
- Test a representative valid body near the permitted limits and then one beyond them, only within the approved test scope. Check inspection settings and events, not just HTTP status.
Acceptance of a valid request does not prove that every property was inspected; one negative test does not establish comprehensive protection either. To exercise a security rule, use a harmless fixture approved by security and verify its expected signal in the isolated environment.
Correct and decide
If the client serializes JSON incorrectly or declares the wrong content type, fix the client and retain API-side contract validation. If a limit is responsible, justify accepted size and inspection depth separately with the security and application owners. For a confirmed managed-rule false positive, consider an exclusion as narrow as the available controls permit; document the affected field and rules, risks, owner and expiry. Do not treat a parsing failure as a rule false positive.
Roll out one change at a time to a bounded canary, with a previous version, an owner and explicit stop conditions. Verify the valid journey, rejection of invalid JSON, the agreed security signal, logs and unaffected routes. If the security test cannot run in production, retain compensating validation and record that limitation.
Stop and restore the previous configuration or client version if rejections persist, an unintended route changes behavior or the expected security control disappears. Rollback cannot retract requests already forwarded: review the potentially less-protected interval and associated application actions before closing the incident.