Don't drop Forwarded entries that have no "for" value - #4287
Open
tkatta-stack wants to merge 1 commit into
Open
tkatta-stack wants to merge 1 commit into
tkatta-stack wants to merge 1 commit into
Conversation
ForwardedHeadersFilter unconditionally dropped any incoming Forwarded header entry that lacked a "for" parameter, even when the immediate remote address had already been validated against trusted-proxies. RFC 7239 section 4 makes every Forwarded pair parameter, including "for", optional, so an upstream proxy that only sets e.g. host and proto is fully valid and should not have its entry silently discarded. Change the per-entry check so it only rejects an entry when it *has* a for value that fails the trustedProxies check; entries with no for value are kept as-is; behavior for entries that do carry a for value is unchanged (verified against the existing test suite, including untrustedForwardedForNotAppended and remoteAdddressIsNullUnTrustedProxyNotAppended, both of which continue to pass unchanged). Add forwardedEntryWithoutForValueIsKeptWhenRemoteAddressTrusted covering the previously-dropped case. Fixes spring-cloudgh-4214 Signed-off-by: Teja Katta <tejakatta12@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ForwardedHeadersFilterunconditionally dropped any incomingForwardedheader entry that lacked aforparameter, even when the immediate remote address had already been validated againsttrusted-proxies. RFC 7239 section 4 makes everyForwardedpair parameter, includingfor, optional, so an upstream proxy that only sets e.g.hostandprotois fully valid and its entry shouldn't be silently discarded.Fix
Changed the per-entry check so it only rejects an entry when it has a
forvalue that fails thetrustedProxiescheck. Entries with noforvalue are now kept as-is. Behavior for entries that do carry aforvalue is unchanged.Tests
Verified against the existing test suite by hand (couldn't run the full Gradle suite in the environment I prepared this in) — in particular
untrustedForwardedForNotAppendedandremoteAdddressIsNullUnTrustedProxyNotAppended, which exercise the trust check for entries that do have aforvalue, continue to pass unchanged since this change only affects theforValue == nullbranch.Added
forwardedEntryWithoutForValueIsKeptWhenRemoteAddressTrustedcovering the previously-dropped case.Fixes #4214