jueves, 25 de agosto de 2011

Solución provisoria a "Apache httpd Remote Denial of Service"

Bueno, después de investigar un ratito llegamos a una solución provisoria a esto mientras sacan el parche.

El problema es este!

http://mail-archives.apache.org/mod_mbox/httpd-announce/201108.mbox/%3C20110824161640.122D387DD@minotaur.apache.org%3E

El exploit es este:

http://www.exploit-db.com/exploits/17696/

Y la solución que econtramos es la siguiente:

Primero poner las recomendaciones del sitio de Apache ayudaron un poco, pero igual seguía pasando. Agreamos esto en el httpd.conf

SetEnvIf Range (,.*?){5,} bad-range=1
RequestHeader unset Range env=bad-range

Encontramos esto:

http://blog.spiderlabs.com/2011/08/mitigation-of-apache-range-header-dos-attack.html

Instalar si no lo tienen Mod_security para apache. Nosotros lo teníamos así que agregamos en modsec.user.conf lo siguiente:

SecRule REQUEST_HEADERS:Range "(\d+)\-(\d+)\," "chain,capture,phase:2,rev:'2.2.2',t:none,block,msg:'Range: Invalid Last Byte Value.',logdata:'%{matched_var}'severity:'5',id:'958230',tag:'RULE_MATURITY/5',tag:'RULE_ACCURACY/7',tag:'https://www.owasp.org/index.php/ModSecurity_CRS_RuleID-%{tx.id}',tag:'PROTOCOL_VIOLATION/INVALID_HREQ',tag:'http://www.bad-behavior.ioerror.us/documentation/how-it-works/',setvar:'tx.msg=%{rule.msg}',setvar:tx.id=%{rule.id},setvar:tx.anomaly_score=+%{tx.notice_anomaly_score},setvar:tx.protocol_violation_score=+%{tx.notice_anomaly_score},setvar:tx.%{rule.id}-PROTOCOL_VIOLATION/INVALID_HREQ-%{matched_var_name}=%{matched_var}"
SecRule TX:2 "!@gt %{tx.1}"


Después en la configuración general de Apache lo siguiente:

RewriteEngine On
RewriteCond %{HTTP:range} ^.+$ [NC]
RewriteRule .* - [F]
RewriteCond %{HTTP:request-range} ^.+$ [NC]
RewriteRule .* - [F]

Por ahora funciona ok!

Espero que les ayudeeee!