Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix(linkedin): close recipient guard fallthrough

16Miku60736d5f3109
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.js
index bdef39bf2..f941d2257 100644
--- a/src/chrome/src/content/content.js
+++ b/src/chrome/src/content/content.js
@@ -5260,6 +5260,7 @@
}
if (!linkedInDestination) return 'navigation';
if (redirectPath) return 'blocked';
+ if (/^\/messaging\/(?:send|compose)\/?$/.test(destination.pathname)) return 'blocked';
return (/^\/(?:feed|jobs|mynetwork|messaging|notifications)\/?$/.test(destination.pathname)
|| /^\/in\/[^/]+\/overlay\/contact-info\/?$/.test(destination.pathname))
? 'navigation'
diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.js
index c4c0e88ea..35bc01cf9 100644
--- a/src/firefox/src/content/content.js
+++ b/src/firefox/src/content/content.js
@@ -571,14 +571,23 @@
function _someComposedDescendant(root, selector, predicate, limit = 2000) {
const pending = [root];
+ const seen = new Set();
let visited = 0;
while (pending.length && visited < limit) {
const scope = pending.shift();
- const elements = scope?.querySelectorAll?.('*') || [];
+ const descendants = scope?.querySelectorAll?.('*') || [];
+ const elements = scope?.nodeType === Node.ELEMENT_NODE
+ ? [scope, ...descendants]
+ : descendants;
for (const element of elements) {
+ if (seen.has(element)) continue;
+ seen.add(element);
visited += 1;
if (element.matches?.(selector) && predicate(element)) return true;
if (element.shadowRoot) pending.push(element.shadowRoot);
+ if (element.tagName === 'SLOT') {
+ pending.push(...(element.assignedElements?.({ flatten: true }) || []));
+ }
if (visited >= limit) break;
}
}
@@ -4414,6 +4423,7 @@
}
if (!linkedInDestination) return 'navigation';
if (redirectPath) return 'blocked';
+ if (/^\/messaging\/(?:send|compose)\/?$/.test(destination.pathname)) return 'blocked';
return (/^\/(?:feed|jobs|mynetwork|messaging|notifications)\/?$/.test(destination.pathname)
|| /^\/in\/[^/]+\/overlay\/contact-info\/?$/.test(destination.pathname))
? 'navigation'
diff --git a/test/fixtures/message-recipient-navigation.mjs b/test/fixtures/message-recipient-navigation.mjs
index 0f61094f9..dddcc87b9 100644
--- a/test/fixtures/message-recipient-navigation.mjs
+++ b/test/fixtures/message-recipient-navigation.mjs
@@ -222,6 +222,33 @@ export function registerMessageRecipientNavigationFixtures({
assert.equal(await guard('click', args), null);
});
+ register(`${kind}: LinkedIn Contact info ownership follows flattened slots`, async (page) => {
+ const { guard, probe } = await setup(page);
+ const ref_id = await page.evaluate(() => {
+ history.replaceState(null, '', '/in/alice/overlay/contact-info/');
+ document.querySelector('#contact-info-dialog').remove();
+ const host = document.createElement('div');
+ const profile = document.createElement('a');
+ profile.slot = 'profile';
+ profile.href = '/in/alice/';
+ profile.textContent = 'linkedin.com/in/alice';
+ host.append(profile);
+ document.body.append(host);
+ const shadow = host.attachShadow({ mode: 'open' });
+ shadow.innerHTML = `
+ <div role="dialog" aria-modal="true" style="position:fixed;inset:0;background:white">
+ <slot name="profile"></slot>
+ <a id="slotted-ownership-link" href="/safety/go/?url=https%3A%2F%2Fportfolio.example%2F"
+ style="display:inline-block;padding:8px">Slotted ownership link</a>
+ </div>`;
+ return window.__wb_ax_ref(shadow.querySelector('#slotted-ownership-link'));
+ });
+ const args = { ref_id };
+ const result = await probe('click_ax', args);
+ assert.equal(result.navigation, true, JSON.stringify(result));
+ assert.equal(await guard('click_ax', args), null);
+ });
+
register(`${kind}: LinkedIn non-blocking dialogs cannot claim Contact info redirects`, async (page) => {
const { guard, probe } = await setup(page);
await page.evaluate(() => {
@@ -280,17 +307,28 @@ export function registerMessageRecipientNavigationFixtures({
});
register(`${kind}: LinkedIn recipient guard rejects ambiguous navigation and action lookalikes`, async (page) => {
- const { guard } = await setup(page);
- for (const href of [
- '#',
- 'javascript:void(0)',
- 'mailto:[email protected]',
- '/in/alice/',
+ const { guard, probe } = await setup(page);
+ const messageActionHrefs = [
'/messaging/compose/',
'/messaging/send/',
'https://linkedin.com/messaging/send/',
'https://m.linkedin.com/messaging/send/',
'https://m.linkedin.com./messaging/send/',
+ ];
+ await page.evaluate(() => { document.querySelector('#chat').hidden = false; });
+ for (const href of messageActionHrefs) {
+ await page.locator('#jobs').evaluate((el, value) => el.setAttribute('href', value), href);
+ const args = { text: 'Jobs' };
+ const result = await probe('click', args);
+ assert.equal(result.navigationBlocked, true, `${href}: ${JSON.stringify(result)}`);
+ assert.equal((await guard('click', args))?.noDispatch, true, href);
+ }
+ await page.evaluate(() => { document.querySelector('#chat').hidden = true; });
+ for (const href of [
+ '#',
+ 'javascript:void(0)',
+ 'mailto:[email protected]',
+ '/in/alice/',
'/safety/go/?url=https%3A%2F%2Fportfolio.example%2F',
'/safety/go/',
'/safety/go/?url=javascript%3Aalert(1)',