mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-26 04:52:36 +01:00
Merge remote-tracking branch 'phpbb-security/ticket/security-180-asc' into prep-release-3.1.4
* phpbb-security/ticket/security-180-asc: [ticket/security-180] Use language variable for redirect error in 3.1+ [ticket/security-180] Merge if statement with previous one in 3.1.x [ticket/security-180] Add tests for redirecting to main URL [ticket/security-180] Always fail when redirecting to an insecure URL [ticket/security-180] Make sure that redirect goes to full URL plus slash [ticket/security-180] Check if redirect URL contains board URL
This commit is contained in:
commit
c1702b8e19
@ -2309,7 +2309,7 @@ function redirect($url, $return = false, $disable_cd_check = false)
|
|||||||
// Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work)
|
// Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work)
|
||||||
if (!$disable_cd_check && $url_parts['host'] !== $user->host)
|
if (!$disable_cd_check && $url_parts['host'] !== $user->host)
|
||||||
{
|
{
|
||||||
$url = generate_board_url();
|
trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($url[0] == '/')
|
else if ($url[0] == '/')
|
||||||
@ -2347,7 +2347,7 @@ function redirect($url, $return = false, $disable_cd_check = false)
|
|||||||
// Clean URL and check if we go outside the forum directory
|
// Clean URL and check if we go outside the forum directory
|
||||||
$url = $phpbb_path_helper->clean_url($url);
|
$url = $phpbb_path_helper->clean_url($url);
|
||||||
|
|
||||||
if (!$disable_cd_check && strpos($url, generate_board_url(true)) === false)
|
if (!$disable_cd_check && strpos($url, generate_board_url(true) . '/') !== 0)
|
||||||
{
|
{
|
||||||
trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
|
trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
|||||||
{
|
{
|
||||||
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false))
|
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false))
|
||||||
return array(
|
return array(
|
||||||
array('data://x', false, false, 'http://localhost/phpBB'),
|
array('data://x', false, 'INSECURE_REDIRECT', false),
|
||||||
array('bad://localhost/phpBB/index.php', false, 'INSECURE_REDIRECT', false),
|
array('bad://localhost/phpBB/index.php', false, 'INSECURE_REDIRECT', false),
|
||||||
array('http://www.otherdomain.com/somescript.php', false, false, 'http://localhost/phpBB'),
|
array('http://www.otherdomain.com/somescript.php', false, 'INSECURE_REDIRECT', false),
|
||||||
array("http://localhost/phpBB/memberlist.php\n\rConnection: close", false, 'INSECURE_REDIRECT', false),
|
array("http://localhost/phpBB/memberlist.php\n\rConnection: close", false, 'INSECURE_REDIRECT', false),
|
||||||
array('javascript:test', false, false, 'http://localhost/phpBB/javascript:test'),
|
array('javascript:test', false, false, 'http://localhost/phpBB/javascript:test'),
|
||||||
array('http://localhost/phpBB/index.php;url=', false, 'INSECURE_REDIRECT', false),
|
array('http://localhost/phpBB/index.php;url=', false, 'INSECURE_REDIRECT', false),
|
||||||
@ -51,6 +51,11 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
|||||||
array('../index.php', false, false, 'http://localhost/index.php'),
|
array('../index.php', false, false, 'http://localhost/index.php'),
|
||||||
array('../index.php', true, false, 'http://localhost/index.php'),
|
array('../index.php', true, false, 'http://localhost/index.php'),
|
||||||
array('./index.php', false, false, 'http://localhost/phpBB/index.php'),
|
array('./index.php', false, false, 'http://localhost/phpBB/index.php'),
|
||||||
|
array('https://foobar.com\@http://localhost/phpBB', false, 'INSECURE_REDIRECT', false),
|
||||||
|
array('https://foobar.com\@localhost/troll/http://localhost/', false, 'INSECURE_REDIRECT', false),
|
||||||
|
array('http://localhost.foobar.com\@localhost/troll/http://localhost/', false, 'INSECURE_REDIRECT', false),
|
||||||
|
array('http://localhost/phpBB', false, false, 'http://localhost/phpBB'),
|
||||||
|
array('http://localhost/phpBB/', false, false, 'http://localhost/phpBB/'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +110,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
|||||||
|
|
||||||
if ($expected_error !== false)
|
if ($expected_error !== false)
|
||||||
{
|
{
|
||||||
$this->setExpectedTriggerError(E_USER_ERROR, $expected_error);
|
$this->setExpectedTriggerError(E_USER_ERROR, $user->lang[$expected_error]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = redirect($test, true, $disable_cd_check);
|
$result = redirect($test, true, $disable_cd_check);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user