找回密码
 新建账号

Discuz! X5 严重安全漏洞:未校验 GET 参数 app

[复制链接]
大郎 发表于 2026-7-3 18:42 | 显示全部楼层 |阅读模式
Discuz! X5 index.php 中的如下代码会造成严重安全隐患
  1. if(!empty($_GET['app'])) {
  2.     define('MITFRAME_APP', $_app = $_GET['app']);
  3. } else {
  4.     $_app = 'index';
  5. }
复制代码
当使用 ?app[]=admin 这样的参数给 app 传递数组时,程序会崩溃。
如果服务器关闭了 PHP 的错误显示功能,服务器会返回 500 错误,并且没有任何提示性文本,会让访客困惑。
如果服务器没有关闭 PHP 的错误显示功能,服务器信息会泄露。Discuz! 官方论坛 也未能幸免。
  1. 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 参数是不是字符串,不是就重置它。
  1. if(!empty($_GET['app']) && is_string($_GET['app'])) {
  2.     $_app = $_GET['app'];
  3.     define('MITFRAME_APP', $_app);
  4. } else {
  5.     $_app = 'index';
  6. }
复制代码
另外说一句,Discuz! 的代码有时候写得非常不严谨,还喜欢用偷懒式写法,这不是好的习惯。

手机版|轻松e站

GMT+8, 2026-7-3 20:52

快速回复 返回顶部 返回列表