-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Problem: Envoy currently accepts Content-Length headers containing leading zeros (e.g., Content-Length: 010) and forwards the raw string value to upstream clusters without normalization.
Context & Impact: While Envoy correctly parses 010 as decimal 10, various downstream backends (specifically those using legacy C strtol with base 0, or older Python parsers) may interpret leading zeros as Octal indicators.
Envoy: 010 -> 10 bytes.
Backend: 010 -> 8 bytes.
This ambiguity creates a potential desync/smuggling vector (CL.CL) when Envoy is placed in front of such vulnerable backends.
RFC Reference: RFC 9110 (and historically RFC 7230 Section 3.3.2) states that a sender MUST NOT send a Content-Length header field value that contains a leading zero unless the value is 0. As Envoy acts as the sender to the upstream, forwarding the raw value preserves this ambiguity.
Proposed Solution: Envoy should normalize the Content-Length header by stripping leading zeros (converting 010 to 10) before forwarding it to the upstream. This ensures that the upstream receives a canonical decimal integer, eliminating the risk of octal misinterpretation.
Reproduction: I have a reproduction script (vulnerable_backend.py) that demonstrates this desync against a Gunicorn-style backend if needed for verification.