Skip to content

Fix RFC 7239 Forwarded header relay for entries without for#4218

Open
softho0n wants to merge 1 commit into
spring-cloud:mainfrom
softho0n:gh-4214-forwarded-header-optional-for
Open

Fix RFC 7239 Forwarded header relay for entries without for#4218
softho0n wants to merge 1 commit into
spring-cloud:mainfrom
softho0n:gh-4214-forwarded-header-optional-for

Conversation

@softho0n

@softho0n softho0n commented Jun 22, 2026

Copy link
Copy Markdown

Per RFC 7239, all forwarded-pair entries are optional. Both
ForwardedHeadersFilter (webflux) and ForwardedRequestHeadersFilter (webmvc)
currently drop entries where for is absent, even when sent by trusted proxies
(remote address is already validated earlier in the same method).

This causes legitimate upstream host/proto information to be silently lost
in multi-hop proxy chains. The webmvc filter also throws NPE on null for.

Changes:

  • webflux: preserve when for == null OR trustedProxies.isTrusted(forValue)
  • webmvc: same fix + adds null-safety to prevent NPE in TrustedProxies.isTrusted
  • Tests covering header-without-for-field preservation

Fixes gh-4214

Preserve existing Forwarded header entries that do not contain a `for` parameter in both WebFlux and MVC filters.

Fixes spring-cloudgh-4214

Signed-off-by: seunghun shin <18shshin@gmail.com>
@softho0n softho0n force-pushed the gh-4214-forwarded-header-optional-for branch from e07c57a to 8f53a6c Compare June 22, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ForwardedHeadersFilter drops upstream Forwarded headers without a for field

2 participants