Apache2 ModSecurity2 не работает (Ubuntu 14.04)

0

Я следил за официальной документацией на wiki.ubuntuusers.de, но мой файл test.php по-прежнему позволяет злоумышленный доступ, например test.php? Secret_file = my/secret/file.txt. Идеи почему?

test.php:

<?php
    $secret_file = $_GET['secret_file'];
    include ( $secret_file);
?>

Ожидаемый результат test.php? Secret_file = my/secret/file.txt отключен HTTP 403 -access, но мой веб-сервер по-прежнему показывает содержимое включенного файла.

Мои шаги по установке:

sudo apt-get install libapache2-mod-security2
sudo a2enmod security2
sudo a2enmod headers

Configuration

sudo cp /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf

# Enable ModSecurity, attaching it to every transaction. Use detection
# only to start with, because that minimises the chances of post-installation
# disruption.
#
#SecRuleEngine DetectionOnly
#
SecRuleEngine On                                   

Include /usr/share/modsecurity-crs/*.conf
Include /usr/share/modsecurity-crs/base_rules/*.conf
Include /usr/share/modsecurity-crs/optional_rules/*.conf

SecDebugLog /var/log/apache2/modsec_debug.log
SecDebugLogLevel 5

sudo service apache2 restart
sudo service apache2 force-reload 

Вот мой файл modsec_debug.log: modsec_debug.log

Когда я вызываю вредоносный test.php? Secret_file = my/secret/file.txt, он говорит:

[Sun Jan 25 13:21:51.773188 2015] [:error] [pid 14993] [client x.x.x.x] ModSecurity: Warning. Match of "eq 1" against "&ARGS:CSRF_TOKEN" required. [file "/usr/share/modsecurity-crs/optional_rules/modsecurity_crs_43_csrf_protection.conf"] [line "31"] [id "981143"] [msg "CSRF Attack Detected - Missing CSRF Token."] [hostname "example.com"] [uri "/test.php"] [unique_id "VMTf31XWGY4AADqRE00AAAAB"]

[Sun Jan 25 13:21:51.777069 2015] [:error] [pid 14993] [client x.x.x.x] ModSecurity: Warning. Operator LT matched 5 at TX:inbound_anomaly_score. [file "/usr/share/modsecurity-crs/base_rules/modsecurity_crs_60_correlation.conf"] [line "33"] [id "981203"] [msg "Inbound Anomaly Score (Total Inbound Score: 3, SQLi=0, XSS=0): Request from Known SPAM Source (Previous RBL Match)"] [hostname "example.com"] [uri "/test.php"] [unique_id "VMTf31XWGY4AADqRE00AAAAB"]

[Sun Jan 25 13:21:51.777133 2015] [:error] [pid 14993] [client x.x.x.x] ModSecurity: Warning. Match of "rx (?i:(<meta.*?(content|value)=\\"text/html;\\\\s?charset=|<\\\\?xml.*?encoding=))" against "RESPONSE_BODY" required. [file "/usr/share/modsecurity-crs/optional_rules/modsecurity_crs_55_application_defects.conf"] [line "23"] [id "981220"] [msg "[Watcher Check] No charset was specified in the HTTP Content-Type header nor the HTML content meta tag."] [data "Content-Type Response Header: text/html"] [tag "WASCTC/WASC-15"] [tag "APP_DEFECT/MISCONFIGURATION"] [tag "http://code.google.com/p/browsersec/wiki/Part2#Content_handling_mechanisms"] [hostname "example.com"] [uri "/test.php"] [unique_id "VMTf31XWGY4AADqRE00AAAAB"]

[Sun Jan 25 13:21:51.777193 2015] [:error] [pid 14993] [client x.x.x.x] ModSecurity: Warning. Match of "rx (<meta.*?(content|value)=\\"text/html;\\\\s?charset=utf-8|<\\\\?xml.*?encoding=\\"utf-8\\")" against "RESPONSE_BODY" required. [file "/usr/share/modsecurity-crs/optional_rules/modsecurity_crs_55_application_defects.conf"] [line "36"] [id "981222"] [msg "[Watcher Check]  The charset specified was not utf-8 in the HTTP Content-Type header nor the HTML content meta tag."] [data "Content-Type Response Header: text/html"] [tag "WASCTC/WASC-15"] [tag "MISCONFIGURATION"] [tag "http://websecuritytool.codeplex.com/wikipage?title=Checks#charset-not-utf8"] [hostname "example.com"] [uri "/test.php"] [unique_id "VMTf31XWGY4AADqRE00AAAAB"]
  • 0
    Есть ли какое-либо правило, которое сообщит mod_security, что «my / secret / file.txt» является секретным файлом?
  • 0
    Я так не думаю, потому что у меня есть только правила по умолчанию от установки. Как мне установить это правило?
Показать ещё 2 комментария
Теги:
apache2
mod-security2

1 ответ

0

Правила в modsecurity_crs_43_csrf_protection.conf ищут атаку CSRF, однако тот, который вы пытаетесь выполнить, не является CSRF.

Вы можете попробовать это,

  1. Удалите Include /usr/share/modsecurity-crs/base_rules/*.conf и Include/usr/share/modsecurity-crs/optional_rules/*.conf из вашего /etc/apache2/mods-enabled/security2.conf (я думаю, вы используют Ubuntu).
  2. Создайте набор правил в /etc/modsecurity/modsecurity_crs_15_customrules.conf
  3. Включите это правило в этот файл SecRule REQUEST_URI "secret" "phase:1,t:none,log,deny,id:'9000070001',msg:'Malicious content blocked'"
  4. Запустить sudo service apache2 restart

Попробуйте использовать тот же URL-адрес из своего браузера, посмотрите /var/log/apache2/modsec_audit.log и сообщите мне, как это происходит.

Благодаря,

Даниил

Ещё вопросы

Сообщество Overcoder
Наверх
Меню