From eb7e1e92dd5d5957cd5d34f2b99e1e10ee3fd73e Mon Sep 17 00:00:00 2001 From: martinbednar Date: Mar 04 2021 15:29:22 +0000 Subject: NBS-chrome: Analyze HTTP response only when initiator in resposeDetails is defined. --- diff --git a/chrome/http_shield_chrome.js b/chrome/http_shield_chrome.js index 0b61e1f..276c417 100644 --- a/chrome/http_shield_chrome.js +++ b/chrome/http_shield_chrome.js @@ -284,9 +284,6 @@ function onResponseStartedListener(responseDetails) return; } - var sourceUrl = new URL(requestDetail.initiator); - //Removing www. from hostname, so the hostnames are uniform - sourceUrl.hostname = wwwRemove(sourceUrl.hostname); var targetUrl = new URL(responseDetails.url); //Removing www. from hostname, so the hostnames are uniform. targetUrl.hostname = wwwRemove(targetUrl.hostname); @@ -304,8 +301,15 @@ function onResponseStartedListener(responseDetails) } } - // Suspected of attacking, other HTTP requests by this host will be blocked. - if(isRequestFromPublicToPrivateNet(sourceUrl.hostname, targetUrl.hostname)) { - blockedHosts[sourceUrl.hostname] = true; + //Analyze request direction only when responseDetails.initiator is defined. + //When responseDetails.initiator is undefined, can not analyze request direction. + if(responseDetails.initiator !== undefined) { + var sourceUrl = new URL(responseDetails.initiator); + //Removing www. from hostname, so the hostnames are uniform + sourceUrl.hostname = wwwRemove(sourceUrl.hostname); + // Suspected of attacking, other HTTP requests by this host will be blocked. + if(isRequestFromPublicToPrivateNet(sourceUrl.hostname, targetUrl.hostname)) { + blockedHosts[sourceUrl.hostname] = true; + } } }