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

cheroot/server.py:968: TypeError: not enough arguments for format string #218

Closed
1 of 3 tasks
alpire opened this issue Aug 9, 2019 · 1 comment Β· Fixed by #219
Closed
1 of 3 tasks

cheroot/server.py:968: TypeError: not enough arguments for format string #218

alpire opened this issue Aug 9, 2019 · 1 comment Β· Fixed by #219
Labels
bug Something is broken good first issue This is what we believe is newcomer-friendly, feel free to contribute! help wanted Somebody help us, please! reproducer: present This PR or issue contains code, which reproduce the problem described or clearly understandable STR

Comments

@alpire
Copy link
Contributor

alpire commented Aug 9, 2019

❓ I'm submitting a ...

  • 🐞 bug report
  • 🐣 feature request
  • ❓ question about the decisions made in the repository

🐞 Describe the bug. What is the current behavior?

cherrypy returns a 500 on some malformed HTTP request due to a missing argument in a format string in server.read_request_line.

❓ What is the motivation / use case for changing the behavior?

I believe that web servers should not return 500s in general. If you disagree, feel free to close this issue. Otherwise, I'll keep fuzzing cherrypy and reporting issues.

πŸ’‘ To Reproduce

Steps to reproduce the behavior:

  1. Run a cherrypy server, like the following:
import cherrypy

class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        return "Hello World!"

cherrypy.quickstart(HelloWorld())
  1. Make request with echo -ne "GET / HTTP/1\r\n\r\n" | nc localhost 8080
  2. See the 500 response

πŸ’‘ Expected behavior

I would expect a 4xx request, probably a 400

πŸ“‹ Details

[09/Aug/2019:15:50:52] ENGINE TypeError('not enough arguments for format string')
Traceback (most recent call last):
  File "/Users/apr/.pyenv/versions/3.7.2/lib/python3.7/site-packages/cheroot/server.py", line 1263, in communicate
    req.parse_request()
  File "/Users/apr/.pyenv/versions/3.7.2/lib/python3.7/site-packages/cheroot/server.py", line 719, in parse_request
    success = self.read_request_line()
  File "/Users/apr/.pyenv/versions/3.7.2/lib/python3.7/site-packages/cheroot/server.py", line 968, in read_request_line
    self.response_protocol = 'HTTP/%s.%s' % min(rp, sp)
TypeError: not enough arguments for format string

πŸ“‹ Environment

  • Cheroot version: 6.5.5
  • CherryPy version: 18.1.2
  • Python version: 3.7.2
  • OS: MacOS Mojave
  • Browser: N/A
@alpire alpire changed the title cheroot/server.py:968: Typerror: not enough arguments for format string cheroot/server.py:968: TypeError: not enough arguments for format string Aug 9, 2019
@webknjaz
Copy link
Member

webknjaz commented Aug 9, 2019

Thanks for the report! PR is welcome :)

P.S. I'm thinking of migrating to Hyper11: #201 but that shouldn't stop us from making bug fixes.

@webknjaz webknjaz added bug Something is broken good first issue This is what we believe is newcomer-friendly, feel free to contribute! help wanted Somebody help us, please! reproducer: present This PR or issue contains code, which reproduce the problem described or clearly understandable STR and removed triage labels Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken good first issue This is what we believe is newcomer-friendly, feel free to contribute! help wanted Somebody help us, please! reproducer: present This PR or issue contains code, which reproduce the problem described or clearly understandable STR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants