Skip to content

Deferred requests with body or trailers can be proxied incomplete #35814

Closed

Description

@yanavlasov

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:

  1. Envoy receives multiple complete requests with body and/or trailers in one I/O read operation.
  2. Some of these requests are deferred due to limit on the number of requests processed in one I/O iteration.
  3. A decoder filter which pauses and then continues filter chain iteration (i.e. ext_proc).

For example:

  1. gRPC client sends multiple small requests, which Envoy reads in one I/O operation.
  2. The limit on requests per I/O operation is 1 (or lower than the number sent by the client).
  3. ext_proc filter present in the filter chain.
  4. The deferred gRPC requests will be proxied without bodies.

Specifically:

  1. 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.

  1. 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

  1. added
    triage
    and removed
    triage
    on Aug 22, 2024
  2. added a commit that references this issue on Aug 23, 2024
    09501db
  3. KBaichoo commented on Aug 23, 2024

    @KBaichoo
    Contributor

    /backport

  4. added
    backport/review
    on Aug 23, 2024
  5. removed
    backport/review
    on Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions