Repository navigation
Description
There are two bugs in processing of deferred requests, that can cause the request to proxied incomplete. I.e request with body is proxied without the body or with partial body. Or request with trailers is proxies without trailers. This bug also requires a decoder filter that pauses and resumes filter chain iteration.
Preconditions:
- Envoy receives multiple complete requests with body and/or trailers in one I/O read operation.
- Some of these requests are deferred due to limit on the number of requests processed in one I/O iteration.
- A decoder filter which pauses and then continues filter chain iteration (i.e. ext_proc).
For example:
- gRPC client sends multiple small requests, which Envoy reads in one I/O operation.
- The limit on requests per I/O operation is 1 (or lower than the number sent by the client).
- ext_proc filter present in the filter chain.
- The deferred gRPC requests will be proxied without bodies.
Specifically:
- Filter manager (FM) uses presence of the timestamp of receipt of the downstream end_stream (set when HCM receives end_stream from the client) to set the end_stream during filter chain resumption. If a complete request (with end_stream= true) was deferred, its filter chain iteration would start with the downstream end_stream flag set (since the timestamp was set before the request was deferred). If there is a decoder filter in the chain that pauses and resumes filer chain iteration, all filters after that will see end_stream as true.
For example if a filter pauses in decodeHeaders() and then resumes in decodeData() all filters after that will have decodeHeaders called with end_stream == true. This can cause request to be proxied by the router without the body.
- The request trailers were also immediately available to the filter manager when processing of deferred request begins. If there is a filter that pauses and resumes iteration it makes filter manager incorrectly process trailers as though they were added by the filter that paused iteration. This causes trailers to be processed by filter chain twice triggering asserts.
The same problem is also present when HCM recreates the stream with body (i.e. for internal redirect).
All presently supported versions v1.28.0 to v1.31.0 are affected.
Activity
Separate state for tracking downstream end_stream in filter manager a…
KBaichoo commentedon Aug 23, 2024
/backport