browserpass / browserpass-extension

Browserpass web extension
ISC License
825 stars 50 forks source link

Error: An unexpected error occurred #316

Closed raxod502 closed 1 year ago

raxod502 commented 1 year ago

General information


If you are getting an error immediately after opening popup, have you followed the Configure browsers documentation section?

Yes, this is taken care of by my packaging script, so /usr/lib/mozilla/native-messaging-hosts/com.github.browserpass.native.json has the contents:

{
    "name": "com.github.browserpass.native",
    "description": "Browserpass native component for the Firefox extension",
    "path": "/usr/bin/browserpass-linux64",
    "type": "stdio",
    "allowed_extensions": ["browserpass@maximbaz.com"]
}

And:

% /usr/bin/browserpass-linux64 --version
Browserpass host app version: 3.0.10

Exact steps to reproduce the problem

  1. Go to extension options, see error

image

  1. Try clicking extension icon, see same error

image

What should happen?

  1. Extension options should be shown as documented at https://github.com/browserpass/browserpass-extension#options

  2. Popup should display as documented at https://github.com/browserpass/browserpass-extension#first-steps-in-browser-extension

This works on my other laptops, which are running Pop!_OS 22.10 and macOS 10.15 respectively, both on Firefox ~latest. I've never seen this precise error before having configured Browserpass on numerous installations over the years, but something must be different with my new laptop.

What happened instead?

See screenshots above

maximbaz commented 1 year ago

Hey! I've never seen something like this either. I don't think the "An unexpected error occurred" is a error message that we send, so I tend to think it might be a browser that gives this error, when it's unable to communicate with the native host.

I wonder if it's possible that there are some additional security configs on this machine, for example AppArmor enabled, preventing Firefox from talking to a binary on the disk? :thinking:

raxod502 commented 1 year ago

Yes, it's an error generated by Firefox, indeed. By checking the traceback in the debugging options for the extension, I was able to see that the error comes from the return value of await chrome.runtime.sendMessage({ action: "getSettings" }) in options.dist.js.

I can look around at the Firefox bug tracker and see if anybody has reported something like this, or if there are known issues with the weird things Canonical is doing with recent versions of Ubuntu (to go along with the migration of most users to Firefox-as-a-snap).

raxod502 commented 1 year ago

Well, you were spot on with AppArmor. I checked sudo aa-status on both my laptops - it's in enforce mode for Firefox processes only on the laptop where this is broken. On Pop!_OS they disable the Firefox profile out of the box.

Following step 4 from https://askubuntu.com/a/1404346:

sudo ln -s /etc/apparmor.d/usr.bin.firefox /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.bin.firefox

And Browserpass immediately starts working again. Very silly, I'm annoyed that nobody doing the security stuff seems to care about native messaging hosts - it's an important use case!

I think having this issue to track the resolution should be good enough for now, but if other users report the same happening, I'd be happy to add this troubleshooting info to the documentation.