Nginx模块代码error_page指令问题

问题描述 投票:0回答:1

我利用ModSecurity WAF帮助阻止tx在NGINX上被认为是危险的:https://github.com/SpiderLabs/ModSecurityhttps://github.com/SpiderLabs/ModSecurity-nginx

我的问题可以在这里找到:https://github.com/SpiderLabs/ModSecurity-nginx/issues/182

我的问题的TLDR是nginx error_page指令重置了发起方客户端重定向到GET期间发送的HTTP请求方法标头。这会导致WAF误报日志,以报告客户端使用GET等方式发送了HTTP正文。当客户端确实发送了POST时,由于某些情况,NGINX命中了error_page重定向,而上游代理在反向代理调用上超时了。

为了解决这个问题,我似乎需要在此文件部分中侵入或PR某些内容:https://github.com/SpiderLabs/ModSecurity-nginx/blob/master/src/ngx_http_modsecurity_rewrite.c#L145

以类似sudo代码的目标:

//SAFE to trust this value as its the originating client HTTP REQUEST Method HEADER when not error_page
if(!r->error_page){
   const char *n_method = ngx_str_to_char(r->method_name, r->pool);
  //HOW to add a transaction persistent context value here to store STORED_CTX_HTTP_REQUEST_METHOD_HEADER_VALUE???
}
else {  //IF ERROR_PAGE, then we need to grab the original stored CTX request http method header value.
  const char *n_method = ngx_str_to_char(STORED_CTX_HTTP_REQUEST_METHOD_HEADER_VALUE); 
}

并且在这里,我无法解决上述sudo代码。如何在这里创建一个tx上下文安全变量,该变量可以在各个阶段持续存在并且内部error_page重定向以存储原始客户端http方法标头?

我登陆了这些NGINX页面指南,但是到目前为止,还没有任何骰子真正看到任何切入我想要的东西:https://www.evanmiller.org/nginx-modules-guide.html

寻找任何了解该问题并可能将我的sudo代码转换为可以在沙盒环境中测试的东西的NGINX / C专家。

请注意,我无法摆脱NGINX error_page指令调用。因此,我确实需要我相信的上述sudo代码的解决方案。

谢谢!

c nginx mod-security nginx-module
1个回答
0
投票

感谢分享!我们在开发Wallarm Nginx模块时解决了一些类似的问题。简短的答案是肯定的,这里使用了错误的Nginx阶段。原因很简单-这是Apache的ModSecurity端口,与Nginx阶段无关。

我会问我们的开发团队,我们是否可以提供补丁帮助。

© www.soinside.com 2019 - 2024. All rights reserved.