Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
fix(linkedin): reject internal subdomain redirects
16Mikuf36825bf4580
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.jsindex 963278394..5f2b08abf 100644--- a/src/chrome/src/content/content.js+++ b/src/chrome/src/content/content.js@@ -5181,7 +5181,10 @@if (!href || href.startsWith('#')) return false;const destination = new URL(href, document.baseURI);if (!/^https?:$/.test(destination.protocol)) return false;- const isLinkedInHost = (hostname) => /^(?:www\.)?linkedin\.com$/.test(hostname);+ const isLinkedInHost = (hostname) => {+ const normalized = String(hostname || '').toLowerCase().replace(/\.$/, '');+ return normalized === 'linkedin.com' || normalized.endsWith('.linkedin.com');+ };const linkedInDestination = isLinkedInHost(destination.hostname);const redirectPath = /^\/(?:safety\/go|redir\/redirect)\/?$/.test(destination.pathname);let verifiedExternalRedirect = false;diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.jsindex 234664e3e..19a1c68ea 100644--- a/src/firefox/src/content/content.js+++ b/src/firefox/src/content/content.js@@ -4344,7 +4344,10 @@if (!href || href.startsWith('#')) return false;const destination = new URL(href, document.baseURI);if (!/^https?:$/.test(destination.protocol)) return false;- const isLinkedInHost = (hostname) => /^(?:www\.)?linkedin\.com$/.test(hostname);+ const isLinkedInHost = (hostname) => {+ const normalized = String(hostname || '').toLowerCase().replace(/\.$/, '');+ return normalized === 'linkedin.com' || normalized.endsWith('.linkedin.com');+ };const linkedInDestination = isLinkedInHost(destination.hostname);const redirectPath = /^\/(?:safety\/go|redir\/redirect)\/?$/.test(destination.pathname);let verifiedExternalRedirect = false;diff --git a/test/fixtures/message-recipient-navigation.mjs b/test/fixtures/message-recipient-navigation.mjsindex e39f593de..6263ca2e7 100644--- a/test/fixtures/message-recipient-navigation.mjs+++ b/test/fixtures/message-recipient-navigation.mjs@@ -129,6 +129,8 @@ export function registerMessageRecipientNavigationFixtures({'/safety/go/','/safety/go/?url=javascript%3Aalert(1)','/safety/go/?url=https%3A%2F%2Flinkedin.com%2Fmessaging%2Fsend',+ '/safety/go/?url=https%3A%2F%2Fm.linkedin.com%2Fmessaging%2Fsend',+ '/safety/go/?url=https%3A%2F%2Fm.linkedin.com.%2Fmessaging%2Fsend',]) {await page.locator('#safety-portfolio').evaluate((el, value) => el.setAttribute('href', value), href);const result = await probe('click', { text: 'portfolio.example', textMatch: 'exact' });@@ -146,10 +148,14 @@ export function registerMessageRecipientNavigationFixtures({'/messaging/compose/','/messaging/send/','https://linkedin.com/messaging/send/',+ 'https://m.linkedin.com/messaging/send/',+ 'https://m.linkedin.com./messaging/send/','/safety/go/','/safety/go/?url=javascript%3Aalert(1)','/safety/go/?url=https%3A%2F%2Fwww.linkedin.com%2Fmessaging%2Fsend','/safety/go/?url=https%3A%2F%2Flinkedin.com%2Fmessaging%2Fsend',+ '/safety/go/?url=https%3A%2F%2Fm.linkedin.com%2Fmessaging%2Fsend',+ '/safety/go/?url=https%3A%2F%2Fm.linkedin.com.%2Fmessaging%2Fsend',]) {await page.locator('#jobs').evaluate((el, href) => el.setAttribute('href', href), href);assert.equal((await guard('click', { text: 'Jobs' }))?.noDispatch, true, href);