Bug tracker

This ticket has been moved to our new tracker. Open Ticket PHPBB3-9034 now.

Redirect() fails with directory traversal (fix in progress)

This bug is not realized in a vanilla phpBB install, but ...

Scenario:
MOD has a database installer located at /install_awsm_mod/index.php. That file contains a call to login_box() in the event that the user is not logged in.
So build_url() will create S_LOGIN_ACTION as ../ucp.php?redirect=urlencode(../install_awsm/mod/index.php)

So ucp.php passes this into meta_refresh(), which in turn calls redirect(). Redirect eventually calls
Code: Select all
         $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));

Which returns FALSE. Why? $pathinfo['dirname'] does not exist. Why?
Code: Select all
print($pathinfo['dirname']); // displays ../install/install_awsm_mod/index.php

So of course, being at /ucp.php, "../" takes us out of the phpBB root, and into no-man's land.

The resulting redirect is
Code: Select all
http://localhost/phpBB3/../../../../../index.php?&sid=258a07f66530b7fcedfe6c9c10bbcfd2

(the exact number of ../ depends on how many directories from / the phpBB root is.)
Browsers interpret this as "redirect to domain root", so http://localhost/ loads in error (in my case).

Ideally, the redirect would work as planned, but at least a somewhat better case would be to return to the phpBB Index page.

Comments / History

Posted by A_Jelly_Doughnut (MOD Team Member) on Jan 22nd 2010, 17:10

Proposed patch:
bug-56965.diff (643 Bytes)

Linked ticket with changeset: r10536

Action performed by A_Jelly_Doughnut (MOD Team Member) on Feb 25th 2010, 00:18

Assigned ticket to user "A_Jelly_Doughnut"

Action performed by A_Jelly_Doughnut (MOD Team Member) on Feb 25th 2010, 00:18

Changed ticket status from "New" to "Fix completed in SVN"

Action performed by A_Jelly_Doughnut (MOD Team Member) on Feb 25th 2010, 00:18

Changed ticket status from "Fix completed in SVN" to "Fix in progress"

Action performed by bantu (3.0 Release Manager) on Mar 4th 2010, 17:34

Posted by bantu (3.0 Release Manager) on Mar 4th 2010, 17:39

r10536 is currupted, you cannot use "break;" there, since there is no loop. "return;", maybe? ;-)

Posted by A_Jelly_Doughnut (MOD Team Member) on Mar 9th 2010, 16:00

Another test case from nickvergessen: http://www.phpbb.com/bugs/phpbb3/58345

Edited post #219765

Action performed by nickvergessen (Development Team Member) on Mar 9th 2010, 16:12

Ticket details

Related SVN changesets