Skip to content

Commit

Permalink
disallow automatic validation of ALL IP's. fixes webpack#1618
Browse files Browse the repository at this point in the history
for both Host checking and Origin checking
  • Loading branch information
Carlos Requena López committed Jan 8, 2019
1 parent 178e6cc commit 657a2e5
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/Server.js
Expand Up @@ -647,6 +647,10 @@ Server.prototype.setContentHeaders = function (req, res, next) {
};

Server.prototype.checkHost = function (headers, headerToCheck) {
/* This routine is also used to check the Origin header, whenever
* headerToCheck says so
*/

// allow user to opt-out this security check, at own risk
if (this.disableHostCheck) {
return true;
Expand All @@ -668,15 +672,6 @@ Server.prototype.checkHost = function (headers, headerToCheck) {
false,
true
).hostname;
// always allow requests with explicit IPv4 or IPv6-address.
// A note on IPv6 addresses:
// hostHeader will always contain the brackets denoting
// an IPv6-address in URLs,
// these are removed from the hostname in url.parse(),
// so we have the pure IPv6-address in hostname.
if (ip.isV4Format(hostname) || ip.isV6Format(hostname)) {
return true;
}
// always allow localhost host, for convience
if (hostname === 'localhost') {
return true;
Expand Down

0 comments on commit 657a2e5

Please sign in to comment.