大网数据广告活动
服务器运维问答

Exclude sensitive data from modsecurity log

· 52CE 我爱测

I'm setting up Modsecurity, and I have noticed that some sensitive data (credit card numbers) ends up in the log. How should I prevent this? Preferably I would want it logged, but with the sensitive data mangled. Example of a sen…

问题原文

原帖链接 · klutt · CC BY-SA 3.0

I'm setting up Modsecurity, and I have noticed that some sensitive data (credit card numbers) ends up in the log. How should I prevent this? Preferably I would want it logged, but with the sensitive data mangled.

Example of a sensitive line in access.log

id_offer=28&ch_name=%27+or+1%3D1&ch_address1=Korvstolsv%E4gen+2&ch_address2=&ch_zip=756+48&ch_city=STOCKHOLM&ch_email=aslask%40test.net&ch_phone=018-9999999&cardno=1234456712342345&cvc=123&expire_month=--&expire_year=--&send=Avbryt

Maybe it could be like this instead? (Scroll to right. The sensitive fields are cardno and cvs.)

id_offer=28&ch_name=%27+or+1%3D1&ch_address1=Korvstolsv%E4gen+2&ch_address2=&ch_zip=756+48&ch_city=STOCKHOLM&ch_email=aslask%40test.net&ch_phone=018-9999999&cardno=manglemanglemangle&cvc=xxx&expire_month=--&expire_year=--&send=Avbryt

An alternative would be to completely remove that part if it contains sensitive data.

Because of a comment that I should use POST instead of GET, this was a POST.

--36b1f462-A--
[30/May/2017:19:06:55 +0200] WS2mrwpABwsAACy1A9wAAAAG 185.624.636.40 61597 610.64.66.8 445
--36b1f462-B--
POST /wb/e/check.php HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: sv-SE,sv;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded
Content-Length: 216
Referer: https://example.com/wb/e/auth.php
Connection: keep-alive
Upgrade-Insecure-Requests: 1
--36b1f462-C--
id_offer=28&ch_name=%27+or+1%3D1&ch_address1=Korvstolsv%E4gen+2&ch_address2=&ch_zip=756+48&ch_city=STOCKHOLM&ch_email=aslask%40test.net&ch_phone=018-9999999&cardno=1234456712342345&cvc=123&expire_month=--&expire_year=--&send=Avbryt

已采纳解答

原帖链接 · Marco · CC BY-SA 3.0

Have a deeper look at this: https://www.feistyduck.com/library/modsecurity-handbook-free/online/ch04-logging.html "Remove Sensitive data from Audit Logs".

In your case should be:

SecRule ARGS "@verifyCC \d{13,16}" "phase:5,nolog,pass,\
sanitiseMatched"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-05-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。