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

Returned 200 for illegal request url #1541

Closed
loggerhead opened this issue Jul 28, 2015 · 8 comments
Closed

Returned 200 for illegal request url #1541

loggerhead opened this issue Jul 28, 2015 · 8 comments

Comments

@loggerhead
Copy link

Flask version is 0.10.1 and the below is code of server side.

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

The below is input and output of netcat tool.

GET foo://127.999.999.999/ HTTP/1.1

HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 12
Server: Werkzeug/0.10.4 Python/2.7.10
Date: Tue, 28 Jul 2015 02:56:03 GMT

Hello World!
@loggerhead
Copy link
Author

@aftalavera see below picture.

output

@untitaker
Copy link
Contributor

Posting an absolute URI is fine in principle, so I guess the only issue here is that Flask doesn't do strict validation of the IP address and the scheme? I don't really know if that's its job.

@loggerhead
Copy link
Author

@untitaker Yes, the issue is just what you said. I think maybe this is the responsibility of Werkzeug, but I'm not sure the design principle of Flask, so I issue it here.

@untitaker
Copy link
Contributor

Not even Werkzeug, but whatever is parsing the original HTTP request.

I'm not even sure if we should reject the request or just fall back to sensible defaults.

@untitaker untitaker reopened this Jul 28, 2015
@loggerhead
Copy link
Author

@untitaker I have read Werkzeug code and found out WSGIRequestHandler in werkzeug/serving.py inherit BaseHTTPRequestHandler and it's parse_request method do the parsing thing.

Hopes that will help you.

@RonnyPfannschmidt
Copy link
Contributor

I'd consider this invalid, the development server is rather minimalistic, production servers do the validation

@ThiefMaster
Copy link
Member

👍 for invalid. The dev server is not suitable for anything but development (and even then I'd run it behind nginx if there are lots of static assets so those requests aren't served by the dev server at all) so I don't think there's any important reason to be more strict in parsing HTTP requests as long as it works fine with valid requests.

@untitaker
Copy link
Contributor

I now have to agree with Adrian and Ronny, Flask/Werkzeug is not in a position to decide what a valid IP address is.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants