Hello @JorneS ,
Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.
I understand that you have set an Azure Application Gateway with WAF in front of your SOAP service and the files that are being uploaded are larger than 2 MB, but your WAF has a request body limit of 128 KB, and the requests are blocked by the WAF because it is too large, and you would like to know how to handle this issue.
You can use the new WAF engine, which is a high-performance, scalable Microsoft proprietary engine and has significant improvements over the previous WAF engine. The new engine, released with CRS 3.2, provides the following benefits:
- Increased request body size limit to 2 MB
- Increased file upload limit to 4 GB
Refer: https://learn.microsoft.com/en-us/azure/web-application-firewall/ag/waf-engine
The allowed Content-type by CRS 3.2 WAF engine are:
setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain'"
Refer: https://github.com/coreruleset/coreruleset/blob/v3.2.0/rules/REQUEST-901-INITIALIZATION.conf#L165
But as you mentioned, only requests with Content-Type of multipart/form-data are considered for file uploads. For content to be considered as a file upload, it has to be a part of a multipart form with a filename header. For all other content types, the request body size limit applies. So, if your Content-Type is set to anything else apart from multipart/form-data, then the request size limit will be applied which is 2 MB for CRS 3.2 WAF engine.
So, you can use the new CRS 3.2 WAF engine for uploading files (which are NOT of Content-Type multipart/form-data) of limit upto 2MB.
Adding MTOM support to the Microsoft WAF is currently under review by Microsoft engineering team for future improvements. You can upvote the feedback in the below forum:
https://feedback.azure.com/d365community/idea/0bc973d9-8326-ec11-b6e6-000d3a4f0789
The WAF Product Group team is also considering if it is possible to increase the file inspection limit further but there is nothing available as of today except the above-mentioned details.
I will discuss this issue with the Azure WAF Product Group team to check if there are any other workarounds and will update them here.
Kindly let us know if the above helps or you need further assistance on this issue.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.