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

REMOTE_ADDR used unconditionally #53

Closed
steamraven opened this issue Jan 31, 2012 · 2 comments
Closed

REMOTE_ADDR used unconditionally #53

steamraven opened this issue Jan 31, 2012 · 2 comments

Comments

@steamraven
Copy link

toolbar.py: 101
remote_addr = request.remote_addr

However, the wsgi spec does not actually define REMOTE_ADDR, and the system could be behind a proxy with X-FORWARDED-FOR headers. I know if at least one WSGI server that does not provide this.

@mcdonc
Copy link
Member

mcdonc commented Feb 1, 2012

request.remote_addr is implemented as an "environ_getter" in webob; the getter looks for the value of environ['REMOTE_ADDR'] and if it doesn't exist it returns None. It would be quite dangerous for us to also consider HTTP_X_FORWARDED_FOR here because that header can be set by an HTTP client. Any fix that used HTTP_X_FORWARDED_FOR would require us to also ensure that the value of REMOTE_ADDR was in a "trusted proxy" list, so it wouldn't work under the server you've mentioned anyway.

That said, I'd consider a patch that made the "ok check" a callback so you could pass in an arbitrary function to do the checking (rather than the toolbar being hardcoded to depend on REMOTE_ADDR).

@mmerickel
Copy link
Member

The HTTP_X_FORWARDED_FOR, or any other proxy-specific headers should be translated into their environ keys by some middleware. For example paste's PrefixMiddleware does this already for HTTP_X_FORWARDED_PROTO, _SCHEME and _SERVER.

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

No branches or pull requests

3 participants