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

When remote_addr_header is used, but not passed, remote_addr defaults to localhost #2652

Closed
Roguelazer opened this issue Jun 30, 2021 · 3 comments
Labels
Milestone

Comments

@Roguelazer
Copy link
Contributor

Describe the bug
When the header option is passed to set_remote_address but the requisite header is not passed on a request, the request is attributed to localhost instead of to the actual peeraddr.

Puma config:

set_remote_address header: "X-Client-IP"

To Reproduce
Make an HTTP request from non-localhost without setting the X-Client-IP. Note that the Rack REMOTE_ADDR variable is set to 127.0.0.1 instead of your actual IP.

Expected behavior
When the header is not set, requests should have REMOTE_ADDR set to the actual remote addr. If it's not available, it is arguably more correct to use 0.0.0.0 rather than 127.0.0.1 but I'm less picky about that case.

Desktop (please complete the following information):

  • OS: Linux
  • Puma Version: 5.3.2
@nateberkopec nateberkopec added this to the 6.0.0 milestone Jul 2, 2021
@nateberkopec
Copy link
Member

If it's not available, it is arguably more correct to use 0.0.0.0 rather than 127.0.0.1 but I'm less picky about that case.

This is an API breakage and I'm not sure I agree. I think the choice is arbitrary and changing from one value to another doesn't have a big enough gain for the breakage.

When the header is not set, requests should have REMOTE_ADDR set to the actual remote addr.

Possibly... fallback to socket is not a bad idea.

@Roguelazer
Copy link
Contributor Author

I would be satisfied with just having it fall back to the result of getpeeraddr; it seems unquestionably wrong that if I set set_remote_address header: "Foo" and someone sends a request without the "Foo" header, the request gets treated as coming from localhost (which might have elevated trust).

@nateberkopec
Copy link
Member

Whoops, closed by #2653

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

Successfully merging a pull request may close this issue.

2 participants