Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: whitespace in header field name violation #3093

Closed
jasnell opened this issue Sep 27, 2015 · 10 comments
Closed

http: whitespace in header field name violation #3093

jasnell opened this issue Sep 27, 2015 · 10 comments
Assignees
Labels
help wanted Issues that need assistance from volunteers or PRs that need help to proceed. http_parser Issues and PRs related to the HTTP Parser dependency or the http_parser binding. http Issues or PRs related to the http subsystem.

Comments

@jasnell
Copy link
Member

jasnell commented Sep 27, 2015

Per RFC 7230: "A server MUST reject any received request message that contains whitespace between a header field-name and colon with a response code of 400 (Bad Request)."

We are currently ignoring this. To test, create a simple server:

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

Then send a simple request via telnet, inserting whitespace between the header field name and the colon:

$ telnet localhost 8080
GET / HTTP/1.1
Test    : ing

HTTP/1.1 200 OK
Date: ...

The server will respond with a 200 (OK) rather than the required 400 (Bad Request)

@jasnell
Copy link
Member Author

jasnell commented Sep 27, 2015

I believe the fix actually needs to be made in http-parser and not Node, but opening this to track so I don't forget

@jasnell jasnell self-assigned this Sep 27, 2015
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Sep 27, 2015
@addaleax addaleax added the http_parser Issues and PRs related to the HTTP Parser dependency or the http_parser binding. label Apr 30, 2017
@Trott
Copy link
Member

Trott commented Aug 6, 2017

Refs: nodejs/http-parser#315

@Trott
Copy link
Member

Trott commented Aug 6, 2017

This has been sitting here for almost two years, so I'm going to put a help wanted label on it. Maybe we should add mentor available label as well if you're available to mentor on it @jasnell?

@Trott Trott added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Aug 6, 2017
@Trott
Copy link
Member

Trott commented Aug 6, 2017

@nodejs/http

@jasnell
Copy link
Member Author

jasnell commented Aug 6, 2017

It's an extremely non-trivial issue that requires pretty deep knowledge of the http-parser. It also has a major impact on performance. It's not going to be easy by any measure.

@Trott Trott removed the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Aug 6, 2017
@bnoordhuis
Copy link
Member

Should this actually be fixed though? Extraneous whitespace is common enough that http-parser users will want a way to turn off rejection, even in strict mode.

It's also harmless, IMO. The parser skips over the whitespace; there is no observable difference to users because they never see it. You can't use it as a vector for smuggling attacks.

Besides to-the-letter compliance with the spec, what is the point of making it an error?

@apapirovski
Copy link
Member

Does anyone feel about this strongly one way or another? The more time passes, the less likely we'll be able to change it without causing breakage so it would be good to make a decision one way or another.

@bnoordhuis
Copy link
Member

I might have been wrong about this part:

The parser skips over the whitespace; there is no observable difference to users because they never see it.

A header like X-Foo : bar shows up as 'x-foo ' in req.headers. That should be fixed.

@apapirovski apapirovski added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Apr 13, 2018
@wellingguzman
Copy link

Is this ticket taken? I would like to try this one.

@bnoordhuis
Copy link
Member

@wellingguzman You're welcome to but it should probably be fixed in nodejs/http-parser, not nodejs/node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that need assistance from volunteers or PRs that need help to proceed. http_parser Issues and PRs related to the HTTP Parser dependency or the http_parser binding. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

7 participants