keepassxreboot / keepassxc-browser

KeePassXC Browser Extension
GNU General Public License v3.0
1.72k stars 177 forks source link

After KeepassXC locks, Firefox addon can't reconnect #1887

Open eplinux opened 1 year ago

eplinux commented 1 year ago

Expected Behavior

After a while, KeepassXC locks the database automatically. Once I then reopen the database, the firefox addon should be able to reconnect to the database and provide login credentials.

Current Behavior

After a while, KeepassXC locks the database automatically. Once I then reopen the database, the firefox addon cannot connect to the database anymore. Sometimes it says that the key exchange was not possible. When I toggle the browser integration in the settings, the addon can reconnect again but does not fill in the credentials. Only solution is a restart of KeepassXC.

Possible Solution

Steps to Reproduce (for bugs)

  1. Connect KeepassXC to the fireofx extension
  2. Wait until the database has been automatically locked
  3. Navigate to a website with saved credentials, try to log in via the browser integration in firefox

Debug info

[Error event.js:12] KeePassXC-Browser - 1: Datenbank nicht geöffnet [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
[Error ] KeePassXC-Browser - Failed to connect: Unknown error [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
KeePassXC-Browser: Connecting to native messaging host org.keepassxc.keepassxc_browser [client.js:317:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/client.js)
KeePassXC-Browser: Server public key: xx= [keepass.js:445:17](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/keepass.js)
[Error ] KeePassXC-Browser - Failed to connect: Unknown error [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
[Error init.js:66] KeePassXC-Browser - Cannot send activated_tab message: Could not establish connection. Receiving end does not exist. [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
[Error keepass.js:270] KeePassXC-Browser - 5: Die Verbindung zu KeePassXC ist nicht möglich. Überprüfen Sie, ob die Browser-Integration in den KeePassXC-Einstellungen aktiviert ist. [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
[Error init.js:66] KeePassXC-Browser - Cannot send activated_tab message: Could not establish connection. Receiving end does not exist. [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
KeePassXC-Browser: Connecting to native messaging host org.keepassxc.keepassxc_browser [client.js:317:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/client.js)
KeePassXC-Browser: Server public key: xx= [keepass.js:445:17](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/keepass.js)
[Error keepass.js:760] KeePassXC-Browser - 1: Datenbank nicht geöffnet [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
[Error keepass.js:270] KeePassXC-Browser - 1: Datenbank nicht geöffnet [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
[Error event.js:12] KeePassXC-Browser - 1: Datenbank nicht geöffnet [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
[Error ] KeePassXC-Browser - Failed to connect: Unknown error [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
KeePassXC-Browser: Connecting to native messaging host org.keepassxc.keepassxc_browser [client.js:317:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/client.js)
KeePassXC-Browser: Server public key: xx= [keepass.js:445:17](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/keepass.js)
[Error ] KeePassXC-Browser - Failed to connect: Unknown error [global.js:145:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/common/global.js)
KeePassXC-Browser: Connecting to native messaging host org.keepassxc.keepassxc_browser [client.js:317:13](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/client.js)
KeePassXC-Browser: Server public key: xx= [keepass.js:445:17](moz-extension://1da4ec2c-abce-4c3e-99c6-1ce089a1b2e3/background/keepass.js)
[Error ] KeePassXC-Browser - Failed to connect: Unknown error

KeePassXC - 2.7.3 KeePassXC-Browser - 1.8.5.1 Operating system: Win/L Browser: Firefox

varjolintu commented 1 year ago

This sounds very strange. The connection keys are still stored in your database after unlocking it again, and those match with the extension? Also, registry entries are intact etc? Are you using portable KeePassXC?

eplinux commented 1 year ago

Hey @varjolintu , I'm using the normal version not the portable one. registry entry is intact, just checked again. the connection keys are always stored in the database and they match with the extension

varjolintu commented 1 year ago

And the .json script file is located at the path registry points to? This might have something to do with anti-virus or anti-malware software that prevents launching a new proxy or connecting to a new pipe.

eplinux commented 1 year ago

Yes, it is

varjolintu commented 1 year ago

What happens if you start it manually? If you restart just your browser when the problem occurs, what happens?

eplinux commented 1 year ago

I will try next time it occurs and then I'll let you know. If I remember correctly, I once restarted the browser and it started working again. Usually I restart Keepass, though.

varjolintu commented 1 year ago

That indicates that something may kill the keepassxc-proxy.exe process. That causes the connection to fail. Next time when the problem occurs, see if that process is still running. Restarting the browser will also start a new proxy process.

eplinux commented 1 year ago

You were right, @varjolintu . It is indeed the proxy that gets terminated at some point. After restart, it reappears as subprocess of firefox. In terms of antivirus software, I only use the built in Microsoft Defender, so quite ordinary. I don't know much about windows' process handling, but might it just be terminated after a while when it's been sitting idle for too long? or is this a firefox problem?

varjolintu commented 1 year ago

It shouldn't stop or terminate, unless Firefox does it for some reason. You are not sleeping or hibernating the computer? Could you verify if the process gets terminated when the auto-lock hits after timeout? Or does it happen randomly?

eplinux commented 1 year ago

It seems to happen randomly but I feel like it mostly occurs after the computer went to sleep. I do use hibernation, though. However, in the last case, it occured after the computer went to energy saving mode (although that isn't always the case, yesterday it just worked fine throughout the day with several energy saving phases inbetween)

varjolintu commented 1 year ago

Sleep/Hibernation is a known issue in Windows. Somehow it disturbs the proxy and makes restarting it mandatory.

eplinux commented 1 year ago

Update: Restarting Firefox doesn't work. I have to restart KeepassXC for the proxy to restart

varjolintu commented 1 year ago

That indicates the pipe KeePassXC creates doesn't stay active.

cyrdam commented 1 year ago

Hi, I had the same issue the last days, and today it was "magically" fixed.

I checked lot of places and traced the problem why the proxy was not starting.

One thing I did before I run the following steps: I deleted the .json file for the tor browser. The debugger told me there was an issue finding it, but it was actually in the right place.

Afterwards following steps did the trick:

  1. Remove the connection in KeePassXC for the linked browser (in this case Firefox)
  2. Remove the connection from the browser extension
  3. Close KeePassXC and Firefox
  4. Restart Windows
  5. Run KeePassXC with database
  6. Run Firefox
  7. Connect to KeePassXC again

This worked for me.

I always shut down my PC, no hibernating/sleep, so it might be the order on when the applications start running from Windows boot.

eplinux commented 9 months ago

Update: Problem still persisting even without hibernation. I became accustomed to manually restarting Keepass several times per day but it is quite an annoying bug.