Matched requests that contain invalid header values (eg with emoji) return a 502 to the client
#2375
Replies: 4 comments 11 replies
|
Other than looking for the string |
|
@Laura7089 Hello Laura!
First, could you please attach logs of a direct connection to the downstream endpoint? We need to examine the behavior of the downstream service first. Second, making requests using the curl tool is not recommended, since Ocelot is not designed to process such requests. Manipulating headers with curl may break the HTTP protocol with a high probability.
Why do you think so? In your case, the downstream service returned a 502 error due to invalid data of header body, and Ocelot correctly forwarded this response to the curl client without changing the status code. The Ocelot Server Error Responses documentation states:
However, if Ocelot overrides the status code in this scenario, I am open to further discussion.... |
Most other popular API gateways and reverse proxies (NGINX, Envoy, Kong, HAProxy, Traefik, and cloud services like AWS API Gateway) treat a request with invalid data in a header value (e.g., non-ASCII characters like emojis, control characters, or other violations of RFC 7230/RFC 3986) as a client error. They reject it early at the ingress layer with a This is the expected and secure behavior: the malformation is the client's fault, so it should never surface as a "server/downstream" error like Ocelot's Specific Behaviors by Gateway
Why This Differs from OcelotIn the linked discussion, Ocelot's .NET Bottom line: The industry-standard behavior is a 400-level rejection at the gateway edge. This avoids leaking internal exceptions, prevents misleading "server error" status codes, and aligns with HTTP spec expectations for malformed client input. If you're building or configuring a gateway, early validation (or optional sanitization) is the norm. |
Uh oh!
There was an error while loading. Please reload this page.
The expected behaviour of this should be to return a
4XXerror to the client.Reproducing
Reproduced against the
Basicsample on tag24.1.0with:Prints:
Logs
The logs shed some light:
All reactions