-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support Forwarded
in Host
extractor
#1078
Conversation
It would be great if Axum also provides an |
@Tsing please file a separate issue about that. |
cc @neoeinstein what do you think about this? |
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea whether this makes sense conceptually, but code looks good 😄
Did some initial review. The current implementation is insecure by default and overly-trusting of the I'd recommend that the default, no-configuration implementation should only trust the If configured to trust proxy headers, then parsing A proper configuration for proxy forwarded information should account for:
Using the above, the "trusted" information should take the Peer IP: 127.0.0.1 With a default trust profile of private IPs and 0 trust, we evaluate as follows:
With just |
Can't all headers be spoofed including I imagine its up to users to not blindly trust the data that comes through headers. The docs currently say
|
The primary question is where you place the trust boundary. With only a direct connection and no headers indicating the request was forwarded, we trust that the first hop is the "real" client and they provided the header. Things get tricky as you insert proxies in the middle, and especially with a CDN that might need to replace the original host header to avoid self-reference. A malicious client can spoof arbitrary information, but proxies will always tack their information onto the end for |
Perhaps I'm being naive but I don't think adding a bunch of configuration to this is necessary. If users wanna look at things in a different order or exclude addresses they don't trust then they can still do that by writing their own extractor. I have compared with actix-web and they do basically the same thing that we do. See https://github.com/actix/actix-web/blob/master/actix-web/src/info.rs#L75 |
I think that's a reasonable take. I tend to lean toward preferring secure defaults, especially if others are going to be relying on the value for potentially critical functionality, hence my recommendation on the default pattern. It can be done such that no configuration is required (in which case it would apply the conservative defaults), but that customization could be provided just by adding an extension layer. With this way of doing things, the security admonition is important, as people will rely on this for security-related purposes whether the documentation says to or not. With a conservative default, 99% of user use cases will be correct and safe out of the box without needing configuration. Whichever approach |
Thanks for you input 😊 Perhaps a more conservative |
Based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded