Proxy errors (silent) in logs #528

Closed
viyatb opened this Issue Dec 9, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@viyatb
Member

viyatb commented Dec 9, 2015

I observed some proxy error (occurring multiple times) when combing through the logs files,

[ERROR] [2015-12-08 23:13:15,010] [File 'web.py', line 1407, in log_exception] - Uncaught exception POST /mail/u/0/?ui=2&ik=54e58ff210&rid=mail%3Ai.2430.0.1&view=cv&th=1516b27b7f05397a&th=1516617fe80662ae&th=1516166782d8017d&th=15160e6c936f9a34&th=1513c558b10e2db5&prf=1&_reqid=183595&nsc=1&mb=0&rt=j&search=inbox (1)
HTTPServerRequest(protocol='https', host='mail.google.com', method='POST', uri='/mail/u/0/?ui=2&ik=54e58ff210&rid=mail%3Ai.2430.0.1&view=cv&th=1516b27b7f05397a&th=1516617fe80662ae&th=1516166782d8017d&th=15160e6c936f9a34&th=1513c558b10e2db5&prf=1&_reqid=183595&nsc=1&mb=0&rt=j&search=inbox', version='HTTP/1.1', remote_ip=u'1', headers={'Origin': 'https://mail.google.com', 'Content-Length': '0', 'Accept-Language': 'en-US,en;q=0.8', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36', 'Dnt': '1', 'Host': 'mail.google.com', 'Referer': 'https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.en.3TS1r_chCQs.O/m=m_i,t,it/am=PiP-WsD8v_cHcZ0hAO3SByrsvfc87iLFzx4e7r83AUTWBcD_zf4fwP_Be9MWCg/rt=h/d=1/t=zcms/rs=AHGWq9AbotIVRfAdPBOdN6YLEUu-AW9siA', 'X-Same-Domain': '1', 'Cookie': xxxx', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'})
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/tornado/web.py", line 1288, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "/usr/lib/python2.7/site-packages/tornado/stack_context.py", line 314, in wrapped
    ret = fn(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/tornado/web.py", line 1484, in future_complete
    f.result()
  File "/usr/lib/python2.7/site-packages/tornado/concurrent.py", line 109, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/site-packages/tornado/gen.py", line 631, in run
    yielded = self.gen.throw(*sys.exc_info())
  File "/home/viyat/workspace/owtf/framework/http/proxy/proxy.py", line 202, in get
    if response.code in [408, 599]:
UnboundLocalError: local variable 'response' referenced before assignment

@tunnelshade?

I think that this block of code

                try:
                    response = yield tornado.gen.Task(async_client.fetch, request)
                except Exception:
                    pass
                # Request retries
                for i in range(0, 3):
                    if response.code in [408, 599]:
                        self.request.response_buffer = ''
                        response = yield tornado.gen.Task(async_client.fetch, request)
                    else:
                        success_response = True
                        break

has a bug when Exception occurs and there is no response object. See https://github.com/owtf/owtf/blob/develop/framework/http/proxy/proxy.py#L196

@viyatb viyatb added the Bug label Dec 9, 2015

@tunnelshade

This comment has been minimized.

Show comment
Hide comment
@tunnelshade

tunnelshade Dec 9, 2015

Member

@delta24 Just check if there is a response object so the if condition turns out

response == None or response.code in [408, 599]

As this should be a performance required code, assign response to None in the Exception block

Member

tunnelshade commented Dec 9, 2015

@delta24 Just check if there is a response object so the if condition turns out

response == None or response.code in [408, 599]

As this should be a performance required code, assign response to None in the Exception block

@viyatb

This comment has been minimized.

Show comment
Hide comment
@viyatb

viyatb Dec 9, 2015

Member

ok, I'll set the response object to be None in the exception block 👍

Member

viyatb commented Dec 9, 2015

ok, I'll set the response object to be None in the exception block 👍

@viyatb viyatb closed this in e237892 Dec 9, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment