Skip to content

ext_proc listener: body mutation that changes the length gets a 500 #820

Description

@JoshSag

A WritesBody plugin under the envoy-sidecar (ext_proc) listener can only replace a body with
one of exactly the same length. Any other length: Envoy answers 500 and the upstream is never
reached. Same on the response path. Reported by @lernerjenny, whose body-mutating plugin
hit the 500 as soon as the payload length changed.

Envoy's ext_proc API puts content-length on the processor in the mode this listener runs
(BUFFERED body, SEND headers) —
processing_mode.proto, BodySendMode:

In BUFFERED mode with SEND header mode, content length header is allowed but it is external
processor's responsibility to set the content length correctly matched to the length of mutated body.

withBodyMutation (authlib/listener/extproc/server.go) sends the BodyMutation without it;
the response-body reply sends no HeaderMutation at all.

Reproduction

Plain podman, no cluster: static Envoy 1.37.1 (the version in the authbridge-envoy image) with the
ext_proc filter configured as the rossoctl chart does (headers SEND, bodies NONE,
allow_mode_override: true, failure_mode_allow: false) → an echo upstream that reports the
content-length and byte count it received; the ext_proc server is the stock
listener/extproc.Server with one WritesBody plugin that wraps every request and response body
in {"wrapped": …} — so the length always changes.

POST /mcp  '{"orig":"payload"}'       → HTTP/1.1 500 Internal Server Error
GET  /mcp  (upstream reply wrapped)   → HTTP/1.1 500 Internal Server Error
envoy (ext_proc:debug): Sending immediate response: mismatch between content length and the length of the mutated body

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions