Nginx 1.18 Proxy: Backend Response Alignment Issues with Apache 2.4 (Leaking Adjacent Response Headers)

Overview of the Issue

When deploying Nginx 1.18 as a reverse proxy in front of an Apache 2.4 backend server, administrators occasionally encounter a severe HTTP response splitting and header leakage vulnerability. This occurs due to subtle misinterpretations of the HTTP/1.1 specification regarding chunked transfer encoding, parsing of custom headers containing underscores, or malformed boundary terminators sent by Apache modules (such as mod_proxy or mod_fcgid).

When Nginx fails to correctly align the boundaries of incoming backend responses, adjacent response headers from previous keep-alive request-response cycles can bleed into subsequent client payloads. This results in:

  • Header Leakage: Clients receiving sensitive internal headers (X-Backend-Server, internal cookies, or authorization tokens) meant for other sessions.
  • Cache Poisoning: Public caches storing responses contaminated with user-specific session headers.
  • Malformed HTTP Parsing: Intermittent 502 Bad Gateway or 400 Bad Request errors triggered by upstream stream desynchronization.

Read more here: Source link