-
Notifications
You must be signed in to change notification settings - Fork 887
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
Redirect crashes if path contains CRLF #2800
Comments
@leplatrem Thanks for the report! I think this is a WebOb issue, similar to Pylons/webob#231. ISTM that the ideal response to such a request would be a "400 Bad Request". |
You are passing user input directly into a http response without sanitizing the input. Historically this has never really been webob's stance to handle these things automatically. The best you could ask for is maybe a custom exception that webob would raise and you would have to handle and turn into a 4xx. |
In this case WebOb is handling it. It's telling you you are setting a header to an invalid value because it contains control characters. It won't truncate things for you automatically though... that would IMHO be bad. @tseaver That issue you linked is not similar at all. That is upon touching There were security seat belts added in header manipulation here: Pylons/webob#229 to avoid being vulnerable to HTTP Response splitting (which is exactly what the user above is being protected against). Now even if this were not caught by WebOb, and we would allow the setting of the Should WebOb raise a different error rather than ValueError? I don't think so. The accepted way of assigning the location is:
Setting an attribute should raise a This is not a WebOb or Pyramid issue. The location parameter passed to |
I can't see a scenario in which I don't close this ticket right now. Anyone wanna make an argument / offer a possible solution? To me this is simply not our responsibility to sanitize user input. I think it's great that we're even validating it to avoid the response splitting exploit. |
redirect requires an URL, and that is no URL there. |
@ztane That is incorrect. Redirect can either be a full URL, or it can be a path. WebOb will make it a full URL on the way out the door. |
Path, or a relative URL? A relative URL is still a URL., but something with unescaped CRLF's is not. And BTW, as per https://tools.ietf.org/html/rfc7231, a relative URL is now allowed in Location. |
With the following example:
If I pass some CRLF character in the path, the app crashes:
I could fix my route pattern with something like
/{path:(?!v1)[^\r]*}
but don't you think the URL should be truncated on CRLF when passed as redirect?I would be happy to work on a patch if you think it's relevant. Otherwise don't hesitate to close the issue.
The text was updated successfully, but these errors were encountered: