|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-01-07 10:16 UTC] jifan dot jf at alibaba-inc dot com
Description: ------------ --- From manual page: https://php.net/datetime.formats.time --- Test script: --------------- <?php $a = "http://php.net\@aliyun.com/aaa.do"; $b = parse_url($a); var_dump($b); ?> use "str_replace("\","/",$b);" to fix it Expected result: ---------------- for security, we will filter the host before using redirect($url) . we'll test if the host of the url to redirect is in our whitelist(e.g. aliyun.com). how ever, a attacker will use "http://php.net\@aliyun.com/" to bypass the filter. ------- parse_url("http://php.net\@aliyun.com/aaa.do"); ["host"]=> string(10) "aliyun.com" ------- parse_url("http://php.net/@aliyun.com/aaa.do"); ["host"]=> string(7) "php.net" ---------------- then we'll export the url to the webpage as "<a href="http://php.net\@aliyun.com/">" aaa</a> then click the button, browser will open the "php.net". PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
Hello, Have we considered a case where the input has only "@" within the URL instead of "\@". A sample use case is below on latest version of PHP, where the hostname being returned is still incorrect (malicious). $ php -v PHP 7.4.14 (cli) (built: Jan 5 2021 10:45:06) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies $ $ rpm -qa | grep -i php-7 php-7.4.14-1.fc33.x86_64 $ $ cat test.php <?php #$a = "http://php.net\@aliyun.com/aaa.do"; $a = "http://php.net@aliyun.com/aaa.do"; var_dump($a); $b = parse_url($a); var_dump($b); ?> $ $ php -f test.php string(32) "http://php.net@aliyun.com/aaa.do" array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(10) "aliyun.com" <<<<<<<< ["user"]=> string(7) "php.net" ["path"]=> string(7) "/aaa.do" } $