From 8c7b4391a7ec6497710bb45665f97d020c4a8a7b Mon Sep 17 00:00:00 2001 From: hackademix Date: Mar 27 2023 20:45:35 +0000 Subject: Bug 41: Prevent NBS from leaking IPs through DNS for proxy requests. --- diff --git a/firefox/http_shield_firefox.js b/firefox/http_shield_firefox.js index 56e5459..4b3bf69 100644 --- a/firefox/http_shield_firefox.js +++ b/firefox/http_shield_firefox.js @@ -65,6 +65,9 @@ async function beforeSendHeadersListener(requestDetail) var sourceResolution = ""; var blockNotifications = false; + const {proxyInfo} = requestDetail; // see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/ProxyInfo + const dnsAllowed = !(proxyInfo && (proxyInfo.type && proxyInfo.type.startsWith("http") || proxyInfo.proxyDNS)); + //Host found among user's trusted hosts, allow it right away if (isNbsWhitelisted(sourceDomain)) { @@ -90,9 +93,9 @@ async function beforeSendHeadersListener(requestDetail) isSourcePrivate = true; } } - else //SOURCE is hostname - { - //Resoluting DNS query for source domain + else if (dnsAllowed) //SOURCE is hostname + { + //Resolving DNS query for source domain sourceResolution = browser.dns.resolve(fullSourceDomain).then((val) => { //Assigning source IPs @@ -143,9 +146,9 @@ async function beforeSendHeadersListener(requestDetail) } } } - else //Target is hostname + else if (dnsAllowed) //Target is hostname { - //Resoluting DNS query for destination domain + //Resolving DNS query for destination domain destinationResolution = browser.dns.resolve(fullTargetDomain).then((val) => { //Assigning source IPs