我在对API的PUT请求上收到“403 ModSecurity Action”。获取和发布按预期工作。
我想到的第一件事是WAF可能会阻止特定的动词(即PUT),即“请求-911-方法-执行”More info here
但后来网络组找到了请求的记录
TimeGenerated: 2018-05-04T09:55:42Z
AzureDiagnostics 5/4/2018 10:55:42.000 AM AzureDiagnostics ApplicationGatewayFirewall ApplicationGatewayFirewallLog WAF-CPP-01 52.233.137.239 OWASP 3.0 200002 Blocked Global Access denied with code 400 (phase 2). Match of "eq 0" against "REQBODY_ERROR" required. JSON parsing error: parse error: invalid object key (must be a string)\x0a cpp.api.cardiff.gov.uk ApplicationGatewayRole_IN_0
$table AzureDiagnostics
TenantId 31c4d3f2-394f-4c06-833c-9d22912ec8ab
SourceSystem Azure
TimeGenerated 2018-05-04T09:55:42Z
Type AzureDiagnostics
ResourceId /SUBSCRIPTIONS/ECA58BF3-DF5E-41E6-B113-BB96E1EBC768/RESOURCEGROUPS/RG-CPP-COREINFRASTRUCTURE/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/WAF-CPP-01
OperationName ApplicationGatewayFirewall
Category ApplicationGatewayFirewallLog
Resource WAF-CPP-01
ResourceGroup RG-CPP-COREINFRASTRUCTURE
ResourceProvider MICROSOFT.NETWORK
SubscriptionId eca58bf3-df5e-41e6-b113-bb96e1ebc768
clientIp_s 52.233.137.239
ruleSetType_s OWASP
ruleSetVersion_s 3.0
ruleId_s 200002
Message Mandatory rule. Cannot be disabled. Failed to parse request body.
action_s Blocked
site_s Global
details_message_s Access denied with code 400 (phase 2). Match of "eq 0" against "REQBODY_ERROR" required.
details_data_s JSON parsing error: parse error: invalid object key (must be a string)\x0a
hostname_s cpp.api.cardiff.gov.uk
instanceId_s ApplicationGatewayRole_IN_0
requestUri_s /Notification/api/Notification/
ResourceType APPLICATIONGATEWAYS
clientPort_d 0
AzureDiagnostics 5/4/2018 10:55:42.000 AM AzureDiagnostics ApplicationGatewayAccess ApplicationGatewayAccessLog WAF-CPP-01 ApplicationGatewayRole_IN_0 52.233.137.239 PUT
$table AzureDiagnostics
TenantId 31c4d3f2-394f-4c06-833c-9d22912ec8ab
SourceSystem Azure
TimeGenerated 2018-05-04T09:55:42Z
Type AzureDiagnostics
ResourceId /SUBSCRIPTIONS/ECA58BF3-DF5E-41E6-B113-BB96E1EBC768/RESOURCEGROUPS/RG-CPP-COREINFRASTRUCTURE/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/WAF-CPP-01
OperationName ApplicationGatewayAccess
Category ApplicationGatewayAccessLog
Resource WAF-CPP-01
ResourceGroup RG-CPP-COREINFRASTRUCTURE
ResourceProvider MICROSOFT.NETWORK
SubscriptionId eca58bf3-df5e-41e6-b113-bb96e1ebc768
instanceId_s ApplicationGatewayRole_IN_0
clientIP_s 52.233.137.239
httpMethod_s PUT
requestUri_s /Notification/api/Notification/
requestQuery_s -
userAgent_s PostmanRuntime/7.1.1
httpVersion_s HTTP/1.1
sslEnabled_s on
host_s cpp.api.cardiff.gov.uk
ResourceType APPLICATIONGATEWAYS
clientPort_d 1,025
httpStatus_d 400
receivedBytes_d 1,360
sentBytes_d 185
timeTaken_d 56
错误提到请求主体有错误,JSON不正确。但我这边看起来一切正常:/
我已经通过了斯瓦格和 Postman 的测试。
2条答案
按热度按时间mbzjlibv1#
我们的WAF刚刚遇到了这个问题。问题不是JSON格式不正确,而是它太大了。我一直无法找到构成大JSON负载的确切数字,但如果请求的内容长度超过120- 150 kb,就会发生这种情况。
h5qlskok2#
我遇到了同样的问题,结果发现这是应用网关WAF策略中的一个限制,该策略只允许它检查大小在128KB以下的请求主体。
对我来说,基础设施是在Azure中的,显然应用网关的版本升级将允许检查(和解析)高达2MB的主体。
对于Azure中的应用程序网关,正文大小限制记录在此处:https://learn.microsoft.com/en-us/azure/web-application-firewall/ag/application-gateway-waf-request-size-limits#limits