Skip to content

http: sanitize x-envoy-upstream-stream-duration-ms from external requests - #48067

Merged
ggreenway merged 2 commits into
envoyproxy:mainfrom
lboynton:sanitize-upstream-stream-duration-header
Oct 7, 2026
Merged

ggreenway merged 2 commits into
envoyproxy:mainfrom
lboynton:sanitize-upstream-stream-duration-header

Conversation

@lboynton

@lboynton lboynton commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Commit Message: http: sanitize x-envoy-upstream-stream-duration-ms from external requests
Additional Description:

The router honours the x-envoy-upstream-stream-duration-ms request header from any client. ConnectionManagerUtility::cleanInternalHeaders() removes the other router timeout and retry control headers (x-envoy-upstream-rq-timeout-ms, x-envoy-max-retries, x-envoy-retry-on, ...) from external requests, but this one was missed when it was added in #15433. As a result, any external client can set a per-request upstream stream duration and make Envoy abort the upstream request with a local reply.

This PR removes the header from external requests alongside the others. The change is guarded by envoy.reloadable_features.sanitize_upstream_stream_duration_header (default true) for deployments that send the header from clients Envoy classifies as external.

It also adds the header to the header sanitizing docs, documents that it is only honoured for internal clients, and corrects the documented response code: the local reply is a 504, or a 408 if the downstream request has not been fully received (Http::Utility::maybeRequestTimeoutCode()), not always a 408.

This was reported to envoy-security first; they classified it as a bug rather than a vulnerability and asked for a public issue.

Fixes #48066

Risk Level: low. Removes one more header from external requests, runtime guarded.
Testing: unit.
Docs Changes: added.
Release Notes: added.
Platform Specific Features: n/a.
Runtime guard: envoy.reloadable_features.sanitize_upstream_stream_duration_header

🤖 Generated with Claude Code

…ests

The router honoured x-envoy-upstream-stream-duration-ms from any client,
because cleanInternalHeaders() did not remove it from external requests
like the other router timeout and retry control headers. Remove it there,
guarded by envoy.reloadable_features.sanitize_upstream_stream_duration_header.

Also list the header in the header sanitizing docs, document that it is only
honoured for internal clients, and correct the documented response code.

Fixes envoyproxy#48066

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lee Boynton <[email protected]>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #48067 was opened by lboynton.

see: more, trace.

x-envoy-upstream-stream-duration-ms is now removed from external requests,
so set x-forwarded-for to an internal address as the other timeout header
integration tests do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lee Boynton <[email protected]>
@lboynton

lboynton commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@lboynton
lboynton marked this pull request as ready for review October 6, 2026 16:33
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #48067 was ready_for_review by lboynton.

see: more, trace.

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing this @lboynton

@ggreenway
ggreenway merged commit b820508 into envoyproxy:main Oct 7, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x-envoy-upstream-stream-duration-ms is honoured from external clients (missing from header sanitisation)

2 participants