@ai-ecoverse/slicc-browsers 1.26.5 → 1.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/catalog.json +4 -0
- package/credential-export.mjs +1359 -0
- package/fixture-server.mjs +5 -0
- package/guard-driver.mjs +2 -0
- package/guard-runner.mjs +40 -4
- package/guard-vectors.json +382 -1
- package/package.json +3 -2
- package/protected.mjs +49 -0
- package/schema/catalog.schema.json +22 -0
- package/schema/guard-vectors.schema.json +22 -0
- package/sign-in-hold.mjs +39 -16
|
@@ -0,0 +1,1359 @@
|
|
|
1
|
+
import { outcome, parseURL, waitFor } from './guard-driver.mjs';
|
|
2
|
+
import { createObserverTarget } from './observer-target.mjs';
|
|
3
|
+
|
|
4
|
+
const refused = (out) => !out.ok && /^slicc: refused:/.test(out.error?.message ?? '');
|
|
5
|
+
const unsupported = (out) =>
|
|
6
|
+
!out.ok &&
|
|
7
|
+
/(?:Method|method) (?:not found|doesn't exist)|wasn't found|Unknown method|not supported|Not supported/i.test(
|
|
8
|
+
String(out.error?.message ?? out.error ?? '')
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const hostOf = (text) => {
|
|
12
|
+
const u = typeof text === 'string' ? parseURL(text) : text;
|
|
13
|
+
const host = (u?.hostname ?? '').toLowerCase();
|
|
14
|
+
return host.endsWith('.') ? host.slice(0, -1) : host;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const originOf = (text) => {
|
|
18
|
+
const u = parseURL(text);
|
|
19
|
+
if (!u?.host) return null;
|
|
20
|
+
const host = hostOf(u);
|
|
21
|
+
if (!host) return null;
|
|
22
|
+
return `${u.protocol}//${host}${u.port ? `:${u.port}` : ''}`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const siteHost = (host) => {
|
|
26
|
+
const parts = host.split('.');
|
|
27
|
+
return parts.length >= 2 ? parts.slice(-2).join('.') : host;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function siteOf(url) {
|
|
31
|
+
const parsed = parseURL(url);
|
|
32
|
+
if (!parsed?.hostname) return null;
|
|
33
|
+
return `${parsed.protocol}//${siteHost(hostOf(parsed))}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const partitionSite = (cookie) => {
|
|
37
|
+
const key = cookie?.partitionKey;
|
|
38
|
+
return typeof key === 'string' ? key : (key?.topLevelSite ?? null);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const partitionedUnder = (cookie, site) => {
|
|
42
|
+
const key = partitionSite(cookie);
|
|
43
|
+
return Boolean(key) && hostOf(key) === hostOf(site);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function cookieHit(cookies, { name, host, value }) {
|
|
47
|
+
return (cookies ?? []).some((cookie) => {
|
|
48
|
+
if (cookie?.name !== name) return false;
|
|
49
|
+
if (value !== undefined && cookie.value !== value) return false;
|
|
50
|
+
const domain = String(cookie.domain ?? '')
|
|
51
|
+
.toLowerCase()
|
|
52
|
+
.replace(/^\./, '')
|
|
53
|
+
.replace(/\.$/, '');
|
|
54
|
+
return !host || domain === host || host.endsWith(`.${domain}`) || domain === '' || !domain;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const hasEntry = (entries, key, value) =>
|
|
59
|
+
(entries ?? []).some(
|
|
60
|
+
(entry) => entry?.[0] === key && (value === undefined || entry?.[1] === value)
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
async function pageReady(reader, sessionId, accept) {
|
|
64
|
+
const ev = await outcome(
|
|
65
|
+
reader.send(
|
|
66
|
+
'Runtime.evaluate',
|
|
67
|
+
{
|
|
68
|
+
expression: `({href:location.href,ready:document.readyState,title:document.title})`,
|
|
69
|
+
returnByValue: true,
|
|
70
|
+
},
|
|
71
|
+
sessionId
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
const value = ev.result?.result?.value;
|
|
75
|
+
return Boolean(
|
|
76
|
+
ev.ok && value?.ready === 'complete' && typeof value.href === 'string' && accept(value)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function openPage(reader, url, notes, internalSessions) {
|
|
81
|
+
const opened = await outcome(
|
|
82
|
+
createObserverTarget(reader, { url }, notes).then(async (created) => {
|
|
83
|
+
const { sessionId } = await reader.send('Target.attachToTarget', {
|
|
84
|
+
targetId: created.targetId,
|
|
85
|
+
flatten: true,
|
|
86
|
+
});
|
|
87
|
+
await reader.send('Page.enable', {}, sessionId);
|
|
88
|
+
await reader.send('Runtime.enable', {}, sessionId);
|
|
89
|
+
await reader.send('Network.enable', {}, sessionId);
|
|
90
|
+
const ready = await waitFor(
|
|
91
|
+
() =>
|
|
92
|
+
pageReady(
|
|
93
|
+
reader,
|
|
94
|
+
sessionId,
|
|
95
|
+
(value) => value.href.includes('/credential') && value.title === 'credential'
|
|
96
|
+
),
|
|
97
|
+
5000
|
|
98
|
+
);
|
|
99
|
+
if (!ready) throw new Error('credential page did not become ready');
|
|
100
|
+
return { targetId: created.targetId, sessionId };
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
if (!opened.ok) return opened;
|
|
104
|
+
internalSessions.add(opened.result.sessionId);
|
|
105
|
+
return opened;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const credentialCookieParams = (planted, origin, tag) => [
|
|
109
|
+
[
|
|
110
|
+
'HttpOnly',
|
|
111
|
+
{ name: planted.httpOnly, value: tag, url: `${origin}/`, httpOnly: true, path: '/' },
|
|
112
|
+
],
|
|
113
|
+
['open', { name: planted.open, value: tag, url: `${origin}/`, httpOnly: false, path: '/' }],
|
|
114
|
+
['parent-domain', { name: planted.parent, value: tag, domain: planted.parentDomain, path: '/' }],
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
async function setCookies(reader, sessionId, list) {
|
|
118
|
+
for (const [label, params] of list) {
|
|
119
|
+
const set = await outcome(reader.send('Network.setCookie', params, sessionId));
|
|
120
|
+
if (!set.ok || set.result?.success === false)
|
|
121
|
+
return `plant ${label} cookie failed: ${set.error?.message ?? 'no success'}`;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function plantState(reader, { origin, host, tag, sessionId }) {
|
|
127
|
+
const names = {
|
|
128
|
+
httpOnly: `cred-http-${tag}`,
|
|
129
|
+
open: `cred-open-${tag}`,
|
|
130
|
+
parent: `cred-parent-${tag}`,
|
|
131
|
+
parentDomain: `.${siteHost(host)}`,
|
|
132
|
+
};
|
|
133
|
+
const failed = await setCookies(reader, sessionId, credentialCookieParams(names, origin, tag));
|
|
134
|
+
if (failed) return { incomplete: failed };
|
|
135
|
+
const lsKey = `cred-ls-${tag}`;
|
|
136
|
+
const dbName = `cred-db-${tag}`;
|
|
137
|
+
const cacheName = `cred-cache-${tag}`;
|
|
138
|
+
const cacheUrl = `${origin}/cred-cache-${tag}`;
|
|
139
|
+
const q = JSON.stringify;
|
|
140
|
+
const planted = await outcome(
|
|
141
|
+
reader.send(
|
|
142
|
+
'Runtime.evaluate',
|
|
143
|
+
{
|
|
144
|
+
expression: `(async()=>{
|
|
145
|
+
const secure=self.isSecureContext===true;
|
|
146
|
+
const localStorageOk=(()=>{try{localStorage.setItem(${q(lsKey)},${q(tag)});return localStorage.getItem(${q(lsKey)})===${q(tag)};}catch(e){return 'err:'+e.message;}})();
|
|
147
|
+
const idb=await (async()=>{try{const open=indexedDB.open(${q(dbName)},1);const db=await new Promise((ok,err)=>{open.onupgradeneeded=()=>open.result.createObjectStore('s');open.onsuccess=()=>ok(open.result);open.onerror=()=>err(open.error);});const tx=db.transaction('s','readwrite');tx.objectStore('s').put(${q(tag)},'k');await new Promise((ok,err)=>{tx.oncomplete=()=>ok(true);tx.onerror=()=>err(tx.error);tx.onabort=()=>err(tx.error);});db.close();return true;}catch(e){return 'err:'+e.message;}})();
|
|
148
|
+
const cache=await (async()=>{if(!secure)return 'insecure-context';try{const c=await caches.open(${q(cacheName)});await c.put(${q(cacheUrl)},new Response(${q(tag)}));const m=await c.match(${q(cacheUrl)});return m?await m.text():false;}catch(e){return 'err:'+e.message;}})();
|
|
149
|
+
return {secure,localStorage:localStorageOk,idb,cache};
|
|
150
|
+
})()`,
|
|
151
|
+
awaitPromise: true,
|
|
152
|
+
returnByValue: true,
|
|
153
|
+
},
|
|
154
|
+
sessionId
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
const value = planted.result?.result?.value;
|
|
158
|
+
if (!planted.ok || !value || value.localStorage !== true || value.idb !== true)
|
|
159
|
+
return {
|
|
160
|
+
incomplete: `plant storage failed: ${planted.error?.message ?? JSON.stringify(value)}`,
|
|
161
|
+
};
|
|
162
|
+
const secure = value.secure === true;
|
|
163
|
+
const cachePlanted = secure && value.cache === tag;
|
|
164
|
+
if (secure && !cachePlanted)
|
|
165
|
+
return {
|
|
166
|
+
incomplete: `plant cache failed: ${typeof value.cache === 'string' ? value.cache : JSON.stringify(value.cache)}`,
|
|
167
|
+
};
|
|
168
|
+
const proved = await provePlanted(reader, sessionId, {
|
|
169
|
+
...names,
|
|
170
|
+
origin,
|
|
171
|
+
host,
|
|
172
|
+
tag,
|
|
173
|
+
lsKey,
|
|
174
|
+
dbName,
|
|
175
|
+
cacheName,
|
|
176
|
+
cachePlanted,
|
|
177
|
+
});
|
|
178
|
+
if (proved.incomplete) return proved;
|
|
179
|
+
return {
|
|
180
|
+
...names,
|
|
181
|
+
lsKey,
|
|
182
|
+
dbName,
|
|
183
|
+
secure,
|
|
184
|
+
cacheName: cachePlanted ? cacheName : null,
|
|
185
|
+
cacheUrl: cachePlanted ? cacheUrl : null,
|
|
186
|
+
cachePlanted,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function readerEntries(reader, sessions, storageId) {
|
|
191
|
+
for (const session of sessions) {
|
|
192
|
+
const read = await outcome(
|
|
193
|
+
reader.send('DOMStorage.getDOMStorageItems', { storageId }, session)
|
|
194
|
+
);
|
|
195
|
+
if (read.ok && Array.isArray(read.result?.entries)) return read.result.entries;
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async function readerDatabases(reader, sessionId, origin) {
|
|
201
|
+
const read = await outcome(
|
|
202
|
+
reader.send('IndexedDB.requestDatabaseNames', { securityOrigin: origin }, sessionId)
|
|
203
|
+
);
|
|
204
|
+
return read.ok ? (read.result?.databaseNames ?? []) : null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function readerCaches(reader, sessionId, origin) {
|
|
208
|
+
const read = await outcome(
|
|
209
|
+
reader.send('CacheStorage.requestCacheNames', { securityOrigin: origin }, sessionId)
|
|
210
|
+
);
|
|
211
|
+
return read.ok ? (read.result?.caches ?? []) : null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const cacheNameOf = (cache) => cache?.cacheName ?? cache;
|
|
215
|
+
|
|
216
|
+
const survivingCookies = (cookies, planted, host, tag) =>
|
|
217
|
+
cookieHit(cookies, { name: planted.httpOnly, host, value: tag }) &&
|
|
218
|
+
cookieHit(cookies, { name: planted.parent, host, value: tag });
|
|
219
|
+
|
|
220
|
+
async function provePlanted(reader, sessionId, planted) {
|
|
221
|
+
const { origin, host, tag, lsKey, dbName, cacheName, cachePlanted } = planted;
|
|
222
|
+
const entries = await readerEntries(reader, [sessionId], {
|
|
223
|
+
securityOrigin: origin,
|
|
224
|
+
isLocalStorage: true,
|
|
225
|
+
});
|
|
226
|
+
if (!hasEntry(entries, lsKey, tag))
|
|
227
|
+
return { incomplete: 'unguarded localStorage not readable after plant' };
|
|
228
|
+
if (!(await readerDatabases(reader, sessionId, origin))?.includes(dbName))
|
|
229
|
+
return { incomplete: 'unguarded IndexedDB not readable after plant' };
|
|
230
|
+
if (cachePlanted) {
|
|
231
|
+
const caches = await readerCaches(reader, sessionId, origin);
|
|
232
|
+
if (!caches?.map(cacheNameOf).includes(cacheName))
|
|
233
|
+
return { incomplete: 'unguarded CacheStorage not readable after plant' };
|
|
234
|
+
}
|
|
235
|
+
const all = await outcome(reader.send('Network.getAllCookies', {}, sessionId));
|
|
236
|
+
if (!all.ok)
|
|
237
|
+
return { incomplete: `unguarded getAllCookies failed: ${all.error?.message ?? 'unknown'}` };
|
|
238
|
+
const cookies = all.result?.cookies;
|
|
239
|
+
if (!cookieHit(cookies, { name: planted.httpOnly, host, value: tag }))
|
|
240
|
+
return { incomplete: 'unguarded HttpOnly cookie not readable after plant' };
|
|
241
|
+
if (!cookieHit(cookies, { name: planted.open, host, value: tag }))
|
|
242
|
+
return { incomplete: 'unguarded open cookie not readable after plant' };
|
|
243
|
+
if (!cookieHit(cookies, { name: planted.parent, host, value: tag }))
|
|
244
|
+
return { incomplete: 'unguarded parent-domain cookie not readable after plant' };
|
|
245
|
+
return {};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function readerCookies(reader, sessionId) {
|
|
249
|
+
const browser = await outcome(reader.send('Storage.getCookies', {}));
|
|
250
|
+
const network = await outcome(reader.send('Network.getAllCookies', {}, sessionId));
|
|
251
|
+
return [...(browser.result?.cookies ?? []), ...(network.result?.cookies ?? [])];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async function plantPartitionedCookie(reader, sessionId, { url, name, tag, site }) {
|
|
255
|
+
const base = { name, value: tag, url, path: '/', secure: true, sameSite: 'None' };
|
|
256
|
+
for (const partitionKey of [
|
|
257
|
+
{ topLevelSite: site, hasCrossSiteAncestor: true },
|
|
258
|
+
{ topLevelSite: site, hasCrossSiteAncestor: false },
|
|
259
|
+
site,
|
|
260
|
+
]) {
|
|
261
|
+
await outcome(reader.send('Network.setCookie', { ...base, partitionKey }, sessionId));
|
|
262
|
+
const cookies = await readerCookies(reader, sessionId);
|
|
263
|
+
if (
|
|
264
|
+
cookies.some(
|
|
265
|
+
(cookie) => cookie?.name === name && cookie.value === tag && partitionedUnder(cookie, site)
|
|
266
|
+
)
|
|
267
|
+
)
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async function plantPartitionedCookies(reader, sessionId, { ordinaryOrigin, host, tag }) {
|
|
274
|
+
const credentialSite = `https://${siteHost(host)}`;
|
|
275
|
+
const partitionedCredential = `cred-part-cookie-${tag}`;
|
|
276
|
+
const partitionedAdobeCom = `adobecom-part-cookie-${tag}`;
|
|
277
|
+
const url = `${ordinaryOrigin}/`;
|
|
278
|
+
return {
|
|
279
|
+
partitionedCredential,
|
|
280
|
+
partitionedCredentialSite: credentialSite,
|
|
281
|
+
partitionedCredentialProven: await plantPartitionedCookie(reader, sessionId, {
|
|
282
|
+
url,
|
|
283
|
+
name: partitionedCredential,
|
|
284
|
+
tag,
|
|
285
|
+
site: credentialSite,
|
|
286
|
+
}),
|
|
287
|
+
partitionedAdobeCom,
|
|
288
|
+
partitionedAdobeComProven: await plantPartitionedCookie(reader, sessionId, {
|
|
289
|
+
url,
|
|
290
|
+
name: partitionedAdobeCom,
|
|
291
|
+
tag,
|
|
292
|
+
site: 'https://adobe.com',
|
|
293
|
+
}),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function tryMethod(client, method, params, session) {
|
|
298
|
+
const out = await outcome(client.send(method, params, session));
|
|
299
|
+
if (unsupported(out)) return { skip: `not-supported:${method}`, out };
|
|
300
|
+
return { out };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function cookiesFrom(out) {
|
|
304
|
+
return out?.result?.cookies ?? out?.result ?? [];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function emptyCredentialResult() {
|
|
308
|
+
return {
|
|
309
|
+
live: false,
|
|
310
|
+
cookiesPlanted: false,
|
|
311
|
+
storagePlanted: false,
|
|
312
|
+
getCookiesFiltered: false,
|
|
313
|
+
getAllCookiesFiltered: false,
|
|
314
|
+
storageGetCookiesFiltered: false,
|
|
315
|
+
pageGetCookiesFiltered: false,
|
|
316
|
+
partitionedCookieFiltered: false,
|
|
317
|
+
setCookieRefused: false,
|
|
318
|
+
setCookiesRefused: false,
|
|
319
|
+
deleteCookiesRefused: false,
|
|
320
|
+
pageDeleteCookieRefused: false,
|
|
321
|
+
storageSetCookiesRefused: false,
|
|
322
|
+
clearBrowserCookiesSurvived: false,
|
|
323
|
+
storageClearCookiesSurvived: false,
|
|
324
|
+
clearDataForOriginSurvived: false,
|
|
325
|
+
headersStripped: false,
|
|
326
|
+
associatedCookiesStripped: false,
|
|
327
|
+
domStorageRefused: false,
|
|
328
|
+
domStorageSetRefused: false,
|
|
329
|
+
domStorageRemoveRefused: false,
|
|
330
|
+
indexedDBRefused: false,
|
|
331
|
+
indexedDBDeleteRefused: false,
|
|
332
|
+
cacheStorageRefused: false,
|
|
333
|
+
cacheStorageDeleteRefused: false,
|
|
334
|
+
ordinaryCookiesExportable: false,
|
|
335
|
+
adobeComCookiesExportable: false,
|
|
336
|
+
adobeComPartitionedCookieExportable: false,
|
|
337
|
+
partitionedStorageKeyFiltered: false,
|
|
338
|
+
adobeComStorageKeyExportable: false,
|
|
339
|
+
pageDrivable: false,
|
|
340
|
+
evaluateOk: false,
|
|
341
|
+
subHostNotCredential: false,
|
|
342
|
+
residualEvaluateCookie: false,
|
|
343
|
+
skips: [],
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function unmeasurable(ctx, key, reason, controlWants = false) {
|
|
348
|
+
if (ctx.control && !controlWants) {
|
|
349
|
+
ctx.result[key] = false;
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
ctx.result[key] = 'incomplete';
|
|
353
|
+
ctx.result.skips.push(`${key}: ${reason}`);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async function measureDrivability(ctx) {
|
|
357
|
+
const { client, clientSession, planted, tag, result, note } = ctx;
|
|
358
|
+
await outcome(client.send('Page.enable', {}, clientSession));
|
|
359
|
+
await outcome(client.send('Runtime.enable', {}, clientSession));
|
|
360
|
+
await outcome(client.send('Network.enable', {}, clientSession));
|
|
361
|
+
const evalOk = await outcome(
|
|
362
|
+
client.send(
|
|
363
|
+
'Runtime.evaluate',
|
|
364
|
+
{
|
|
365
|
+
expression: `(() => { const i=document.querySelector('input'); const b=document.querySelector('button'); if(i){i.value=${JSON.stringify(tag)}; i.dispatchEvent(new Event('input',{bubbles:true}));} if(b) b.click(); return document.title; })()`,
|
|
366
|
+
returnByValue: true,
|
|
367
|
+
},
|
|
368
|
+
clientSession
|
|
369
|
+
)
|
|
370
|
+
);
|
|
371
|
+
result.evaluateOk = evalOk.ok && typeof evalOk.result?.result?.value === 'string';
|
|
372
|
+
result.pageDrivable = result.evaluateOk && !refused(evalOk);
|
|
373
|
+
const residual = await outcome(
|
|
374
|
+
client.send(
|
|
375
|
+
'Runtime.evaluate',
|
|
376
|
+
{
|
|
377
|
+
expression: `({cookie:document.cookie,ls:(()=>{try{return localStorage.getItem(${JSON.stringify(planted.lsKey)});}catch(e){return null;}})()})`,
|
|
378
|
+
returnByValue: true,
|
|
379
|
+
},
|
|
380
|
+
clientSession
|
|
381
|
+
)
|
|
382
|
+
);
|
|
383
|
+
const residualValue = residual.result?.result?.value;
|
|
384
|
+
result.residualEvaluateCookie =
|
|
385
|
+
residual.ok &&
|
|
386
|
+
typeof residualValue?.cookie === 'string' &&
|
|
387
|
+
residualValue.cookie.includes(planted.open);
|
|
388
|
+
note('drive', {
|
|
389
|
+
evaluateOk: result.evaluateOk,
|
|
390
|
+
pageDrivable: result.pageDrivable,
|
|
391
|
+
residualEvaluateCookie: result.residualEvaluateCookie,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function credentialCookieLeaked(cookies, planted, host) {
|
|
396
|
+
return (
|
|
397
|
+
cookieHit(cookies, { name: planted.httpOnly, host }) ||
|
|
398
|
+
cookieHit(cookies, { name: planted.open, host }) ||
|
|
399
|
+
cookieHit(cookies, { name: planted.parent, host }) ||
|
|
400
|
+
(planted.partitionedCredentialProven === true &&
|
|
401
|
+
cookieHit(cookies, { name: planted.partitionedCredential }))
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
async function measureHeaders(ctx) {
|
|
406
|
+
const { client, clientSession, origin, host, tag, planted, until, result } = ctx;
|
|
407
|
+
const start = client.events?.length ?? 0;
|
|
408
|
+
await outcome(
|
|
409
|
+
client.send(
|
|
410
|
+
'Page.navigate',
|
|
411
|
+
{ url: `${origin}/credential?n=${encodeURIComponent(tag)}&reload=1` },
|
|
412
|
+
clientSession
|
|
413
|
+
)
|
|
414
|
+
);
|
|
415
|
+
await until(async () => {
|
|
416
|
+
const slice = (client.events ?? []).slice(start);
|
|
417
|
+
return slice.some(
|
|
418
|
+
(event) =>
|
|
419
|
+
event.sessionId === clientSession &&
|
|
420
|
+
(event.method === 'Network.responseReceivedExtraInfo' ||
|
|
421
|
+
event.method === 'Network.requestWillBeSentExtraInfo')
|
|
422
|
+
);
|
|
423
|
+
});
|
|
424
|
+
const events = (client.events ?? [])
|
|
425
|
+
.slice(start)
|
|
426
|
+
.filter((event) => event.sessionId === clientSession);
|
|
427
|
+
const headerLeak = events.some((event) => {
|
|
428
|
+
const headers = event.params?.headers;
|
|
429
|
+
if (headers && typeof headers === 'object') {
|
|
430
|
+
const names = Object.keys(headers).map((name) => name.toLowerCase());
|
|
431
|
+
if (names.includes('cookie') || names.includes('set-cookie')) return true;
|
|
432
|
+
}
|
|
433
|
+
const text = event.params?.headersText;
|
|
434
|
+
return typeof text === 'string' && /^(cookie|set-cookie)\s*:/im.test(text);
|
|
435
|
+
});
|
|
436
|
+
const associatedLeak = events.some((event) =>
|
|
437
|
+
(event.params?.associatedCookies ?? []).some((entry) =>
|
|
438
|
+
credentialCookieLeaked([entry.cookie ?? entry], planted, host)
|
|
439
|
+
)
|
|
440
|
+
);
|
|
441
|
+
const sawExtra = events.some((event) =>
|
|
442
|
+
['Network.responseReceivedExtraInfo', 'Network.requestWillBeSentExtraInfo'].includes(
|
|
443
|
+
event.method
|
|
444
|
+
)
|
|
445
|
+
);
|
|
446
|
+
if (!sawExtra) {
|
|
447
|
+
unmeasurable(ctx, 'headersStripped', 'Network ExtraInfo events not seen');
|
|
448
|
+
unmeasurable(ctx, 'associatedCookiesStripped', 'Network ExtraInfo events not seen');
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
result.headersStripped = !headerLeak;
|
|
452
|
+
result.associatedCookiesStripped = !associatedLeak;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function applyFilteredCookieRead(ctx, key, out) {
|
|
456
|
+
const { result, planted, host } = ctx;
|
|
457
|
+
const cookies = cookiesFrom(out);
|
|
458
|
+
if (refused(out)) result[key] = true;
|
|
459
|
+
else if (out.ok) result[key] = !credentialCookieLeaked(cookies, planted, host);
|
|
460
|
+
else result[key] = false;
|
|
461
|
+
return out.ok ? cookies : [];
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function storageRefused(out, leaked) {
|
|
465
|
+
if (refused(out)) return true;
|
|
466
|
+
if (!out.ok) return false;
|
|
467
|
+
return !leaked;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async function measureCookieReads(ctx) {
|
|
471
|
+
const {
|
|
472
|
+
client,
|
|
473
|
+
clientSession,
|
|
474
|
+
origin,
|
|
475
|
+
ordinaryOrigin,
|
|
476
|
+
ordinaryHost,
|
|
477
|
+
ordinaryCookie,
|
|
478
|
+
adobeComCookie,
|
|
479
|
+
tag,
|
|
480
|
+
planted,
|
|
481
|
+
refusalPrefix,
|
|
482
|
+
result,
|
|
483
|
+
note,
|
|
484
|
+
} = ctx;
|
|
485
|
+
const seen = { measured: 0, credential: false, adobeCom: false };
|
|
486
|
+
const track = (cookies) => {
|
|
487
|
+
seen.measured += 1;
|
|
488
|
+
if (
|
|
489
|
+
planted.partitionedCredentialProven &&
|
|
490
|
+
cookieHit(cookies, { name: planted.partitionedCredential })
|
|
491
|
+
)
|
|
492
|
+
seen.credential = true;
|
|
493
|
+
if (
|
|
494
|
+
planted.partitionedAdobeComProven &&
|
|
495
|
+
cookieHit(cookies, { name: planted.partitionedAdobeCom, value: tag })
|
|
496
|
+
)
|
|
497
|
+
seen.adobeCom = true;
|
|
498
|
+
};
|
|
499
|
+
const markControls = (cookies) => {
|
|
500
|
+
track(cookies);
|
|
501
|
+
if (cookieHit(cookies, { name: ordinaryCookie, host: ordinaryHost, value: tag }))
|
|
502
|
+
result.ordinaryCookiesExportable = true;
|
|
503
|
+
if (cookieHit(cookies, { name: adobeComCookie, host: 'adobe.com', value: tag }))
|
|
504
|
+
result.adobeComCookiesExportable = true;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
const getCookies = await tryMethod(
|
|
508
|
+
client,
|
|
509
|
+
'Network.getCookies',
|
|
510
|
+
{ urls: [`${origin}/`, `${ordinaryOrigin}/`, 'https://www.adobe.com/'] },
|
|
511
|
+
clientSession
|
|
512
|
+
);
|
|
513
|
+
if (getCookies.skip) result.skips.push(getCookies.skip);
|
|
514
|
+
else {
|
|
515
|
+
markControls(applyFilteredCookieRead(ctx, 'getCookiesFiltered', getCookies.out));
|
|
516
|
+
if (
|
|
517
|
+
refused(getCookies.out) &&
|
|
518
|
+
!String(getCookies.out.error?.message ?? '').startsWith(refusalPrefix)
|
|
519
|
+
)
|
|
520
|
+
note('getCookies-refusal', getCookies.out.error?.message);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const getAll = await tryMethod(client, 'Network.getAllCookies', {}, clientSession);
|
|
524
|
+
if (getAll.skip) result.skips.push(getAll.skip);
|
|
525
|
+
else markControls(applyFilteredCookieRead(ctx, 'getAllCookiesFiltered', getAll.out));
|
|
526
|
+
|
|
527
|
+
const storageGet = await tryMethod(client, 'Storage.getCookies', {}, undefined);
|
|
528
|
+
if (storageGet.skip) result.skips.push(storageGet.skip);
|
|
529
|
+
else markControls(applyFilteredCookieRead(ctx, 'storageGetCookiesFiltered', storageGet.out));
|
|
530
|
+
|
|
531
|
+
const pageGet = await tryMethod(client, 'Page.getCookies', {}, clientSession);
|
|
532
|
+
if (pageGet.skip) result.skips.push(pageGet.skip);
|
|
533
|
+
else track(applyFilteredCookieRead(ctx, 'pageGetCookiesFiltered', pageGet.out));
|
|
534
|
+
|
|
535
|
+
if (!result.ordinaryCookiesExportable) {
|
|
536
|
+
const plainOnly = await tryMethod(
|
|
537
|
+
client,
|
|
538
|
+
'Network.getCookies',
|
|
539
|
+
{ urls: [`${ordinaryOrigin}/`] },
|
|
540
|
+
clientSession
|
|
541
|
+
);
|
|
542
|
+
if (!plainOnly.skip && plainOnly.out.ok) markControls(cookiesFrom(plainOnly.out));
|
|
543
|
+
}
|
|
544
|
+
if (!result.adobeComCookiesExportable) {
|
|
545
|
+
const adobeOnly = await tryMethod(
|
|
546
|
+
client,
|
|
547
|
+
'Network.getCookies',
|
|
548
|
+
{ urls: ['https://www.adobe.com/'] },
|
|
549
|
+
clientSession
|
|
550
|
+
);
|
|
551
|
+
if (!adobeOnly.skip && adobeOnly.out.ok) markControls(cookiesFrom(adobeOnly.out));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (!planted.partitionedCredentialProven)
|
|
555
|
+
unmeasurable(
|
|
556
|
+
ctx,
|
|
557
|
+
'partitionedCookieFiltered',
|
|
558
|
+
'cookie partitioned under the credential site not readable on raw leg'
|
|
559
|
+
);
|
|
560
|
+
else if (!seen.measured)
|
|
561
|
+
unmeasurable(ctx, 'partitionedCookieFiltered', 'no cookie read was supported');
|
|
562
|
+
else result.partitionedCookieFiltered = !seen.credential;
|
|
563
|
+
|
|
564
|
+
if (!planted.partitionedAdobeComProven)
|
|
565
|
+
unmeasurable(
|
|
566
|
+
ctx,
|
|
567
|
+
'adobeComPartitionedCookieExportable',
|
|
568
|
+
'cookie partitioned under adobe.com not readable on raw leg',
|
|
569
|
+
true
|
|
570
|
+
);
|
|
571
|
+
else result.adobeComPartitionedCookieExportable = seen.adobeCom;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
async function measureCookieWrites(ctx) {
|
|
575
|
+
const { client, clientSession, origin, tag, planted, result } = ctx;
|
|
576
|
+
const setCookie = await tryMethod(
|
|
577
|
+
client,
|
|
578
|
+
'Network.setCookie',
|
|
579
|
+
{ name: `probe-${tag}`, value: 'x', url: `${origin}/`, path: '/' },
|
|
580
|
+
clientSession
|
|
581
|
+
);
|
|
582
|
+
if (setCookie.skip) result.skips.push(setCookie.skip);
|
|
583
|
+
else result.setCookieRefused = refused(setCookie.out) || setCookie.out.result?.success === false;
|
|
584
|
+
|
|
585
|
+
const setCookies = await tryMethod(
|
|
586
|
+
client,
|
|
587
|
+
'Network.setCookies',
|
|
588
|
+
{ cookies: [{ name: `probe2-${tag}`, value: 'x', url: `${origin}/`, path: '/' }] },
|
|
589
|
+
clientSession
|
|
590
|
+
);
|
|
591
|
+
if (setCookies.skip) result.skips.push(setCookies.skip);
|
|
592
|
+
else result.setCookiesRefused = refused(setCookies.out);
|
|
593
|
+
|
|
594
|
+
const del = await tryMethod(
|
|
595
|
+
client,
|
|
596
|
+
'Network.deleteCookies',
|
|
597
|
+
{ name: planted.open, url: `${origin}/` },
|
|
598
|
+
clientSession
|
|
599
|
+
);
|
|
600
|
+
const delParent = await tryMethod(
|
|
601
|
+
client,
|
|
602
|
+
'Network.deleteCookies',
|
|
603
|
+
{ name: planted.parent, domain: planted.parentDomain, path: '/' },
|
|
604
|
+
clientSession
|
|
605
|
+
);
|
|
606
|
+
if (del.skip || delParent.skip) result.skips.push(del.skip ?? delParent.skip);
|
|
607
|
+
else result.deleteCookiesRefused = refused(del.out) && refused(delParent.out);
|
|
608
|
+
|
|
609
|
+
const pageDel = await tryMethod(
|
|
610
|
+
client,
|
|
611
|
+
'Page.deleteCookie',
|
|
612
|
+
{ cookieName: planted.open, url: `${origin}/` },
|
|
613
|
+
clientSession
|
|
614
|
+
);
|
|
615
|
+
if (pageDel.skip) result.skips.push(pageDel.skip);
|
|
616
|
+
else result.pageDeleteCookieRefused = refused(pageDel.out);
|
|
617
|
+
|
|
618
|
+
const storageSet = await tryMethod(
|
|
619
|
+
client,
|
|
620
|
+
'Storage.setCookies',
|
|
621
|
+
{ cookies: [{ name: `probe3-${tag}`, value: 'x', url: `${origin}/`, path: '/' }] },
|
|
622
|
+
undefined
|
|
623
|
+
);
|
|
624
|
+
if (storageSet.skip) result.skips.push(storageSet.skip);
|
|
625
|
+
else result.storageSetCookiesRefused = refused(storageSet.out);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
async function measureStorageReads(ctx) {
|
|
629
|
+
const { client, clientSession, origin, planted, result } = ctx;
|
|
630
|
+
const dom = await tryMethod(
|
|
631
|
+
client,
|
|
632
|
+
'DOMStorage.getDOMStorageItems',
|
|
633
|
+
{ storageId: { securityOrigin: origin, isLocalStorage: true } },
|
|
634
|
+
clientSession
|
|
635
|
+
);
|
|
636
|
+
if (dom.skip) result.skips.push(dom.skip);
|
|
637
|
+
else
|
|
638
|
+
result.domStorageRefused = storageRefused(
|
|
639
|
+
dom.out,
|
|
640
|
+
hasEntry(dom.out.result?.entries, planted.lsKey)
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
const idbNames = await tryMethod(
|
|
644
|
+
client,
|
|
645
|
+
'IndexedDB.requestDatabaseNames',
|
|
646
|
+
{ securityOrigin: origin },
|
|
647
|
+
clientSession
|
|
648
|
+
);
|
|
649
|
+
if (idbNames.skip) result.skips.push(idbNames.skip);
|
|
650
|
+
else {
|
|
651
|
+
const names = idbNames.out.result?.databaseNames ?? [];
|
|
652
|
+
result.indexedDBRefused = storageRefused(idbNames.out, names.includes(planted.dbName));
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (!planted.cachePlanted) {
|
|
656
|
+
unmeasurable(
|
|
657
|
+
ctx,
|
|
658
|
+
'cacheStorageRefused',
|
|
659
|
+
'Cache API plant unavailable (secure context required)'
|
|
660
|
+
);
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
const caches = await tryMethod(
|
|
664
|
+
client,
|
|
665
|
+
'CacheStorage.requestCacheNames',
|
|
666
|
+
{ securityOrigin: origin },
|
|
667
|
+
clientSession
|
|
668
|
+
);
|
|
669
|
+
if (caches.skip) unmeasurable(ctx, 'cacheStorageRefused', caches.skip);
|
|
670
|
+
else {
|
|
671
|
+
const names = (caches.out.result?.caches ?? []).map(cacheNameOf);
|
|
672
|
+
result.cacheStorageRefused = storageRefused(caches.out, names.includes(planted.cacheName));
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
async function frameSession(ctx, targetId) {
|
|
677
|
+
ctx.frameSessions ??= new Map();
|
|
678
|
+
if (ctx.frameSessions.has(targetId)) return ctx.frameSessions.get(targetId);
|
|
679
|
+
const attach = await outcome(
|
|
680
|
+
ctx.client.send('Target.attachToTarget', { targetId, flatten: true })
|
|
681
|
+
);
|
|
682
|
+
const entry = refused(attach)
|
|
683
|
+
? { refused: true, out: attach }
|
|
684
|
+
: { id: attach.result?.sessionId ?? null };
|
|
685
|
+
if (entry.id) ctx.internalSessions.add(entry.id);
|
|
686
|
+
ctx.frameSessions.set(targetId, entry);
|
|
687
|
+
return entry;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
async function partitionSend(ctx, frameTarget, method, params) {
|
|
691
|
+
const first = await tryMethod(ctx.client, method, params, ctx.clientSession);
|
|
692
|
+
if (first.skip || first.out.ok || refused(first.out) || !frameTarget) return first;
|
|
693
|
+
const session = await frameSession(ctx, frameTarget);
|
|
694
|
+
if (session.refused) return { out: session.out };
|
|
695
|
+
if (!session.id) return first;
|
|
696
|
+
return tryMethod(ctx.client, method, params, session.id);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
async function measurePartitionedStorageKeys(ctx) {
|
|
700
|
+
const { tag, planted, result } = ctx;
|
|
701
|
+
const lsKey = planted.partitionedKey;
|
|
702
|
+
const read = (storageKey, frameTarget) =>
|
|
703
|
+
partitionSend(ctx, frameTarget, 'DOMStorage.getDOMStorageItems', {
|
|
704
|
+
storageId: { storageKey, isLocalStorage: true },
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
if (!planted.adobeloginPartitionProven)
|
|
708
|
+
unmeasurable(
|
|
709
|
+
ctx,
|
|
710
|
+
'partitionedStorageKeyFiltered',
|
|
711
|
+
'partitioned storageKey plant not readable on raw leg'
|
|
712
|
+
);
|
|
713
|
+
else {
|
|
714
|
+
const adobelogin = await read(planted.adobeloginStorageKey, planted.adobeloginFrameTarget);
|
|
715
|
+
if (adobelogin.skip) unmeasurable(ctx, 'partitionedStorageKeyFiltered', adobelogin.skip);
|
|
716
|
+
else
|
|
717
|
+
result.partitionedStorageKeyFiltered = storageRefused(
|
|
718
|
+
adobelogin.out,
|
|
719
|
+
hasEntry(adobelogin.out.result?.entries, lsKey)
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (!planted.adobeComPartitionProven)
|
|
724
|
+
unmeasurable(
|
|
725
|
+
ctx,
|
|
726
|
+
'adobeComStorageKeyExportable',
|
|
727
|
+
'adobe.com partitioned storageKey plant not readable on raw leg',
|
|
728
|
+
true
|
|
729
|
+
);
|
|
730
|
+
else {
|
|
731
|
+
const adobeCom = await read(planted.adobeComStorageKey, planted.adobeComFrameTarget);
|
|
732
|
+
if (adobeCom.skip) unmeasurable(ctx, 'adobeComStorageKeyExportable', adobeCom.skip, true);
|
|
733
|
+
else
|
|
734
|
+
result.adobeComStorageKeyExportable =
|
|
735
|
+
adobeCom.out.ok && hasEntry(adobeCom.out.result?.entries, lsKey, tag);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
async function measureSubHost(ctx) {
|
|
740
|
+
const { client, clientSession, origin, host, tag, result } = ctx;
|
|
741
|
+
const base = parseURL(origin);
|
|
742
|
+
if (!base) return;
|
|
743
|
+
const subHost = `x.${host}`;
|
|
744
|
+
const subOrigin = `${base.protocol}//${subHost}${base.port ? `:${base.port}` : ''}`;
|
|
745
|
+
const name = `sub-${tag}`;
|
|
746
|
+
const set = await tryMethod(
|
|
747
|
+
client,
|
|
748
|
+
'Network.setCookie',
|
|
749
|
+
{ name, value: tag, url: `${subOrigin}/`, path: '/' },
|
|
750
|
+
clientSession
|
|
751
|
+
);
|
|
752
|
+
if (set.skip) {
|
|
753
|
+
result.skips.push(set.skip);
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (refused(set.out)) return;
|
|
757
|
+
const get = await tryMethod(
|
|
758
|
+
client,
|
|
759
|
+
'Network.getCookies',
|
|
760
|
+
{ urls: [`${subOrigin}/`] },
|
|
761
|
+
clientSession
|
|
762
|
+
);
|
|
763
|
+
if (get.skip) {
|
|
764
|
+
result.skips.push(get.skip);
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
if (refused(get.out) || !get.out.ok) return;
|
|
768
|
+
result.subHostNotCredential = cookieHit(cookiesFrom(get.out), {
|
|
769
|
+
name,
|
|
770
|
+
host: subHost,
|
|
771
|
+
value: tag,
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
async function mutationRefused(attempt, unchanged) {
|
|
776
|
+
if (refused(attempt.out)) return true;
|
|
777
|
+
if (!attempt.out.ok) return false;
|
|
778
|
+
return (await unchanged()) === true;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
async function measureDomStorageMutations(ctx) {
|
|
782
|
+
const { client, clientSession, reader, readerSession, origin, tag, planted, result } = ctx;
|
|
783
|
+
const originId = { securityOrigin: origin, isLocalStorage: true };
|
|
784
|
+
const probeKey = `cred-probe-${tag}`;
|
|
785
|
+
const originEntries = () => readerEntries(reader, [readerSession], originId);
|
|
786
|
+
const partitioned = planted.adobeloginPartitionProven
|
|
787
|
+
? {
|
|
788
|
+
storageId: { storageKey: planted.adobeloginStorageKey, isLocalStorage: true },
|
|
789
|
+
frameTarget: planted.adobeloginFrameTarget,
|
|
790
|
+
entries: () =>
|
|
791
|
+
readerEntries(reader, planted.adobeloginReadSessions ?? [undefined], {
|
|
792
|
+
storageKey: planted.adobeloginStorageKey,
|
|
793
|
+
isLocalStorage: true,
|
|
794
|
+
}),
|
|
795
|
+
}
|
|
796
|
+
: null;
|
|
797
|
+
if (!partitioned)
|
|
798
|
+
result.skips.push('domStorageSetRefused: partitioned credential storageKey not proven');
|
|
799
|
+
|
|
800
|
+
const originSet = await tryMethod(
|
|
801
|
+
client,
|
|
802
|
+
'DOMStorage.setDOMStorageItem',
|
|
803
|
+
{ storageId: originId, key: probeKey, value: tag },
|
|
804
|
+
clientSession
|
|
805
|
+
);
|
|
806
|
+
if (originSet.skip) unmeasurable(ctx, 'domStorageSetRefused', originSet.skip);
|
|
807
|
+
else {
|
|
808
|
+
let setRefused = await mutationRefused(originSet, async () => {
|
|
809
|
+
const entries = await originEntries();
|
|
810
|
+
return entries !== null && !hasEntry(entries, probeKey);
|
|
811
|
+
});
|
|
812
|
+
if (setRefused && partitioned) {
|
|
813
|
+
const keySet = await partitionSend(
|
|
814
|
+
ctx,
|
|
815
|
+
partitioned.frameTarget,
|
|
816
|
+
'DOMStorage.setDOMStorageItem',
|
|
817
|
+
{
|
|
818
|
+
storageId: partitioned.storageId,
|
|
819
|
+
key: probeKey,
|
|
820
|
+
value: tag,
|
|
821
|
+
}
|
|
822
|
+
);
|
|
823
|
+
setRefused =
|
|
824
|
+
!keySet.skip &&
|
|
825
|
+
(await mutationRefused(keySet, async () => {
|
|
826
|
+
const entries = await partitioned.entries();
|
|
827
|
+
return entries !== null && !hasEntry(entries, probeKey);
|
|
828
|
+
}));
|
|
829
|
+
}
|
|
830
|
+
result.domStorageSetRefused = setRefused;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
const originRemove = await tryMethod(
|
|
834
|
+
client,
|
|
835
|
+
'DOMStorage.removeDOMStorageItem',
|
|
836
|
+
{ storageId: originId, key: planted.lsKey },
|
|
837
|
+
clientSession
|
|
838
|
+
);
|
|
839
|
+
if (originRemove.skip) unmeasurable(ctx, 'domStorageRemoveRefused', originRemove.skip);
|
|
840
|
+
else {
|
|
841
|
+
let removeRefused = await mutationRefused(originRemove, async () =>
|
|
842
|
+
hasEntry(await originEntries(), planted.lsKey, tag)
|
|
843
|
+
);
|
|
844
|
+
if (removeRefused && partitioned) {
|
|
845
|
+
const keyRemove = await partitionSend(
|
|
846
|
+
ctx,
|
|
847
|
+
partitioned.frameTarget,
|
|
848
|
+
'DOMStorage.removeDOMStorageItem',
|
|
849
|
+
{ storageId: partitioned.storageId, key: planted.partitionedKey }
|
|
850
|
+
);
|
|
851
|
+
removeRefused =
|
|
852
|
+
!keyRemove.skip &&
|
|
853
|
+
(await mutationRefused(keyRemove, async () =>
|
|
854
|
+
hasEntry(await partitioned.entries(), planted.partitionedKey, tag)
|
|
855
|
+
));
|
|
856
|
+
}
|
|
857
|
+
result.domStorageRemoveRefused = removeRefused;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
async function measureStorageMutations(ctx) {
|
|
862
|
+
const { client, clientSession, reader, readerSession, origin, planted, result } = ctx;
|
|
863
|
+
await measureDomStorageMutations(ctx);
|
|
864
|
+
|
|
865
|
+
const idbDelete = await tryMethod(
|
|
866
|
+
client,
|
|
867
|
+
'IndexedDB.deleteDatabase',
|
|
868
|
+
{ securityOrigin: origin, databaseName: planted.dbName },
|
|
869
|
+
clientSession
|
|
870
|
+
);
|
|
871
|
+
if (idbDelete.skip) unmeasurable(ctx, 'indexedDBDeleteRefused', idbDelete.skip);
|
|
872
|
+
else
|
|
873
|
+
result.indexedDBDeleteRefused = await mutationRefused(idbDelete, async () =>
|
|
874
|
+
(await readerDatabases(reader, readerSession, origin))?.includes(planted.dbName)
|
|
875
|
+
);
|
|
876
|
+
|
|
877
|
+
if (!planted.cachePlanted) {
|
|
878
|
+
unmeasurable(
|
|
879
|
+
ctx,
|
|
880
|
+
'cacheStorageDeleteRefused',
|
|
881
|
+
'Cache API plant unavailable (secure context required)'
|
|
882
|
+
);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
const listed = await readerCaches(reader, readerSession, origin);
|
|
886
|
+
const cacheId = listed?.find((cache) => cacheNameOf(cache) === planted.cacheName)?.cacheId;
|
|
887
|
+
if (!cacheId) {
|
|
888
|
+
unmeasurable(ctx, 'cacheStorageDeleteRefused', 'planted cache has no cacheId on raw leg');
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
const cacheDelete = await tryMethod(
|
|
892
|
+
client,
|
|
893
|
+
'CacheStorage.deleteCache',
|
|
894
|
+
{ cacheId },
|
|
895
|
+
clientSession
|
|
896
|
+
);
|
|
897
|
+
if (cacheDelete.skip) unmeasurable(ctx, 'cacheStorageDeleteRefused', cacheDelete.skip);
|
|
898
|
+
else
|
|
899
|
+
result.cacheStorageDeleteRefused = await mutationRefused(cacheDelete, async () =>
|
|
900
|
+
(await readerCaches(reader, readerSession, origin))
|
|
901
|
+
?.map(cacheNameOf)
|
|
902
|
+
.includes(planted.cacheName)
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
async function measureGlobalClears(ctx) {
|
|
907
|
+
const { client, clientSession, reader, readerSession, origin, host, tag, planted, result } = ctx;
|
|
908
|
+
for (const [key, method, session] of [
|
|
909
|
+
['clearBrowserCookiesSurvived', 'Network.clearBrowserCookies', clientSession],
|
|
910
|
+
['storageClearCookiesSurvived', 'Storage.clearCookies', undefined],
|
|
911
|
+
]) {
|
|
912
|
+
const replanted = await setCookies(
|
|
913
|
+
reader,
|
|
914
|
+
readerSession,
|
|
915
|
+
credentialCookieParams(planted, origin, tag).filter(([label]) => label !== 'open')
|
|
916
|
+
);
|
|
917
|
+
if (replanted) {
|
|
918
|
+
unmeasurable(ctx, key, `re-plant before clear: ${replanted}`);
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
const cleared = await tryMethod(client, method, {}, session);
|
|
922
|
+
if (cleared.skip) {
|
|
923
|
+
unmeasurable(ctx, key, cleared.skip);
|
|
924
|
+
continue;
|
|
925
|
+
}
|
|
926
|
+
const all = await outcome(reader.send('Network.getAllCookies', {}, readerSession));
|
|
927
|
+
if (!all.ok) {
|
|
928
|
+
unmeasurable(ctx, key, `unguarded getAllCookies failed: ${all.error?.message ?? 'unknown'}`);
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
result[key] = survivingCookies(all.result?.cookies, planted, host, tag);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
async function measureClearDataForOrigin(ctx) {
|
|
936
|
+
const { client, reader, readerSession, origin, host, tag, planted, result } = ctx;
|
|
937
|
+
const replanted = await setCookies(
|
|
938
|
+
reader,
|
|
939
|
+
readerSession,
|
|
940
|
+
credentialCookieParams(planted, origin, tag)
|
|
941
|
+
);
|
|
942
|
+
if (replanted) {
|
|
943
|
+
unmeasurable(ctx, 'clearDataForOriginSurvived', `re-plant cookies before clear: ${replanted}`);
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
const store = await outcome(
|
|
947
|
+
reader.send(
|
|
948
|
+
'Runtime.evaluate',
|
|
949
|
+
{
|
|
950
|
+
expression: `(async()=>{try{localStorage.setItem(${JSON.stringify(planted.lsKey)},${JSON.stringify(tag)});const open=indexedDB.open(${JSON.stringify(planted.dbName)},1);const db=await new Promise((ok,err)=>{open.onupgradeneeded=()=>open.result.createObjectStore('s');open.onsuccess=()=>ok(open.result);open.onerror=()=>err(open.error);});const tx=db.transaction('s','readwrite');tx.objectStore('s').put(${JSON.stringify(tag)},'k');await new Promise((ok,err)=>{tx.oncomplete=()=>ok(true);tx.onerror=()=>err(tx.error);});db.close();return true;}catch(e){return 'err:'+e.message;}})()`,
|
|
951
|
+
awaitPromise: true,
|
|
952
|
+
returnByValue: true,
|
|
953
|
+
},
|
|
954
|
+
readerSession
|
|
955
|
+
)
|
|
956
|
+
);
|
|
957
|
+
if (!store.ok || store.result?.result?.value !== true) {
|
|
958
|
+
unmeasurable(
|
|
959
|
+
ctx,
|
|
960
|
+
'clearDataForOriginSurvived',
|
|
961
|
+
`re-plant storage before clear: ${store.error?.message ?? JSON.stringify(store.result?.result?.value)}`
|
|
962
|
+
);
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
const cleared = await tryMethod(
|
|
966
|
+
client,
|
|
967
|
+
'Storage.clearDataForOrigin',
|
|
968
|
+
{
|
|
969
|
+
origin,
|
|
970
|
+
storageTypes: 'cookies,local_storage,indexeddb,cache_storage',
|
|
971
|
+
},
|
|
972
|
+
undefined
|
|
973
|
+
);
|
|
974
|
+
if (cleared.skip) {
|
|
975
|
+
unmeasurable(ctx, 'clearDataForOriginSurvived', cleared.skip);
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
if (refused(cleared.out)) {
|
|
979
|
+
result.clearDataForOriginSurvived = true;
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const all = await outcome(reader.send('Network.getAllCookies', {}, readerSession));
|
|
983
|
+
const cookiesOk = all.ok && survivingCookies(all.result?.cookies, planted, host, tag);
|
|
984
|
+
const lsOk = hasEntry(
|
|
985
|
+
await readerEntries(reader, [readerSession], {
|
|
986
|
+
securityOrigin: origin,
|
|
987
|
+
isLocalStorage: true,
|
|
988
|
+
}),
|
|
989
|
+
planted.lsKey
|
|
990
|
+
);
|
|
991
|
+
const idbOk = (await readerDatabases(reader, readerSession, origin))?.includes(planted.dbName);
|
|
992
|
+
result.clearDataForOriginSurvived = Boolean(cookiesOk && lsOk && idbOk);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
async function readPartitionedKey(reader, sessions, storageKey, lsKey, tag) {
|
|
996
|
+
return hasEntry(
|
|
997
|
+
await readerEntries(reader, sessions, { storageKey, isLocalStorage: true }),
|
|
998
|
+
lsKey,
|
|
999
|
+
tag
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
async function plantLocalStorage(reader, sessionId, lsKey, tag, contextId) {
|
|
1004
|
+
const set = await outcome(
|
|
1005
|
+
reader.send(
|
|
1006
|
+
'Runtime.evaluate',
|
|
1007
|
+
{
|
|
1008
|
+
expression: `(()=>{try{localStorage.setItem(${JSON.stringify(lsKey)},${JSON.stringify(tag)});return localStorage.getItem(${JSON.stringify(lsKey)})===${JSON.stringify(tag)};}catch(e){return 'err:'+e.message;}})()`,
|
|
1009
|
+
returnByValue: true,
|
|
1010
|
+
...(contextId ? { contextId } : {}),
|
|
1011
|
+
},
|
|
1012
|
+
sessionId
|
|
1013
|
+
)
|
|
1014
|
+
);
|
|
1015
|
+
return set.result?.result?.value === true;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
async function reportedStorageKey(reader, sessions, frameId) {
|
|
1019
|
+
for (const session of sessions)
|
|
1020
|
+
for (const method of ['Storage.getStorageKeyForFrame', 'Storage.getStorageKey']) {
|
|
1021
|
+
const out = await outcome(reader.send(method, { frameId }, session));
|
|
1022
|
+
if (typeof out.result?.storageKey === 'string' && out.result.storageKey)
|
|
1023
|
+
return out.result.storageKey;
|
|
1024
|
+
}
|
|
1025
|
+
return null;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
function partitionCandidates(iframeOrigin, topSite) {
|
|
1029
|
+
if (!topSite) return [];
|
|
1030
|
+
const sites = [...new Set([topSite, topSite.replace(/^http:/, 'https:')])];
|
|
1031
|
+
return sites.flatMap((site) => [
|
|
1032
|
+
`${iframeOrigin}/^0${site}^31`,
|
|
1033
|
+
`${iframeOrigin}^0${site}^31`,
|
|
1034
|
+
`${iframeOrigin}/^0${site}`,
|
|
1035
|
+
`${iframeOrigin}^0${site}`,
|
|
1036
|
+
]);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
async function iframeTarget(reader, before, topId, marker) {
|
|
1040
|
+
const matches = (info) =>
|
|
1041
|
+
info && info.targetId !== topId && typeof info.url === 'string' && info.url.includes(marker);
|
|
1042
|
+
const fromEvents = (reader.events ?? [])
|
|
1043
|
+
.slice(before)
|
|
1044
|
+
.map((event) => event.params?.targetInfo)
|
|
1045
|
+
.find(matches);
|
|
1046
|
+
if (fromEvents) return fromEvents;
|
|
1047
|
+
const listed = await outcome(reader.send('Target.getTargets', {}));
|
|
1048
|
+
return (listed.result?.targetInfos ?? []).find(matches) ?? null;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
async function plantInChildTarget(reader, target, { lsKey, tag, marker, until }) {
|
|
1052
|
+
const childAttach = await outcome(
|
|
1053
|
+
reader.send('Target.attachToTarget', { targetId: target.targetId, flatten: true })
|
|
1054
|
+
);
|
|
1055
|
+
const childSession = childAttach.result?.sessionId;
|
|
1056
|
+
if (!childSession) return { planted: false };
|
|
1057
|
+
await outcome(reader.send('Page.enable', {}, childSession));
|
|
1058
|
+
await outcome(reader.send('Runtime.enable', {}, childSession));
|
|
1059
|
+
await until(() => pageReady(reader, childSession, (value) => value.href.includes(marker)));
|
|
1060
|
+
const planted = await plantLocalStorage(reader, childSession, lsKey, tag);
|
|
1061
|
+
const tree = await outcome(reader.send('Page.getFrameTree', {}, childSession));
|
|
1062
|
+
const frameId = tree.result?.frameTree?.frame?.id ?? target.targetId;
|
|
1063
|
+
return {
|
|
1064
|
+
planted,
|
|
1065
|
+
reportedKey: await reportedStorageKey(reader, [childSession, undefined], frameId),
|
|
1066
|
+
sessions: [childSession, undefined],
|
|
1067
|
+
frameTarget: target.targetId,
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
async function plantInLocalFrame(reader, topSession, topId, frameId, { lsKey, tag }) {
|
|
1072
|
+
const world = await outcome(
|
|
1073
|
+
reader.send(
|
|
1074
|
+
'Page.createIsolatedWorld',
|
|
1075
|
+
{ frameId, worldName: `cred-part-${tag}`, grantUniveralAccess: true },
|
|
1076
|
+
topSession
|
|
1077
|
+
)
|
|
1078
|
+
);
|
|
1079
|
+
const contextId = world.result?.executionContextId;
|
|
1080
|
+
if (!contextId) return { planted: false };
|
|
1081
|
+
return {
|
|
1082
|
+
planted: await plantLocalStorage(reader, topSession, lsKey, tag, contextId),
|
|
1083
|
+
reportedKey: await reportedStorageKey(reader, [topSession, undefined], frameId),
|
|
1084
|
+
sessions: [undefined],
|
|
1085
|
+
frameTarget: topId,
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
async function plantPartitionedInTop(reader, { topUrl, iframeOrigin, lsKey, tag, until }) {
|
|
1090
|
+
await outcome(reader.send('Target.setDiscoverTargets', { discover: true }));
|
|
1091
|
+
const created = await outcome(reader.send('Target.createTarget', { url: topUrl }));
|
|
1092
|
+
const topId = created.result?.targetId;
|
|
1093
|
+
if (!topId) return { ok: false, storageKey: null, reportedKey: null };
|
|
1094
|
+
const attach = await outcome(
|
|
1095
|
+
reader.send('Target.attachToTarget', { targetId: topId, flatten: true })
|
|
1096
|
+
);
|
|
1097
|
+
const topSession = attach.result?.sessionId;
|
|
1098
|
+
if (!topSession) return { ok: false, storageKey: null, reportedKey: null, topId };
|
|
1099
|
+
await outcome(reader.send('Page.enable', {}, topSession));
|
|
1100
|
+
await outcome(reader.send('Runtime.enable', {}, topSession));
|
|
1101
|
+
const topOrigin = new URL(topUrl).origin;
|
|
1102
|
+
await until(() => pageReady(reader, topSession, (value) => value.href.startsWith(topOrigin)));
|
|
1103
|
+
const marker = `cred-frame=${encodeURIComponent(tag)}`;
|
|
1104
|
+
const src = `${iframeOrigin}/blank?${marker}`;
|
|
1105
|
+
const before = reader.events?.length ?? 0;
|
|
1106
|
+
await outcome(
|
|
1107
|
+
reader.send(
|
|
1108
|
+
'Runtime.evaluate',
|
|
1109
|
+
{
|
|
1110
|
+
expression: `(()=>{const id='cred-part-frame';let f=document.getElementById(id);if(f)f.remove();f=document.createElement('iframe');f.id=id;f.src=${JSON.stringify(src)};document.body.appendChild(f);return true;})()`,
|
|
1111
|
+
returnByValue: true,
|
|
1112
|
+
},
|
|
1113
|
+
topSession
|
|
1114
|
+
)
|
|
1115
|
+
);
|
|
1116
|
+
let found = null;
|
|
1117
|
+
await until(async () => {
|
|
1118
|
+
const target = await iframeTarget(reader, before, topId, marker);
|
|
1119
|
+
if (target) found = { target };
|
|
1120
|
+
else {
|
|
1121
|
+
const tree = await outcome(reader.send('Page.getFrameTree', {}, topSession));
|
|
1122
|
+
const child = (tree.result?.frameTree?.childFrames ?? []).find((entry) =>
|
|
1123
|
+
String(entry.frame?.url ?? '').includes(marker)
|
|
1124
|
+
);
|
|
1125
|
+
if (child?.frame?.id) found = { frameId: child.frame.id };
|
|
1126
|
+
}
|
|
1127
|
+
return found !== null;
|
|
1128
|
+
});
|
|
1129
|
+
let plant = { planted: false };
|
|
1130
|
+
if (found?.target)
|
|
1131
|
+
plant = await plantInChildTarget(reader, found.target, { lsKey, tag, marker, until });
|
|
1132
|
+
else if (found?.frameId) {
|
|
1133
|
+
plant = await plantInLocalFrame(reader, topSession, topId, found.frameId, { lsKey, tag });
|
|
1134
|
+
if (!plant.planted) {
|
|
1135
|
+
let late = null;
|
|
1136
|
+
await until(async () => {
|
|
1137
|
+
late = await iframeTarget(reader, before, topId, marker);
|
|
1138
|
+
return late !== null;
|
|
1139
|
+
});
|
|
1140
|
+
if (late) plant = await plantInChildTarget(reader, late, { lsKey, tag, marker, until });
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const reportedKey = plant.reportedKey ?? null;
|
|
1144
|
+
const fail = { ok: false, storageKey: null, reportedKey, topId };
|
|
1145
|
+
if (!plant.planted) return fail;
|
|
1146
|
+
const sessions = [...plant.sessions, topSession];
|
|
1147
|
+
const proven = { reportedKey, topId, frameTarget: plant.frameTarget, sessions };
|
|
1148
|
+
if (reportedKey && (await readPartitionedKey(reader, sessions, reportedKey, lsKey, tag)))
|
|
1149
|
+
return { ok: true, storageKey: reportedKey, ...proven };
|
|
1150
|
+
for (const storageKey of partitionCandidates(iframeOrigin, siteOf(topUrl))) {
|
|
1151
|
+
if (storageKey === reportedKey) continue;
|
|
1152
|
+
if (await readPartitionedKey(reader, sessions, storageKey, lsKey, tag))
|
|
1153
|
+
return { ok: true, storageKey, ...proven };
|
|
1154
|
+
}
|
|
1155
|
+
return fail;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
async function plantPartitionedDirect(reader, sessions, { iframeOrigin, topSite, lsKey, tag }) {
|
|
1159
|
+
for (const storageKey of partitionCandidates(iframeOrigin, topSite)) {
|
|
1160
|
+
for (const session of sessions)
|
|
1161
|
+
await outcome(
|
|
1162
|
+
reader.send(
|
|
1163
|
+
'DOMStorage.setDOMStorageItem',
|
|
1164
|
+
{ storageId: { storageKey, isLocalStorage: true }, key: lsKey, value: tag },
|
|
1165
|
+
session
|
|
1166
|
+
)
|
|
1167
|
+
);
|
|
1168
|
+
if (await readPartitionedKey(reader, sessions, storageKey, lsKey, tag))
|
|
1169
|
+
return { ok: true, storageKey, sessions };
|
|
1170
|
+
}
|
|
1171
|
+
return { ok: false };
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
async function plantPartitionedStorage(reader, sessionId, { origin, ordinaryOrigin, tag }) {
|
|
1175
|
+
const lsKey = `cred-part-${tag}`;
|
|
1176
|
+
const until = (check) => waitFor(check, 5000);
|
|
1177
|
+
const base = parseURL(ordinaryOrigin);
|
|
1178
|
+
const adobeOrigin = `${base.protocol}//adobe.com${base.port ? `:${base.port}` : ''}`;
|
|
1179
|
+
const proven = { partitionedKey: lsKey, cleanup: [] };
|
|
1180
|
+
for (const [name, topUrl] of [
|
|
1181
|
+
['adobelogin', `${origin}/credential?n=${encodeURIComponent(tag)}&part=1`],
|
|
1182
|
+
['adobeCom', `${adobeOrigin}/blank?n=${encodeURIComponent(tag)}`],
|
|
1183
|
+
]) {
|
|
1184
|
+
let planted = await plantPartitionedInTop(reader, {
|
|
1185
|
+
topUrl,
|
|
1186
|
+
iframeOrigin: ordinaryOrigin,
|
|
1187
|
+
lsKey,
|
|
1188
|
+
tag,
|
|
1189
|
+
until,
|
|
1190
|
+
});
|
|
1191
|
+
if (planted.topId) proven.cleanup.push(planted.topId);
|
|
1192
|
+
if (!planted.ok) {
|
|
1193
|
+
const direct = await plantPartitionedDirect(reader, [sessionId, undefined], {
|
|
1194
|
+
iframeOrigin: ordinaryOrigin,
|
|
1195
|
+
topSite: siteOf(topUrl),
|
|
1196
|
+
lsKey,
|
|
1197
|
+
tag,
|
|
1198
|
+
});
|
|
1199
|
+
if (direct.ok) planted = { ...direct, reportedKey: planted.reportedKey, frameTarget: null };
|
|
1200
|
+
}
|
|
1201
|
+
proven[`${name}PartitionProven`] = planted.ok === true;
|
|
1202
|
+
proven[`${name}StorageKey`] = planted.ok ? planted.storageKey : null;
|
|
1203
|
+
proven[`${name}ReportedKey`] = planted.reportedKey ?? null;
|
|
1204
|
+
proven[`${name}FrameTarget`] = planted.ok ? (planted.frameTarget ?? null) : null;
|
|
1205
|
+
proven[`${name}ReadSessions`] = planted.ok ? planted.sessions : [];
|
|
1206
|
+
}
|
|
1207
|
+
return proven;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
async function probeCredentialClient(ctx) {
|
|
1211
|
+
const { client, internalSessions, targetId, result, note } = ctx;
|
|
1212
|
+
const attach = await outcome(client.send('Target.attachToTarget', { targetId, flatten: true }));
|
|
1213
|
+
const clientSession = attach.result?.sessionId;
|
|
1214
|
+
if (!clientSession || refused(attach)) {
|
|
1215
|
+
result.pageDrivable = false;
|
|
1216
|
+
note('attach', { refused: refused(attach), error: attach.error?.message });
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
internalSessions.add(clientSession);
|
|
1220
|
+
ctx.clientSession = clientSession;
|
|
1221
|
+
await measureDrivability(ctx);
|
|
1222
|
+
await measureHeaders(ctx);
|
|
1223
|
+
await measureCookieReads(ctx);
|
|
1224
|
+
await measureCookieWrites(ctx);
|
|
1225
|
+
await measureStorageReads(ctx);
|
|
1226
|
+
await measurePartitionedStorageKeys(ctx);
|
|
1227
|
+
await measureSubHost(ctx);
|
|
1228
|
+
if (ctx.control) return;
|
|
1229
|
+
await measureStorageMutations(ctx);
|
|
1230
|
+
await measureGlobalClears(ctx);
|
|
1231
|
+
await measureClearDataForOrigin(ctx);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
async function closeAll(reader, targetIds) {
|
|
1235
|
+
for (const targetId of targetIds) await outcome(reader.send('Target.closeTarget', { targetId }));
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
export async function credentialExport({
|
|
1239
|
+
client,
|
|
1240
|
+
reader,
|
|
1241
|
+
credentialOrigin,
|
|
1242
|
+
ordinary,
|
|
1243
|
+
tag,
|
|
1244
|
+
internalSessions = new Set(),
|
|
1245
|
+
notes = [],
|
|
1246
|
+
budget = 8000,
|
|
1247
|
+
refusalPrefix = 'slicc: refused:',
|
|
1248
|
+
}) {
|
|
1249
|
+
const until = (check) => waitFor(check, budget);
|
|
1250
|
+
const result = emptyCredentialResult();
|
|
1251
|
+
const note = (label, evidence) => notes.push(`${label}: ${JSON.stringify(evidence)}`);
|
|
1252
|
+
if (!reader) return { ...result, incomplete: 'missing unguarded reader' };
|
|
1253
|
+
const origin = originOf(credentialOrigin);
|
|
1254
|
+
const host = hostOf(credentialOrigin);
|
|
1255
|
+
const ordinaryOrigin = originOf(ordinary);
|
|
1256
|
+
const ordinaryHost = hostOf(ordinary);
|
|
1257
|
+
if (!origin || !host || !ordinaryOrigin)
|
|
1258
|
+
return { ...result, incomplete: 'credentialOrigin or ordinary is not a URL' };
|
|
1259
|
+
|
|
1260
|
+
const page = await openPage(
|
|
1261
|
+
reader,
|
|
1262
|
+
`${origin}/credential?n=${encodeURIComponent(tag)}`,
|
|
1263
|
+
notes,
|
|
1264
|
+
internalSessions
|
|
1265
|
+
);
|
|
1266
|
+
if (!page.ok)
|
|
1267
|
+
return {
|
|
1268
|
+
...result,
|
|
1269
|
+
incomplete: `open credential page: ${page.error?.message ?? 'failed'}`,
|
|
1270
|
+
};
|
|
1271
|
+
const { targetId, sessionId } = page.result;
|
|
1272
|
+
const planted = await plantState(reader, { origin, host, tag, sessionId });
|
|
1273
|
+
if (planted.incomplete) {
|
|
1274
|
+
await closeAll(reader, [targetId]);
|
|
1275
|
+
return { ...result, incomplete: planted.incomplete };
|
|
1276
|
+
}
|
|
1277
|
+
result.cookiesPlanted = true;
|
|
1278
|
+
result.storagePlanted = true;
|
|
1279
|
+
result.live = true;
|
|
1280
|
+
note('planted', { origin, host, ...planted });
|
|
1281
|
+
|
|
1282
|
+
const ordinaryCookie = `plain-${tag}`;
|
|
1283
|
+
await outcome(
|
|
1284
|
+
reader.send(
|
|
1285
|
+
'Network.setCookie',
|
|
1286
|
+
{ name: ordinaryCookie, value: tag, url: `${ordinaryOrigin}/`, path: '/' },
|
|
1287
|
+
sessionId
|
|
1288
|
+
)
|
|
1289
|
+
);
|
|
1290
|
+
const adobeComCookie = `adobecom-${tag}`;
|
|
1291
|
+
await outcome(
|
|
1292
|
+
reader.send(
|
|
1293
|
+
'Network.setCookie',
|
|
1294
|
+
{ name: adobeComCookie, value: tag, domain: '.adobe.com', path: '/' },
|
|
1295
|
+
sessionId
|
|
1296
|
+
)
|
|
1297
|
+
);
|
|
1298
|
+
Object.assign(
|
|
1299
|
+
planted,
|
|
1300
|
+
await plantPartitionedCookies(reader, sessionId, { ordinaryOrigin, host, tag })
|
|
1301
|
+
);
|
|
1302
|
+
Object.assign(
|
|
1303
|
+
planted,
|
|
1304
|
+
await plantPartitionedStorage(reader, sessionId, { origin, ordinaryOrigin, tag })
|
|
1305
|
+
);
|
|
1306
|
+
note('partitioned', {
|
|
1307
|
+
partitionedCredentialProven: planted.partitionedCredentialProven,
|
|
1308
|
+
partitionedAdobeComProven: planted.partitionedAdobeComProven,
|
|
1309
|
+
adobeloginPartitionProven: planted.adobeloginPartitionProven,
|
|
1310
|
+
adobeloginStorageKey: planted.adobeloginStorageKey,
|
|
1311
|
+
adobeloginReportedKey: planted.adobeloginReportedKey,
|
|
1312
|
+
adobeComPartitionProven: planted.adobeComPartitionProven,
|
|
1313
|
+
adobeComStorageKey: planted.adobeComStorageKey,
|
|
1314
|
+
adobeComReportedKey: planted.adobeComReportedKey,
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1317
|
+
const ctx = {
|
|
1318
|
+
client,
|
|
1319
|
+
reader,
|
|
1320
|
+
readerSession: sessionId,
|
|
1321
|
+
control: client === reader,
|
|
1322
|
+
internalSessions,
|
|
1323
|
+
targetId,
|
|
1324
|
+
origin,
|
|
1325
|
+
host,
|
|
1326
|
+
ordinaryOrigin,
|
|
1327
|
+
ordinaryHost,
|
|
1328
|
+
ordinaryCookie,
|
|
1329
|
+
adobeComCookie,
|
|
1330
|
+
tag,
|
|
1331
|
+
planted,
|
|
1332
|
+
until,
|
|
1333
|
+
refusalPrefix,
|
|
1334
|
+
result,
|
|
1335
|
+
note,
|
|
1336
|
+
};
|
|
1337
|
+
try {
|
|
1338
|
+
await probeCredentialClient(ctx);
|
|
1339
|
+
} finally {
|
|
1340
|
+
await closeAll(reader, [...planted.cleanup, targetId]);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
note('result', {
|
|
1344
|
+
getCookiesFiltered: result.getCookiesFiltered,
|
|
1345
|
+
getAllCookiesFiltered: result.getAllCookiesFiltered,
|
|
1346
|
+
partitionedCookieFiltered: result.partitionedCookieFiltered,
|
|
1347
|
+
ordinaryCookiesExportable: result.ordinaryCookiesExportable,
|
|
1348
|
+
adobeComCookiesExportable: result.adobeComCookiesExportable,
|
|
1349
|
+
adobeComPartitionedCookieExportable: result.adobeComPartitionedCookieExportable,
|
|
1350
|
+
partitionedStorageKeyFiltered: result.partitionedStorageKeyFiltered,
|
|
1351
|
+
adobeComStorageKeyExportable: result.adobeComStorageKeyExportable,
|
|
1352
|
+
clearBrowserCookiesSurvived: result.clearBrowserCookiesSurvived,
|
|
1353
|
+
storageClearCookiesSurvived: result.storageClearCookiesSurvived,
|
|
1354
|
+
clearDataForOriginSurvived: result.clearDataForOriginSurvived,
|
|
1355
|
+
pageDrivable: result.pageDrivable,
|
|
1356
|
+
skips: result.skips,
|
|
1357
|
+
});
|
|
1358
|
+
return result;
|
|
1359
|
+
}
|