modsec 日志文件中的密码

modsec 日志文件中的密码

是否有任何最佳实践或方法来防止某些数据(例如密码)被登录到 mod-security 的日志文件?

我们的 Apache 服务器(以及 Karaf 后端)收到一个调用,该调用似乎偶尔会触发 mod-security 规则。此调用包含密码作为 URL 参数之一。

我如何让 mod-security 报告规则但隐藏日志中的某些信息?显然我想知道规则是否已被触发,但我担心在日志中留下敏感数据。

下面是一个例子(可疑的部分在第二行):-

--0a6bf76f-C--
userName=fred.bloggs%40whatever.com&password=SHOULDNTBEHERE&%3Asubmit=1
--0a6bf76f-F--
HTTP/1.1 200 OK
Ajax-Location: ./home
Content-Type: text/xml;charset=ISO-8859-1
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Pragma: no-cache
Cache-Control: no-cache, no-store
Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Sat, 18-Apr-2015 08:06:08 GMT
Strict-Transport-Security: max-age=15768000
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked

--0a6bf76f-E--
<ajax-response><redirect><![CDATA[./home]]></redirect></ajax-response>
--0a6bf76f-H--
Message: Warning. Pattern match "(.*?)=(?i)(?!.*secure.*)(.*$)" at RESPONSE_HEADERS:Set-Cookie. [file "/etc/modsecurity/activated_rules/modsecurity_crs_55_application_defects.conf"] [line "99"] [id "981185"] [msg "AppDefect: Missing Secure Cookie Flag for rememberMe."] [tag "WASCTC/WASC-15"] [tag "MISCONFIGURATION"] [tag "http://websecuritytool.codeplex.com/wikipage?title=Checks#cookie-not-setting-secure-flag"]
Message: Warning. Pattern match "(.*?)=(?i)(?!.*httponly.*)(.*$)" at RESPONSE_HEADERS:Set-Cookie. [file "/etc/modsecurity/activated_rules/modsecurity_crs_55_application_defects.conf"] [line "83"] [id "981184"] [msg "AppDefect: Missing HttpOnly Cookie Flag for rememberMe."] [tag "WASCTC/WASC-15"] [tag "MISCONFIGURATION"] [tag "http://websecuritytool.codeplex.com/wikipage?title=Checks#cookie-not-setting-httponly-flag"]
Apache-Handler: proxy-server
Stopwatch: 1429430768382701 63597 (- - -)
Stopwatch2: 1429430768382701 63597; combined=13093, p1=317, p2=11903, p3=242, p4=130, p5=395, sr=110, sw=106, l=0, gc=0
Response-Body-Transformed: Dechunked
Producer: ModSecurity for Apache/2.6.3 (http://www.modsecurity.org/); OWASP_CRS/2.2.5.
Server: Apache
WebApp-Info: "default" "-" ""

--0a6bf76f-Z--

这是在 Ubuntu 12.04 上运行的 Apache 2.2。

谢谢。

答案1

您应该设置一个清理规则:

https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#sanitiseArg

5kKate 密码位于 C 部分,即请求正文。POST 请求的密码应该放在此处。我同意您不应通过 GET 请求在 URL 中使用它们(在这种情况下,它们应该放在审计日志的 B 部分中)。

答案2

您可以配置 mod_security 以禁用记录请求 URL。这是我从以下配置中删除的字母 B。

SecAuditLogParts ACIFHZ

你可以在这里阅读更多:http://resources.infosecinstitute.com/analyzing-mod-security-logs/

但更大的问题是您在 URL 中发送明文密码。我不太熟悉 Karaf,但如果他们没有更安全的身份验证方式,我会感到惊讶。

相关内容