Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XForwardedHeadersFilter does not add X-Forwarded-For when remote address is an IPv6 #3644

Open
ZIRAKrezovic opened this issue Dec 16, 2024 · 4 comments

Comments

@ZIRAKrezovic
Copy link

This is a continuation of the Forwarded headers bug, but this time for XForwardedFilter

After adding property spring.cloud.gateway.forwarded.enabled=false to https://github.com/ZIRAKrezovic/gateway-reproducer, XForwardedFilter check for remote address fails when IPv6 is parsed as remote address

{4B52290E-5E1C-4D5D-9951-4B0FE5B482A7}

{7FDCCF7E-7017-4A74-9183-804966D9BA3F}

Last conditional will fail, and X-Forwarded-For will not be added to the request.

@bclozel
Copy link
Contributor

bclozel commented Jan 13, 2025

If this is a continuation of #3643, the premise in #3643 seems wrong so maybe this should be closed as well?

@ZIRAKrezovic
Copy link
Author

There is a valid IPv6 in request.getRemoteAddress(), so the problem still persists. I have updated the test to use "[]" - issue is still the same.

@ZIRAKrezovic
Copy link
Author

ZIRAKrezovic commented Jan 13, 2025

Note the following in ForwardedHeadersFilter

{1BDF2EC4-C49C-4A7A-86AD-3344E19D3790}

This seems to be missing in XForwardedHeadersFilter.

{D4BFCD54-61D7-402F-8F60-BA6277A69E2E}

Here's the culprit

https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/web/util/ForwardedHeaderUtils.java#L184

@ZIRAKrezovic
Copy link
Author

Created spring-projects/spring-framework#34253 as well.

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

No branches or pull requests

2 participants