@@ -100,9 +100,8 @@ HeuristicBlocker.prototype = {
100100 * Use updateTrackerPrevalence for non-webRequest initiated bookkeeping.
101101 *
102102 * @param {Object } details request/response details
103- * @param {Boolean } check_for_cookie_share whether to check for cookie sharing
104103 */
105- heuristicBlockingAccounting : function ( details , check_for_cookie_share ) {
104+ heuristicBlockingAccounting : function ( details ) {
106105 // ignore requests that are outside a tabbed window
107106 if ( details . tabId < 0 || ! incognito . learningEnabled ( details . tabId ) ) {
108107 return { } ;
@@ -143,119 +142,6 @@ HeuristicBlocker.prototype = {
143142 self . _recordPrevalence ( request_host , request_origin , tab_origin ) ;
144143 return { } ;
145144 }
146-
147- // check for cookie sharing iff this is an image in the top-level frame, and the request URL has parameters
148- if ( check_for_cookie_share && details . type == 'image' && details . frameId === 0 && details . url . indexOf ( '?' ) > - 1 ) {
149- // get all non-HttpOnly cookies for the top-level frame
150- // and pass those to the cookie-share accounting function
151- let tab_url = self . tabUrls [ details . tabId ] ;
152-
153- let config = {
154- url : tab_url
155- } ;
156- if ( badger . firstPartyDomainPotentiallyRequired ) {
157- config . firstPartyDomain = null ;
158- }
159-
160- chrome . cookies . getAll ( config , function ( cookies ) {
161- cookies = cookies . filter ( cookie => ! cookie . httpOnly ) ;
162- if ( cookies . length >= 1 ) {
163- self . pixelCookieShareAccounting ( tab_url , tab_origin , details . url , request_host , request_origin , cookies ) ;
164- }
165- } ) ;
166- }
167- } ,
168-
169- /**
170- * Checks for cookie sharing: requests to third-party domains that include
171- * high entropy data from first-party cookies (associated with the top-level
172- * frame). Only catches plain-text verbatim sharing (b64 encoding + the like
173- * defeat it). Assumes any long string that doesn't contain URL fragments or
174- * stopwords is an identifier. Doesn't catch cookie syncing (3rd party -> 3rd
175- * party), but most of those tracking cookies should be blocked anyway.
176- *
177- * @param details are those from onBeforeSendHeaders
178- * @param cookies are the result of chrome.cookies.getAll()
179- * @returns {* }
180- */
181- pixelCookieShareAccounting : function ( tab_url , tab_origin , request_url , request_host , request_origin , cookies ) {
182- let params = ( new URL ( request_url ) ) . searchParams ,
183- TRACKER_ENTROPY_THRESHOLD = 33 ,
184- MIN_STR_LEN = 8 ;
185-
186- for ( let p of params ) {
187- let key = p [ 0 ] ,
188- value = p [ 1 ] ;
189-
190- // the argument must be sufficiently long
191- if ( ! value || value . length < MIN_STR_LEN ) {
192- continue ;
193- }
194-
195- // check if this argument is derived from a high-entropy first-party cookie
196- for ( let cookie of cookies ) {
197- // the cookie value must be sufficiently long
198- if ( ! cookie . value || cookie . value . length < MIN_STR_LEN ) {
199- continue ;
200- }
201-
202- // find the longest common substring between this arg and the cookies
203- // associated with the document
204- let substrings = utils . findCommonSubstrings ( cookie . value , value ) || [ ] ;
205- for ( let s of substrings ) {
206- // ignore the substring if it's part of the first-party URL. sometimes
207- // content servers take the url of the page they're hosting content
208- // for as an argument. e.g.
209- // https://example-cdn.com/content?u=http://example.com/index.html
210- if ( tab_url . indexOf ( s ) != - 1 ) {
211- continue ;
212- }
213-
214- // elements of the user agent string are also commonly included in
215- // both cookies and arguments; e.g. "Mozilla/5.0" might be in both.
216- // This is not a special tracking risk since third parties can see
217- // this info anyway.
218- if ( navigator . userAgent . indexOf ( s ) != - 1 ) {
219- continue ;
220- }
221-
222- // Sometimes the entire url and then some is included in the
223- // substring -- the common string might be "https://example.com/:true"
224- // In that case, we only care about the information around the URL.
225- if ( s . indexOf ( tab_url ) != - 1 ) {
226- s = s . replace ( tab_url , "" ) ;
227- }
228-
229- // During testing we found lots of common values like "homepage",
230- // "referrer", etc. were being flagged as high entropy. This searches
231- // for a few of those and removes them before we go further.
232- let lower = s . toLowerCase ( ) ;
233- lowEntropyQueryValues . forEach ( function ( qv ) {
234- let start = lower . indexOf ( qv ) ;
235- if ( start != - 1 ) {
236- s = s . replace ( s . substring ( start , start + qv . length ) , "" ) ;
237- }
238- } ) ;
239-
240- // at this point, since we might have removed things, make sure the
241- // string is still long enough to bother with
242- if ( s . length < MIN_STR_LEN ) {
243- continue ;
244- }
245-
246- // compute the entropy of this common substring. if it's greater than
247- // our threshold, record the tracking action and exit the function.
248- let entropy = utils . estimateMaxEntropy ( s ) ;
249- if ( entropy > TRACKER_ENTROPY_THRESHOLD ) {
250- log ( "Found high-entropy cookie share from" , tab_origin , "to" , request_host ,
251- ":" , entropy , "bits\n cookie:" , cookie . name , '=' , cookie . value ,
252- "\n arg:" , key , "=" , value , "\n substring:" , s ) ;
253- this . _recordPrevalence ( request_host , request_origin , tab_origin ) ;
254- return ;
255- }
256- }
257- }
258- }
259145 } ,
260146
261147 /**
@@ -546,51 +432,6 @@ var lowEntropyCookieValues = {
546432 "zu" :8
547433} ;
548434
549- const lowEntropyQueryValues = [
550- "https" ,
551- "http" ,
552- "://" ,
553- "%3A%2F%2F" ,
554- "www" ,
555- "url" ,
556- "undefined" ,
557- "impression" ,
558- "session" ,
559- "homepage" ,
560- "client" ,
561- "version" ,
562- "business" ,
563- "title" ,
564- "get" ,
565- "site" ,
566- "name" ,
567- "category" ,
568- "account_id" ,
569- "smartadserver" ,
570- "front" ,
571- "page" ,
572- "view" ,
573- "first" ,
574- "visit" ,
575- "platform" ,
576- "language" ,
577- "automatic" ,
578- "disabled" ,
579- "landing" ,
580- "entertainment" ,
581- "amazon" ,
582- "official" ,
583- "webvisor" ,
584- "anonymous" ,
585- "across" ,
586- "narrative" ,
587- "\":null" ,
588- "\":false" ,
589- "\":\"" ,
590- "\",\"" ,
591- "\",\"" ,
592- ] ;
593-
594435/**
595436 * Extract cookies from onBeforeSendHeaders
596437 *
@@ -680,7 +521,7 @@ function startListeners() {
680521 extraInfoSpec . push ( 'extraHeaders' ) ;
681522 }
682523 chrome . webRequest . onBeforeSendHeaders . addListener ( function ( details ) {
683- return badger . heuristicBlocking . heuristicBlockingAccounting ( details , true ) ;
524+ return badger . heuristicBlocking . heuristicBlockingAccounting ( details ) ;
684525 } , { urls : [ "<all_urls>" ] } , extraInfoSpec ) ;
685526
686527 /**
@@ -699,7 +540,7 @@ function startListeners() {
699540 }
700541 }
701542 if ( hasSetCookie ) {
702- return badger . heuristicBlocking . heuristicBlockingAccounting ( details , false ) ;
543+ return badger . heuristicBlocking . heuristicBlockingAccounting ( details ) ;
703544 }
704545 } ,
705546 { urls : [ "<all_urls>" ] } , extraInfoSpec ) ;
0 commit comments