Skip to content

[HttpParser] Handle invalid/malformed request chunks from client #127

@abhinavsingh

Description

@abhinavsingh

Describe the bug
Currently, HttpParser works well assuming incoming client is not notorious :) Handle cases when client can send invalid chunks in requests.

To Reproduce
Steps to reproduce the behavior:

  1. Run proxy.py as proxy.py --pac-file proxy.pac
  2. telnet localhost 8899 and hit Enter key to send line feed
$ telnet localhost 8899
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Connection closed by foreign host.
  1. See error
2019-10-11 11:12:06,277 - pid:55396 [E] run:2215 - Exception while handling connection <socket.socket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=0, laddr=('::1', 8899, 0, 0), raddr=('::1', 49902, 0, 0)>
Traceback (most recent call last):
  File "./proxy.py", line 2205, in run
    teardown = self.run_once()
  File "./proxy.py", line 2173, in run_once
    teardown = self.handle_events(readables, writables)
  File "./proxy.py", line 2138, in handle_events
    teardown = self.handle_readables(readables)
  File "./proxy.py", line 2076, in handle_readables
    self.request.parse(client_data)
  File "./proxy.py", line 615, in parse
    more, raw = self.process(raw)
  File "./proxy.py", line 625, in process
    self.process_line(line)
  File "./proxy.py", line 667, in process_line
    self.url = urlparse.urlsplit(line[1])
IndexError: list index out of range
2019-10-11 11:12:06,279 - pid:55396 [I] access_log:1955 - ::1:49902 -  None

Expected behavior
HttpParser must either ignore invalid chunks or be strict about it and drop the connection.

Metadata

Metadata

Assignees

Labels

BugBug report in proxy serverGood First IssueIssues for new contributors to pick-up

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions