[UNIX] phpBB Security Hole Leads to Root Compromise

From: support@securiteam.com
Date: 08/06/01


From: support@securiteam.com
To: list@securiteam.com
Subject: [UNIX] phpBB Security Hole Leads to Root Compromise
Message-Id: <20010806202025.63F5E13903@mail.der-keiler.de>
Date: Mon,  6 Aug 2001 22:20:25 +0200 (CEST)

The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com

  phpBB Security Hole Leads to Root Compromise
------------------------------------------------------------------------

SUMMARY

 <http://www.phpbb.com/> phpBB, is an open source bulletin board created
by the phpBB group. phpBB does not properly sanitize input, and this
creates a potential problem that can lead to arbitrary SQL queries getting
executed, which essentially allows administrative access to the bulletin
board.

DETAILS

Vulnerable systems:
phpBB version 1.4.0
phpBB version 1.4.1

The problem lies in the fact that phpBB includes an algorithm in the
auth.php file that removes backslashes that PHP automatically adds to the
Get / Post /Cookie variables.

<Example code from auth.php>

if(get_magic_quotes_gpc() == 1)
{
 switch($REQUEST_METHOD){
   case "POST":
      while (list ($key, $val) = each ($HTTP_POST_VARS)){
         if( is_array($val) ){
            array_walk($val, 'stripslashes_array', '');
            $$key = $val;}
      else{
         $$key = stripslashes($val);}
      }
   break;

</ End example code>

Therefore, certain PHP variables submitted through a URL can reach an SQL
query with un-escaped quotes, which is not good for security reasons. In
the prefs.php file such a situation exists where a user can execute an
arbitrary query by supplying a certain value for the $viewemail variable.

< Example sql query in prefs.php >
$sql = "UPDATE users SET
user_viewemail='$viewemail',
user_theme='$themes', user_attachsig = '$sig',
user_desmile = '$smile', user_html = '$dishtml',
user_bbcode
 = '$disbbcode', user_lang = '$lang' WHERE
(user_id = '$userdata[user_id]')";
</ End example code >

Example URL gives a username "l337h4x0r" level 4 (administrative)
privileges the board:

<Example URL>

http://sitename/phpBBfolder/prefs.php?save=1
&viewemail=1',user_level%3D'4'%20where%
20username%3D'l337h4x0r'%23

</ End example URL>

Re-creation:

1. Register an account on a phpBB board version 1.4.X.
2. Enter above URL with the correct site name and replace l337h4x0r with
your username.
3. Click on "Administration Panel" near the bottom of the page.

Solution:
An (unofficial) updated prefs.php version can be downloaded from:
 <http://www.game-mods.com/prefs.php.txt>
http://www.game-mods.com/prefs.php.txt

ADDITIONAL INFORMATION

The information has been provided by <mailto:kill-9@modernhackers.com>
kill-9.

========================================

This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

====================
====================

DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.



Relevant Pages

  • [UNIX] PHPBB BBcode Process Vulnerability (DoS)
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... WSS has found a vulnerability in <http://www.phpbb.com/> phpBB, ... Will cause the following data to be saved to the database: ... whitecell$ mysql -uuser -ppasswd ...
    (Securiteam)
  • [Fwd: phpBB 2.0.17 released]
    ... Subject: phpBB 2.0.17 released ... phpBB Group announces the release of phpBB 2.0.17, the "no, we did not ... security since we do not introduce new features into the 2.0.x codebase. ... reporting 2.0.x bugs within the next days. ...
    (Bugtraq)
  • RE: phpBB 2.0.17 remote avatar size bug
    ... I think some people just try to hard to find problems with PHPBB. ... phpBB 2.0.17 remote avatar size bug ... Classifying a report as invalid can have various reasons, ... This isn't a security problem. ...
    (Bugtraq)
  • CastleCops phpBB bbcode Input Validation Disclosure
    ... privmsg.php for phpBB 2.0.14 (possible all ... The CastleCops suggested patch was integrated into bbcode.php. ... Modsecurity adds a nice layer of security in filtering requests to a ...
    (Bugtraq)
  • Re: phpBB 2.06 search.php SQL injection
    ... Greetings BugTraq, ... However, due to the fact that it uses an array function to pull all the relative information and the hash returns a single value without the seperators, it won't acknowledge that a result was returned. ... From what I've tried so far, this doesn't really seem to be a critical vulnerability -- just an SQL injection that would allow you to get maybe the prefix of the forum tables or other insignifcant information. ... >A vulnerability exists in phpBB 2.06 that could allow an attacker to manipulate SQL ...
    (Bugtraq)