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

Let the possibility to specify a wildcard for the truted_proxy var #119

Conversation

dulacp
Copy link

@dulacp dulacp commented Nov 11, 2015

Here is a suggestion to use the X_FORWARDED_PROTO on cloud based reversed proxies with no fixed ip.

I don't see any personal objection on allowing the wildcard if it is documented well enough for this particular case.

Cheers

because for some cloud based reversed proxies you can't determined the
fixed ip used, but you already know that the proxy can be trusted
@tseaver
Copy link
Member

tseaver commented Nov 11, 2015

This feature introduces a huge security hole: allowing any host which can see the server set those headers opens a site up to phishing, etc.

I'd be more willing to merge a feature which allowed either a list of trusted proxies, or perhaps a way to spell a subnet (e.g., using the py-ipaddress distribution on Python2.

@mmerickel
Copy link
Member

pyramid_debugtoolbar works for subnets including 0.0.0.0/0 as well as specific ip addresses. This is probably a good approach to copy.

@dulacp
Copy link
Author

dulacp commented Nov 12, 2015

My first approach was indeed to use ip subnet masks, but I didn't want to introduce a dependency without first submitting the idea of trusting not only fixed ip addresses.

I agree that it may introduce a hole, but in the case of Heroku you can't receive wrong headers from Nginx. Well that's what I understand so far from reading the documentation.

I will make the changes then with the ipaddress package (and natively for Python 3).

@tseaver
Copy link
Member

tseaver commented Nov 12, 2015

Hmm, looking at https://pypi.python.org/pypi/py2-ipaddress, it doesn't appear to support Python 3.2 / 3.3, which we need to support.

@tseaver
Copy link
Member

tseaver commented Nov 12, 2015

https://pypi.python.org/pypi/ipaddress looks to be a better choice.

@mmerickel
Copy link
Member

It's probably a reasonable dependency for a wsgi server to be able to parse ip addresses properly. Alternatively pyramid_debugtoolbar just vendored the ipaddr module.

https://github.com/Pylons/pyramid_debugtoolbar/blob/master/pyramid_debugtoolbar/ipaddr.py

@dulacp
Copy link
Author

dulacp commented Nov 12, 2015

Exactly, the package ipaddress is needed for Python 2.6, 2.7 until 3.3 where it was included as a built-in module.

@dulacp
Copy link
Author

dulacp commented Dec 6, 2015

I have replaced the wildcard use by a subnet mask.

So you can specify a trusted_proxy configuration as 192.168.0.1/24 or even could use values like 0.0.0.0/0 if you want to authorize every ip.

This way people can granularly choose the security they need.

Is the implement good for you ?
If it is I could fix the documentation to reflect the changes

Cheers

@dulacp
Copy link
Author

dulacp commented Dec 6, 2015

The tests failed under Python 3.2, but I can't find the reason why the SyntaxError is raised. If anyone knows Python 3.2 specifics syntax tricks

@dulacp
Copy link
Author

dulacp commented Dec 6, 2015

I finally found how to fix the tests !

@mmerickel
Copy link
Member

Is there a reason you have pinned ipaddress < 1.1? We tend to avoid pinning in packages without reason, allowing users themselves to do the pinning if there is a problem.

Also I believe ipaddress is a backport of a python 3.3 feature, so it should not be depended upon for 3.3+ so a conditional install_requires is necessary.

@dulacp
Copy link
Author

dulacp commented Dec 7, 2015

Very well, I removed the pinned statement, it is indeed better this way !
And I have only included ipaddress for Python version strictly below 3.3.

@mmerickel
Copy link
Member

Could you add a test for the new behavior? It's good to see the current tests pass unchanged for the trusted_proxy setting. We also need to update the docs to reflect the new features that trusted_proxy supports.

@digitalresistor
Copy link
Member

I really think this ought to not live in waitress, and instead should be middleware. There's some work that was done in WebOb and I need to take a look at it again, but I think solving it there will be much more useful as a WSGI middleware than special support in the HTTP server.

@mmerickel
Copy link
Member

I already argued for this a bit when the feature was added. It's in now, so we can only try to improve it. Point-being I think that your comment is not constructive to this particular PR. :-)

@@ -33,9 +33,15 @@
'coverage',
]

install_requires = []

if sys.version_info[:2] == (2, 6):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@mmerickel
Copy link
Member

@dulaccc I think this PR is good but there are outstanding issues on it going back to 2015. We cannot use this code unless you sign the contributors agreement so I must close this. If you'd like to at least add your name to CONTRIBUTORS.txt we can have someone else work on the rest.

@mmerickel mmerickel closed this Mar 23, 2017
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

Successfully merging this pull request may close these issues.

None yet

5 participants