Discuz! X5 index.php 中的如下代码会造成严重安全隐患- if(!empty($_GET['app'])) {
- define('MITFRAME_APP', $_app = $_GET['app']);
- } else {
- $_app = 'index';
- }
复制代码 当使用 ?app[]=admin 这样的参数给 app 传递数组时,程序会崩溃。
如果服务器关闭了 PHP 的错误显示功能,服务器会返回 500 错误,并且没有任何提示性文本,会让访客困惑。
如果服务器没有关闭 PHP 的错误显示功能,服务器信息会泄露。Discuz! 官方论坛 也未能幸免。- Fatal error: Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given in /www/wwwroot/www.dismall.com/index.php:26 Stack trace: #0 /www/wwwroot/www.dismall.com/index.php(26): preg_match() #1 {main} thrown in /www/wwwroot/www.dismall.com/index.php on line 26
复制代码 解决方法很简单:先判断 app 参数是不是字符串,不是就重置它。- if(!empty($_GET['app']) && is_string($_GET['app'])) {
- $_app = $_GET['app'];
- define('MITFRAME_APP', $_app);
- } else {
- $_app = 'index';
- }
复制代码 另外说一句,Discuz! 的代码有时候写得非常不严谨,还喜欢用偷懒式写法,这不是好的习惯。 |