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

X-Forwarded-For behaviour is not configurable. #68

Open
nakedible-p opened this issue Jun 1, 2023 · 2 comments
Open

X-Forwarded-For behaviour is not configurable. #68

nakedible-p opened this issue Jun 1, 2023 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@nakedible-p
Copy link

Right now the this layer automatically parses X-Forwarded-For and takes the leftmost value in there... or takes the TCP connection address if no header is present. This means that anyone can spoof client IP addresses by adding a X-Forwarded-For header.

It should be possible to disable looking at X-Forwarded-For, or to take the rightmost value from X-Forwarded-For instead (the one added by the latest load balancer...). For discussion on these things... see: https://crates.io/crates/axum-client-ip

@davidB
Copy link
Owner

davidB commented Jun 4, 2023

Thanks for the information and the link. PR is welcome (I'll not have too much time to work on this crate before some days)

@davidB davidB added bug Something isn't working good first issue Good for newcomers labels Jun 4, 2023
@davidB
Copy link
Owner

davidB commented Jul 2, 2023

Comment (to myself for memory):

From https://github.com/open-telemetry/semantic-conventions/blob/main/semantic_conventions/trace/http.yaml

The IP address of the original client behind all proxies, if
known (e.g. from Forwarded,
X-Forwarded-For, or a similar header).
Otherwise, the immediate client peer address.

From X-Forwarded-For - HTTP | MDN

If a request goes through multiple proxies, the IP addresses of each successive proxy is listed. This means that, given well-behaved client and proxies, the rightmost IP address is the IP address of the most recent proxy and the leftmost IP address is the IP address of the originating client.

So taking the leftmost is what we want "The IP address of the original client".

Notes: this attribute was removed with release 0.12 (but it come back with future release, if I don't forgot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants