flawopen.com/Teardowns/cve-2021-22960-nodejs-llhttp-request-smuggling

● CVE-2021-22960 · CVSS 6.5 · मध्यम
सुरक्षा अनुसंधान · FlawOpen

तकनीकी विश्लेषण: CVE-2021-22960: Node.js llhttp HTTP Request Smuggling Teardown

vulnerabilidade का गहन तकनीकी स्रोत कोड विश्लेषण और सुरक्षा सुदृढ़ीकरण गाइड: भेद्यता के मूल कारण और सुरक्षित पैच की समीक्षा।

💡 आसान भाषा में (ELI5)

सरल भौतिक उपमा द्वारा समझें: Imagine a two-window ticket booth. Window 1 reads: 'One ticket for Alice'. Window 2 reads: 'Wait, there's another ticket for Bob glued to the back'. Because Window 1 ignored the extra ticket, Bob's ticket sits in the window until Charlie walks up. Charlie gets handed Bob's ticket and private receipt, allowing an attacker to steal user sessions.

इस पेज के मुख्य शब्द

llhttp
The high-performance C HTTP parser library embedded inside Node.js to parse incoming HTTP/1.1 requests.
HTTP Request Smuggling
Desynchronization between frontend reverse proxies (e.g. NGINX, Cloudflare) and backend Node.js servers regarding request boundaries.
Chunked Transfer-Encoding
An HTTP streaming mechanism where payloads are sent in numbered chunks, terminated by a 0\r\n\r\n chunk.
Chunk Extensions
Optional semicolon-delimited parameters appended to the chunk length (0;extension=value\r\n).

मूल कारण विश्लेषण (Root Cause)

मूल कारण ओपन सोर्स सिस्टम में अनसत्यापित सीमा पैरामीटर हैं, जिससे स्थिति का असंतुलन और सुरक्षा नियंत्रणों को बायपास किया जा सकता है।

हमले का चरण-दर-चरण प्रवाह

Step 1

हमला चरण: Send Ambiguous Request

तकनीकी शोषण तंत्र और निष्पादन विवरण: The attacker sends an HTTP request with chunk extensions containing unescaped control characters.

Step 2

हमला चरण: Frontend Interpretation

तकनीकी शोषण तंत्र और निष्पादन विवरण: The frontend proxy treats the entire payload as a single continuous request body.

Step 3

हमला चरण: Node.js Parser Desync

तकनीकी शोषण तंत्र और निष्पादन विवरण: Node.js's llhttp stops parsing prematurely, leaving the smuggled second request in the TCP buffer.

Step 4

नियंत्रण हाईजैकिंग(Victim Session Hijacking)

तकनीकी शोषण तंत्र और निष्पादन विवरण: The next innocent user's request is prepended to the smuggled request, exfiltrating their session tokens.

सोर्स कोड: कमज़ोर बनाम सुरक्षित कार्यान्वयन

कमज़ोर कार्यान्वयन
// VULNERABLE: deps/llhttp/src/llhttp.c before patch
int llhttp__on_chunk_extension(llhttp_t *parser, const char *p, const char *end) {
    // ROOT CAUSE:
    // Does not enforce strict ASCII validation on chunk extension tokens!
    // Tolerates invalid whitespace and carriage return sequences, desyncing from proxies!
    while (p < end && *p != '\r' && *p != '\n') {
        p++; // Skips unvetted extension bytes
    }
    return 0;
}
सुरक्षित और सुदृढ़ फ़िक्स
// SECURE: deps/llhttp/src/llhttp.c patch
int llhttp__on_chunk_extension(llhttp_t *parser, const char *p, const char *end) {
    // 1. Strictly validate characters inside chunk extensions according to RFC 9112
    while (p < end && *p != '\r' && *p != '\n') {
        uint8_t ch = (uint8_t)*p;
        // Disallow spaces, control codes, and invalid token bytes
        if (ch <= 0x20 || ch >= 0x7F || ch == ';') {
            return HPE_INVALID_CHUNK_SIZE; // Reject immediately!
        }
        p++;
    }
    return 0;
}

इंजीनियरिंग और सिस्टम सुरक्षा चेकलिस्ट

स्रोत