Merge pull request #2500 from keepassxreboot/fix/disable_passkeys_if_site_is_ignored

Disable passkeys script injection if site is ignored
This commit is contained in:
Sami Vänttinen 2025-04-19 10:11:42 +03:00 committed by GitHub
commit a8297aeb5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 0 deletions

View file

@ -264,6 +264,7 @@ kpxcEvent.messageHandlers = {
'init_http_auth': kpxcEvent.initHttpAuth,
'is_connected': kpxcEvent.getIsKeePassXCAvailable,
'is_iframe_allowed': page.isIframeAllowed,
'is_site_ignored': page.isSiteIgnored,
'load_keyring': kpxcEvent.onLoadKeyRing,
'load_settings': kpxcEvent.onLoadSettings,
'lock_database': kpxcEvent.lockDatabase,

View file

@ -320,6 +320,22 @@ page.fillHttpAuth = async function(tab, credentials) {
}
};
page.isSiteIgnored = async function(tab, currentLocation) {
if (!page?.settings?.sitePreferences || !currentLocation) {
return false;
}
for (const site of page.settings.sitePreferences) {
if (siteMatch(site.url, currentLocation) || site.url === currentLocation) {
if (site.ignore === IGNORE_FULL) {
return true;
}
}
}
return false;
};
// Update context menu for attribute filling
page.updateContextMenu = async function(tab, credentials) {
// Remove any old attribute items

View file

@ -981,6 +981,8 @@ browser.runtime.onMessage.addListener(async function(req, sender) {
}
} else if (req.action === 'ignore_site') {
kpxc.ignoreSite(req.args);
} else if (req.action === 'is_site_ignored') {
return await kpxc.siteIgnored();
} else if (req.action === 'redetect_fields') {
const response = await sendMessage('load_settings');
kpxc.settings = response;

View file

@ -99,6 +99,11 @@ const initContent = async () => {
return;
}
if (await chrome.runtime.sendMessage({ action: 'is_site_ignored', args: window.self.location.href })) {
console.log('This site is ignored in Site Preferences.');
return;
}
if (settings.passkeys) {
kpxcPasskeysUtils.debugLogging = settings?.debugLogging;
kpxcPasskeysUtils.passkeysFallback = settings?.passkeysFallback;