Skip to content

Commit 91e702c

Browse files
committed
Enable CNAME uncloaking by default
Advanced setting `cnameAliasList` has been removed. New advanced settings: cnameUncloak: Boolean Default value: true Description: Whether to CNAME-uncloak hostnames. cnameIgnoreExceptions: Boolean Default value: true Description: Whether to bypass the uncloaking of network requests which were excepted by filters/rules. This is necessary so as to avoid undue breakage by having exception filters being rendered useless as a result of CNAME-uncloaking. For example, `google-analytics.com` uncloaks to `www-google-analytics.l.google.com` and both hostnames appear in Peter Lowe's list, which means exception filters for `google-analytics.com` (to fix site breakage) would be rendered useless as the uncloaking would cause the network request to be ultimately blocked.
1 parent 8a1a8b1 commit 91e702c

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

platform/firefox/vapi-webrequest.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,21 @@
6161
super();
6262
this.pendingRequests = [];
6363
this.cnames = new Map([ [ '', '' ] ]);
64-
this.cnameAliasList = null;
6564
this.cnameIgnoreList = null;
6665
this.cnameIgnore1stParty = true;
66+
this.cnameIgnoreExceptions = true;
6767
this.cnameIgnoreRootDocument = true;
6868
this.cnameMaxTTL = 60;
6969
this.cnameReplayFullURL = false;
7070
this.cnameTimer = undefined;
71+
this.cnameUncloak = true;
7172
}
7273
setOptions(options) {
7374
super.setOptions(options);
74-
this.cnameAliasList = this.regexFromStrList(options.cnameAliasList);
75+
this.cnameUncloak = options.cnameUncloak !== false;
7576
this.cnameIgnoreList = this.regexFromStrList(options.cnameIgnoreList);
7677
this.cnameIgnore1stParty = options.cnameIgnore1stParty !== false;
78+
this.cnameIgnoreExceptions = options.cnameIgnoreExceptions !== false;
7779
this.cnameIgnoreRootDocument = options.cnameIgnoreRootDocument !== false;
7880
this.cnameMaxTTL = options.cnameMaxTTL || 120;
7981
this.cnameReplayFullURL = options.cnameReplayFullURL === true;
@@ -199,22 +201,29 @@
199201
);
200202
}
201203
onBeforeSuspendableRequest(details) {
202-
let r = super.onBeforeSuspendableRequest(details);
203-
if ( r !== undefined ) { return r; }
204-
if ( this.cnameAliasList === null ) { return; }
205-
if ( details.type === 'main_frame' && this.cnameIgnoreRootDocument ) {
204+
const r = super.onBeforeSuspendableRequest(details);
205+
if ( r !== undefined ) {
206+
if (
207+
r.cancel === true ||
208+
r.redirectUrl !== undefined ||
209+
this.cnameIgnoreExceptions
210+
) {
211+
return r;
212+
}
213+
}
214+
if (
215+
details.type === 'main_frame' &&
216+
this.cnameIgnoreRootDocument
217+
) {
206218
return;
207219
}
220+
if ( this.cnameUncloak === false ) { return; }
208221
const hn = vAPI.hostnameFromNetworkURL(details.url);
209222
let cname = this.cnames.get(hn);
210223
if ( cname === '' ) { return; }
211224
if ( cname !== undefined ) {
212225
return this.processCanonicalName(hn, cname, details);
213226
}
214-
if ( this.cnameAliasList.test(hn) === false ) {
215-
this.cnames.set(hn, '');
216-
return;
217-
}
218227
return browser.dns.resolve(hn, [ 'canonical_name' ]).then(
219228
rec => {
220229
const cname = this.recordCanonicalName(hn, rec);

src/js/background.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ const µBlock = (( ) => { // jshint ignore:line
4646
cacheStorageAPI: 'unset',
4747
cacheStorageCompression: true,
4848
cacheControlForFirefox1376932: 'no-cache, no-store, must-revalidate',
49-
cnameAliasList: 'unset',
5049
cnameIgnoreList: 'unset',
5150
cnameIgnore1stParty: true,
51+
cnameIgnoreExceptions: true,
5252
cnameIgnoreRootDocument: true,
53-
cnameMaxTTL: 120,
53+
cnameMaxTTL: 60,
5454
cnameReplayFullURL: false,
55+
cnameUncloak: true,
5556
consoleLogLevel: 'unset',
5657
debugScriptlets: false,
5758
debugScriptletInjector: false,

src/js/storage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@
136136
self.addEventListener('hiddenSettingsChanged', ( ) => {
137137
self.log.verbosity = µBlock.hiddenSettings.consoleLogLevel;
138138
vAPI.net.setOptions({
139-
cnameAliasList: µBlock.hiddenSettings.cnameAliasList,
140139
cnameIgnoreList: µBlock.hiddenSettings.cnameIgnoreList,
141140
cnameIgnore1stParty: µBlock.hiddenSettings.cnameIgnore1stParty,
141+
cnameIgnoreExceptions: µBlock.hiddenSettings.cnameIgnoreExceptions,
142142
cnameIgnoreRootDocument: µBlock.hiddenSettings.cnameIgnoreRootDocument,
143143
cnameMaxTTL: µBlock.hiddenSettings.cnameMaxTTL,
144144
cnameReplayFullURL: µBlock.hiddenSettings.cnameReplayFullURL,
145+
cnameUncloak: µBlock.hiddenSettings.cnameUncloak,
145146
});
146147
});
147148

src/js/traffic.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ const onBeforeRequest = function(details) {
103103
) {
104104
pageStore.setFrame(details.frameId, details.url);
105105
}
106-
return;
106+
if ( result !== 2 ) { return; }
107+
return { cancel: false };
107108
}
108109

109110
// Blocked

0 commit comments

Comments
 (0)