This commit is contained in:
Mike Ilog 2026-07-14 19:16:50 -07:00 committed by GitHub
commit d20a3fe12e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -299,7 +299,13 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
}
if (msg.type === 'getPort') {
sendResponse({ port: serverPort, connected: isConnected, token: authToken });
// Withhold the auth token from content-script callers (content scripts have
// sender.tab set), mirroring the getToken guard below. port/connected stay
// available to any extension context, but the localhost auth token is never
// handed to an injected page context — without this guard getPort leaks the
// exact token getToken is careful to protect.
const token = sender.tab ? null : authToken;
sendResponse({ port: serverPort, connected: isConnected, token });
return true;
}