kkapsner/keepassxc-mail

Wrong queries to keepass if accoutn data was ever changed in thunderbird.

Closed this issue · 22 comments

I have an email account that uses the IMAP server imap.example.com, with a username of random.dude.
The data used to be URL: imap.invalid.com, Username somebody and was changed in Thunderbird once.

In my keypass database, I have a key correctly set up for URL: imap://imap.example.com, Username: random.dude.

Expected behavior: keepassxc-mail looks up URL: imap://imap.example.com, Username: random.dude and is able to find the entry.

Actual behavior: keepassxc-mail looks up: URL: imap://imap.invalid.com, Username: somebody and does therefore not find the entry. (Excerpt from web console: got credential request: Object { host: "imap://imap.invalid.com", login: "somebody", loginChangeable: false }

Thunderbird version is 78.5.1 (64 Bit), German locale.
Keepasskc-mail version is 0.1.5

I'm using regular keepass with KeePassNatMsg (however as the lookup displayed in the popup on hover is already incorrect, I don't think this is causing the issue.)

Are the IMAP / SMTP account settings correctly set in TB ?
I do have addresses with usernames like user@domain-that-is-not-the-imap-server and I don't have problems.

The account is correctly set up. Thunderbird lists imap.example.com as IMAP Server and random.dude as username, even in the popup.

I can privately share a screenshot with the actual data, if you have a way to contact you.

What I don't understand is where the Username: somebody part is coming from ? Did you try that as a username previously ?

no, it is only the first part of the main email address: somebody@invalid.com. To me it looks like keepassxc-mail is attempting to get the server and username from the main email, instead of actualy thunderbird accoutn data.

So you're not using KeepassXC but the regular Keepass ? This plugin is meant to be used with KPXC.
I don't think the regular Keepass is supported ...

EDIT : found out this issue so OK Keepass should be working

Thjat's what https://github.com/smorks/keepassnatmsg is for. And it is working great - if the lookup is correct.

That issue seems to be resolved, and as I said, for domains where the main email is the same as username@server, it works great. The hover in the keepass password dialog already shows wrong lookup data, so I do not tihnk keepassnatmsg is the problem here.

I suggest that you delete this information as it is sensitive personal data.
You can use CTRL+SHIFT+J in thunderbird to find out what the lookup address is by the way, look for:
got credential request: Object { host: "imap://domain.tld", login: "user@domain.tld", loginChangeable: false }

it confirms the data shown in the popup. got credential request: Object { host: "imap://imap.wrong-domain.com", login: "wrongUsername", loginChangeable: false }

Ok, looking at about:config got me closer to solving this.

In the past, server credentials were in fact what keepassxc-mail is now trying to look up. When changing data in thunderbird, it did NOT correctly replace that data in mail.server.serverX.username and mail.server.serverX.hostname. Instead, it left the data as-is and set mail.serverX.realhostname as well as mail.serverX.realuserName.

I'm not sure why Thunderbird handles it that way, and I am unsure if this is a bug in Thunderbird or just meant to work that way (in which case KeepassXc-Mail should look for that data to be present as well).

I had the same problem in this issue

Try to completely remove the account (account data, message data and SMTP server) and re add it manually.
Also try, if the above doesn't work, to launch Thunderbird with -p option and create a new profile. Install KPXC-mail and configure your account in it to check that it is really a TB problem.

Changing the keys in about:config manually and restarting Thunderbird has fixed the issue - just in case somebody is running into the same issue. No need to re-create the account.

This should still be resolved - if I was to change server details in Thunderbird again, it will break again.
@kkapsner If this is a bug in thunderbird and not documented behaviour, and you do not want to fix this in the addon, let me know and I will submit a bug report to Thunderbird.

Adjusted title and Description accordingly.

IMO it is a TB problem, which doesn't seem to update about:config entries even when the settings are changed.

I had a laugh seeing that this thunderbird bug has been opened 16 years ago ...

Amazing. As I doubt TB will fix this issue any time soon in that case, I suggest implementing a fix in keepassxc-mail - it should be doable to detect if there is a mismatch betweren hostname/realhostname and userName/realuserName and use the real-prefixed version - or just use that by default alltogether whenever it is present (the real-prefixed keys are NOT present when the data was never changed in TB).

Wow you guys are active...
I think I know where the problem comes from. It's weird Thunderbird behaviour when changing the server name or the user name. I don't know if it's documented anywhere, but it does not matter.

Can you please check the attached version if it solves the problem?
keepassxc-mail-0.1.5.2.zip

The attached version did not fix the problem for me. It's still using the value from .username instead of .realuserName, and .hostname instead of .realhostname despite the .real* ones being present.

That's bad... I guess you are not willing to send me your profile? My tests are not quite working...

OK - I managed to reproduce the problem.

So... I could solve the problem in my test case. Please check the attached version:
keepassxc-mail-0.1.5.2.zip

Can confirm the fix - it is now working correctly.

(Also, to reproduce the issue, you can manually change the userName & hostname entries of any server in about:config in Thunderbird and add the realuserName & realhostname string entries.)

Great.

(Also, to reproduce the issue, you can manually change the userName & hostname entries of any server in about:config in Thunderbird and add the realuserName & realhostname string entries.)

I know but my Thunderbird behaved very erratic (I'm developing on nightly).