Skip to content

http: missing host header violation #3094

Description

@jasnell

Per RFC 7230: "A server MUST respond with a 400 (Bad Request) status code to any HTTP/1.1 request message that lacks a Host header field and to any request message that contains more than one Host header field or a Host header field with an invalid field-value."

Node currently ignores this requirement. To test, create a simple server:

http.createServer(function(req,res) {
  res.end('ok');
}).listen(8080);

First, test the missing Host header

$ telnet localhost 8080
GET / HTTP/1.1

HTTP/1.1 200 OK

Second, test duplicate Host headers:

$ telnet localhost 8080
GET / HTTP/1.1
Host: A
Host: B

HTTP/1.1 200 OK

Third, test malformed Host headers:

$ telnet localhost 8080
GET / HTTP/1.1
Host: A, B

HTTP/1.1 200 OK

Activity

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

Metadata

Metadata

Assignees

Labels

httpIssues and PRs related to the http subsystem.securityIssues and PRs related to security.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions