URL 安全漏洞修复 '../'
URL security hole fixing '../'
我在 PHP 中遇到 URL 路由问题。
在我的本地主机中,我有两个项目目录:
- project_one:
- index.php
- other_directorys
- hacking_script:
- index.php
- database_dump.php
当我必须访问我的 project_one 时,我会选择 localhost/project_one
这项工作正确。但是当我在这个 localhost/project_one/../../hacking_script
中输入时,它打开了 localhost/hacking_script/index.php
文件。
所以如何预防,我没有任何想法。我可以使用 .htaccess 来防止它吗?如果是那么怎么办?
这就是 URL 在浏览器中的工作方式。如果你有这个问题的网站:
如果你尝试:
http://whosebug.com/users/../questions/36980771
这将重定向到同一页面。这是设计状态。
如果你在谈论路由,那么你就是在谈论这个:
Request -> Router -> GetController -> ExecuteAction
这意味着 GetController
最有可能 include
或 require
一些文件...有一部分,您需要确保,它只需要允许的文件。例如使用 whitelist (这是推荐的方式)。或者确保不允许使用 ../
等特殊字符。
我在 PHP 中遇到 URL 路由问题。
在我的本地主机中,我有两个项目目录:
- project_one:
- index.php
- other_directorys
- project_one:
- hacking_script:
- index.php
- database_dump.php
- hacking_script:
当我必须访问我的 project_one 时,我会选择 localhost/project_one
这项工作正确。但是当我在这个 localhost/project_one/../../hacking_script
中输入时,它打开了 localhost/hacking_script/index.php
文件。
所以如何预防,我没有任何想法。我可以使用 .htaccess 来防止它吗?如果是那么怎么办?
这就是 URL 在浏览器中的工作方式。如果你有这个问题的网站:
如果你尝试:
http://whosebug.com/users/../questions/36980771
这将重定向到同一页面。这是设计状态。
如果你在谈论路由,那么你就是在谈论这个:
Request -> Router -> GetController -> ExecuteAction
这意味着 GetController
最有可能 include
或 require
一些文件...有一部分,您需要确保,它只需要允许的文件。例如使用 whitelist (这是推荐的方式)。或者确保不允许使用 ../
等特殊字符。