Crash on request with bad headers? #25

Closed
muhmi opened this Issue Mar 4, 2011 · 3 comments

Comments

Projects
None yet
2 participants
@muhmi

muhmi commented Mar 4, 2011

Hmm,

This is a bit of an lousy bug report, more of an notion. I had the http-proxy module fail with the following error message:

/root/local/node/lib/node/.npm/http-proxy/0.3.1/package/lib/proxy-table.js:80
  var target = proxy.req.headers.host.split(':')[0] + proxy.req.url;
                                      ^
TypeError: Cannot call method 'split' of undefined
    at [object Object].proxyRequest (/root/local/node/lib/node/.npm/http-proxy/0.3.1/package/lib/proxy-table.js:80:39)
    at Server.<anonymous> (/root/local/node/lib/node/.npm/http-proxy/0.3.1/package/lib/node-http-proxy.js:93:18)
    at Server.emit (events.js:45:17)
    at HTTPParser.onIncoming (http.js:1078:12)
    at HTTPParser.onHeadersComplete (http.js:87:31)
    at Socket.ondata (http.js:977:22)
    at Socket._onReadable (net.js:654:27)
    at IOWatcher.onReadable [as callback] (net.js:156:10)

Was not able to identify what caused it.... trying reproduce. Any idea?

@indexzero

This comment has been minimized.

Show comment Hide comment
@indexzero

indexzero Mar 4, 2011

Owner

Hmm ... definitely an edge case but something I should be checking for to prevent crashed from malformed requests. Here's the scenario

  1. You're using the ProxyTable.
  2. You're proxying by Host (i.e. proxy based on the value of the HTTP "Host" header
  3. Some careless user decided not to include a Host header
  4. Crash because proxy.req.headers.host (i.e. the value of the HTTP Host header) is undefined

I'll put in a check in 0.4.0. Going to get pushed out in the next 10 days or so

Owner

indexzero commented Mar 4, 2011

Hmm ... definitely an edge case but something I should be checking for to prevent crashed from malformed requests. Here's the scenario

  1. You're using the ProxyTable.
  2. You're proxying by Host (i.e. proxy based on the value of the HTTP "Host" header
  3. Some careless user decided not to include a Host header
  4. Crash because proxy.req.headers.host (i.e. the value of the HTTP Host header) is undefined

I'll put in a check in 0.4.0. Going to get pushed out in the next 10 days or so

@muhmi

This comment has been minimized.

Show comment Hide comment
@muhmi

muhmi Mar 4, 2011

I tried to telnet and do a request by hand without the Host header. Does not crash the server =)

muhmi commented Mar 4, 2011

I tried to telnet and do a request by hand without the Host header. Does not crash the server =)

@indexzero

This comment has been minimized.

Show comment Hide comment
@indexzero

indexzero Mar 4, 2011

Owner

hmm ... odd. Well no host header is the only reason I can think of that req.headers.host would be undefined.

Owner

indexzero commented Mar 4, 2011

hmm ... odd. Well no host header is the only reason I can think of that req.headers.host would be undefined.

This issue was closed.

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