-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: improve invalid character in header error message #9010
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nit.
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var http = require('http'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack, not sure what I was thinking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending @jasnell's nits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Tiny nit: commit subject line is a bit too long (55 chars) but I honestly have not idea how to make it shorter. |
@ChALkeR could you search for |
Ping ... @evanlucas @Fishrock123 @ChALkeR ... as a semver-major this needs to be landed ASAP if it's going to make it into v7.0.0. We're a week out from the release and I do not want to land a semver-major last minute. |
Commit message title has been updated. |
@@ -355,7 +355,8 @@ OutgoingMessage.prototype.setHeader = function(name, value) { | |||
if (this._header) | |||
throw new Error('Can\'t set headers after they are sent.'); | |||
if (common._checkInvalidHeaderChar(value) === true) { | |||
throw new TypeError('The header content contains invalid characters'); | |||
throw new TypeError( | |||
`The header content for "${name}" contains invalid characters`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: a line continuation should have four spaces of indent.
Anyone have opinions on whether this could be used in information leaks or, if the header name is attacker-controlled, inserting tainted data in logs or terminals? It seems farfetched but it's good to think about such things. |
@bnoordhuis that is a good point. Thanks for bringing it up. We are already throwing if the header name is not valid with a message like |
How about |
c133999
to
83c7a88
Compare
This commit includes the header name in the error message when invalid characters are in the value.
Updated with @addaleax's suggestion. |
@Fishrock123 @evanlucas Sorry for the delay on this one — still catching up and finishing unfinished stuff =). All matches for
Note that 7bef1b7 is relatively new, so I might need to sync the dataset today and re-check another time. |
@evanlucas ... I will be running the v7.0.0 RC1 build this afternoon. If this should get in to v7, then it needs to land this morning. |
This was discussed at yesterday's CTC meeting and a resolution was arrived at, so I'm going to remove the ctc-agenda label. |
Ok, I updated the dataset to 2016-10-22, the results for
Only copies of Note that delaying this until v8.0 will give the package authors more time to introduce dependencies on the error message, so this would have to be re-checked later. Upd: I performed another search for > ./search.code.sh 'content contains' | grep -vE '(that|the|text|new|HTML|node|tab|window|loaded|provided) content contains' | grep -vE '(fb|interaction|res|resultObj).content contains' | grep -vE 'content contains (the|HTML|myCoolFramework)'
frida-http-1.0.1.tgz/lib/_http_outgoing.js:313: throw new TypeError('The header content contains invalid characters');
frida-http-1.0.1.tgz/lib/_http_outgoing.js:353: throw new TypeError('The header content contains invalid characters');
frida-http-1.0.1.tgz/lib/_http_outgoing.js:527: throw new TypeError('The trailer content contains invalid characters');
http-node-1.2.0.tgz/_http_outgoing.js:309: throw new TypeError('The header content contains invalid characters');
http-node-1.2.0.tgz/_http_outgoing.js:348: throw new TypeError('The header content contains invalid characters');
http-node-1.2.0.tgz/_http_outgoing.js:522: throw new TypeError('The header content contains invalid characters');
rapx-win-1.4.2.tgz/ruff_modules/http/src/_http_outgoing.js:312: throw new TypeError('The header content contains invalid characters');
rapx-win-1.4.2.tgz/ruff_modules/http/src/_http_outgoing.js:351: throw new TypeError('The header content contains invalid characters');
rapx-win-1.4.2.tgz/ruff_modules/http/src/_http_outgoing.js:522: throw new TypeError('The trailer content contains invalid characters'); |
Btw, what about |
@ChALkeR thanks, I'll add one for trailers too. |
Closing as we landed the debug messages instead (#9195) |
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
http
Description of change
This commit includes the header name in the error message when invalid
characters are in the value.