From ac7f194c4d264ba29c3b6235d2f6866ca81c2e1e Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 16 Jan 2017 15:03:45 -0800 Subject: [PATCH] wsproxy: stricter validation. --- browser/wsproxy.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/browser/wsproxy.js b/browser/wsproxy.js index 1f3f4af6..7ae3222a 100644 --- a/browser/wsproxy.js +++ b/browser/wsproxy.js @@ -86,6 +86,12 @@ WSProxy.prototype._handleResolve = function _handleResolve(ws, name, record, cal return; } + if (record !== 'A' && record !== 'AAAA') { + this.log('Client sent a bad record type: %s.', record); + ws.disconnect(); + return; + } + if (!NAME_REGEX.test(name) || name.length > 200) { this.log('Client sent a bad domain: %s.', name); ws.disconnect(); @@ -143,8 +149,8 @@ WSProxy.prototype._handleConnect = function _handleConnect(ws, port, host, nonce } } - if (!/^[a-zA-Z0-9\.:\-]+$/.test(host)) { - this.log('Client gave a bad host (%s).', state.host); + if (IP.version(host) === -1) { + this.log('Client gave a bad host: %s (%s).', host, state.host); ws.emit('tcp error', { message: 'EHOSTUNREACH', code: 'EHOSTUNREACH'