Keepassxc-browser: Automatic reconnect when using the username input icon

Created on 24 Oct 2019  路  19Comments  路  Source: keepassxreboot/keepassxc-browser

Expected Behavior

When using the username field icon with no active connection, a connection is automatically established in the background if possible, and the input fields are filled afterwards. Only a single click is required.

Current Behavior

Currently, an error message is shown, and the connection needs to be (re-) established manually using the browser extension toolbar icon, and only then can the icon be used. Sometimes, I even have to reload the page. Three or even four manual steps are required.

keepassxc-browser-extension

Debug info


KeePassXC-Browser Version: 1.5.3
KeePassXC Version: 2.4.3
Operating system: Windows/Linux
Browser: Firefox
"Automatically reconnect to KeePassXC (experimental)" is enabled.

PR pending bug

Most helpful comment

Hi, I think I've root caused the issue. On Windows, if we start Chrome before starting KeePassXC, when keepass.enableAutomaticReconnect() is called, since KeePassXC isn't running, keepass.currentKeePassXC doesn't contain the KeePassXC version and is "".

In keepass.enableAutomaticReconnect(), there's a Windows specific version check, it will fail & the function won't set the timer.

    if (!page.settings.autoReconnect
        || (navigator.platform.toLowerCase().includes('win') && !keepass.compareVersion('2.3.4', keepass.currentKeePassXC))) {
        return;
    }

keepass.compareVersion('2.3.4', keepass.currentKeePassXC)) this check will fail and we do this only on Windows.

If we start KeePassXC before starting Chrome, you won't hit the issue.

One quick way to fix this is to move the version check inside the reconnectLoop:

    if (keepass.reconnectLoop === null) {
        keepass.reconnectLoop = setInterval(async () => {
            if (!keepass.isKeePassXCAvailable) {
                if (navigator.platform.toLowerCase().includes('win') && !keepass.compareVersion('2.3.4', keepass.currentKeePassXC)) return;
                keepass.reconnect();
            }
        }, 1000);
    }

All 19 comments

So.. automatic reconnect is enabled but you still made the reconnect manually in the video?

Yes, I needed to. I'm not sure what the options is supposed to do, but it doesn't work for me in those cases. I always need to manually reconnect.

If it it supposed to work like that, it seems like it doesn't work yet for my specific setup. If you need any additional information, please don't hesitate to ask!

With the automatic reconnect enabled, you shouldn't even see the popup message for reloading. Could you debug the extension via about:debugging and see what the console log shows?

Here's the console log:

Error 1: Database not opened keepass.js:1060:13
Error: No content script available for this tab. keepass.js:1178:25
Failed to connect: Unknown error keepass.js:947:13
Error: No content script available for this tab. keepass.js:1178:25
Error 5: Cannot connect to KeePassXC. Check that browser integration is enabled in KeePassXC settings. 3 keepass.js:1060:13
Connecting to native messaging host org.keepassxc.keepassxc_browser keepass.js:977:13
Server public key: 8y49X8AbP4xyZpiAlU/YmpW/ordNf5W+ywrQMLHxtEY= keepass.js:606:17

I figured out how to reproduce the issue. The key point is to close KeepassXC once the connection has been established successfully. Once it's closed, the connection cannot be reestablished again. But it still can be reestablished manually. This is the second try in the log above,

Well that sounds strange. I'll check if I can reproduce it. There has been a lot of fixes for the connection issues lately, so it's possible that something is still broken.

FYI I have the same issue (also seeing the reload page button despite "auto reconnect" is enabled) in Chrome.

The log just says Error 7: Die Nachrichtenverschl眉sselung ist fehlgeschlagen. L盲uft KeePassXC? This is not only the case after closing KeePassXC but also after doing the following:

  1. restart windows
  2. open chrome
  3. open KeePassXC

I've since tested it again in multiple, heterogeneous environments, and found the following:

  1. For me, it only happens on Windows. On all my Linux machines, it works without issues.
  2. On all Windows machines that are affected, the user is running unprivileged.
  3. It happens with "Update native messaging files at startup" both enabled and disabled.

I didn't yet test whether using a proxy application affects the bug. I'm always using a proxy application, thus I'm not sure if it's worth it checking it out.

@bllngr Thanks for the info. I must do some more tests with Windows.

+1 for this.

I use KeePassXC with Firefox on a Mac and Windows 10.

On the Mac, the browser extension automatically connects to KeePassXC. For Windows, I have to manually press Reload in the browser extension for it to connect.

Both have the Automatically reconnect to KeePassXC setting enabled.

Windows environment:
Firefox 72.0.2
Windows 10 Pro (1909)
KeePassXC Version: 2.5.3
KeePassXC-Browser Version: 1.5.4

Same here.

@varjolintu, have you been able to reproduce the issue? Is there anything we can help you with?

To add a little bit more info: I have noticed that this currently happens only for the first unlock of the KeePass database after KeePassXC is opened. When the database is locked and unlocked after that (without closing KeePassXC), it does seem to reconnect automatically.

On MacOS it picks up situations both automatically.

@bllngr I haven't had time to look at it. I'll try to fix this before the next release.

I just tested this with Linux and Windows using Firefox and I couldn't reproduce the issue.

If the automatic reconnect is enabled, and I restart KeePassXC, the icon and popup are functional right away. If I don't open the database, clicking the icon asks for unlocking the database as it's already connected.

That's unfortunate. :( Did you test it with both Proxy application and without? Maybe we can help with some (verbose) logging information?

@bllngr I tested with the proxy application because that's the default behavior. The only thing that could help here is to debug the extension's background script file keepass.js. Basically anyone could add some extra console.log() messages to https://github.com/keepassxreboot/keepassxc-browser/blob/develop/keepassxc-browser/background/keepass.js#L1133 and see where it returns etc. Using breakpoints can be tricky because that function is called repeatedly.

Hi, I think I've root caused the issue. On Windows, if we start Chrome before starting KeePassXC, when keepass.enableAutomaticReconnect() is called, since KeePassXC isn't running, keepass.currentKeePassXC doesn't contain the KeePassXC version and is "".

In keepass.enableAutomaticReconnect(), there's a Windows specific version check, it will fail & the function won't set the timer.

    if (!page.settings.autoReconnect
        || (navigator.platform.toLowerCase().includes('win') && !keepass.compareVersion('2.3.4', keepass.currentKeePassXC))) {
        return;
    }

keepass.compareVersion('2.3.4', keepass.currentKeePassXC)) this check will fail and we do this only on Windows.

If we start KeePassXC before starting Chrome, you won't hit the issue.

One quick way to fix this is to move the version check inside the reconnectLoop:

    if (keepass.reconnectLoop === null) {
        keepass.reconnectLoop = setInterval(async () => {
            if (!keepass.isKeePassXCAvailable) {
                if (navigator.platform.toLowerCase().includes('win') && !keepass.compareVersion('2.3.4', keepass.currentKeePassXC)) return;
                keepass.reconnect();
            }
        }, 1000);
    }

@alex-the-man Nice find!

EDIT: I wouldn't put the check inside the loop because enabling the option will call the function again. It's better just to let the reconnect loop run if keepass.currentKeePassXC is not set.

I can confirm that it works correctly on my Windows machines with 1.6.3. Thanks @alex-the-man and @varjolintu for the fix!

Was this page helpful?
0 / 5 - 0 ratings