From dd20c0186fab9dd92b42f280b8d2b6f980f6b406 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Thu, 20 Sep 2018 15:02:26 +0200 Subject: [PATCH] http: add --security-revert for CVE-2018-12116 PR-URL: https://github.com/nodejs-private/node-private/pull/146 Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Anna Henningsen Reviewed-By: Timothy Gu Reviewed-By: Ruben Bridgewater --- lib/_http_client.js | 11 ++++++++++- src/node_revert.h | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index cd8152cd55c512..448be27a72ed7e 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -14,6 +14,8 @@ const OutgoingMessage = require('_http_outgoing').OutgoingMessage; const Agent = require('_http_agent'); const Buffer = require('buffer').Buffer; +const REVERT_CVE_2018_12116 = process.REVERT_CVE_2018_12116; + const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/; function ClientRequest(options, cb) { @@ -47,7 +49,14 @@ function ClientRequest(options, cb) { var path; if (options.path) { path = String(options.path); - if (INVALID_PATH_REGEX.test(path)) + var invalidPath; + if (REVERT_CVE_2018_12116) { + invalidPath = /[\u0000-\u0020]/.test(path); + } else { + invalidPath = INVALID_PATH_REGEX.test(path); + } + + if (invalidPath) throw new TypeError('Request path contains unescaped characters'); } diff --git a/src/node_revert.h b/src/node_revert.h index 1f7533c0e59aab..9c05270cc6e466 100644 --- a/src/node_revert.h +++ b/src/node_revert.h @@ -15,8 +15,8 @@ **/ namespace node { -#define SECURITY_REVERSIONS(XX) -// XX(CVE_2016_PEND, "CVE-2016-PEND", "Vulnerability Title") +#define SECURITY_REVERSIONS(XX) \ + XX(CVE_2018_12116, "CVE-2018-12116", "HTTP request splitting") enum reversion { #define V(code, ...) SECURITY_REVERT_##code,