node-http-mitm-proxy icon indicating copy to clipboard operation
node-http-mitm-proxy copied to clipboard

Dies on HTTP requests with no Host: header

Open trisk opened this issue 8 years ago • 2 comments

I was wondering if the proxy could be made to serve the cert file directly to HTTP clients. It seems to be easily confused by non-proxy HTTP requests right now.

GET / HTTP/1.0 results in:

.../http-mitm-proxy/lib/proxy.js:708                                                                                                                                                       
    host: hostPort.host,                                                                                                                                                                                                          
                  ^                                                                                                                                                                                                               

TypeError: Cannot read property 'host' of null                                                                                                                                                                                    
  at [object Object].Proxy._onHttpServerRequest (.../http-mitm-proxy/lib/proxy.js:708:19)                                                                                                  
  at emitTwo (events.js:87:13)                                                                                                                                                                                                    
  at Server.emit (events.js:172:7)                                                                                                                                                                                                
  at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:528:12)                                                                                                                                                         
  at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)                                                                                                                                                                   

trisk avatar Jul 28 '16 01:07 trisk

http://stackoverflow.com/a/247026/1961513

felicienfrancois avatar Jul 28 '16 12:07 felicienfrancois

.../proxy.js:732
    host: hostPort.host,
                   ^

TypeError: Cannot read property 'host' of null
    at Proxy._onHttpServerRequest (.../node_modules/http-mitm-proxy/lib/proxy.js:732:20)
    at emitTwo (events.js:126:13)
    at Server.emit (events.js:214:7)
    at parserOnIncoming (_http_server.js:619:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)

It is a bug, because in all cases, the MITM proxy must absolutely not crash when it finds no host in the headers (which is the current behavior of the MITM) The MITM should respond bad request or return an error message in the absence of a header.

Minyar2004 avatar Mar 14 '19 16:03 Minyar2004