Closed Bug 1985684 Opened 2 months ago Closed 1 month ago

Port bug 1974184: Enable AES support for encrypting logins with the SDR and migrate all existing logins

Categories

(Thunderbird :: Upstream Synchronization, enhancement)

Thunderbird 144
enhancement

Tracking

(thunderbird_esr140 unaffected, thunderbird143 unaffected)

RESOLVED FIXED
146 Branch
Tracking Status
thunderbird_esr140 --- unaffected
thunderbird143 --- unaffected

People

(Reporter: darktrojan, Assigned: KaiE, NeedInfo)

References

Details

Attachments

(3 files)

We've got a test failure I don't quite understand, and we should trigger this migration in the same way Firefox has. The ESR 140 login manager does not support AES so migrating would break all logins on a downgrade to 140.

The test in question is test_imapPasswordFailure.js, it installs premade key4.db and logins.json files, which work initially then when a login is updated they fail. I'm not sure why this is, surely there should be backwards compatibility here. I could make the test pass by creating new versions of the files, but I'm not sure that should be necessary.

Oh and the SMTP, POP3, and NNTP versions of the test also fail.

In a separate issue, if I port the migration changes, the migration fails with a rejection we can't catch, when there's no passwords to reencrypt:

FAIL test_migrateTryStartTLS - [test_migrateTryStartTLS : 266] A promise chain failed to handle a rejection: Need at least one ciphertext to decrypt - stack: decryptMany@resource://gre/modules/crypto-SDR.sys.mjs:226:24

This is a backwards-incompatible change. A profile that goes through this migration will not have
usable logins if downgraded to ESR 140.

Despite the attached patches, we're trying to understand what is causing the failure, because the assumption is that it shouldn't fail.

I see we execute the test twice, once with maildir and once with mbox.

If I disable either one of the tests in mailnews/imap/test/moz.build then the failure is gone.

However, it doesn't appear to be a simple race, because enabling both and running the test with "test --sequential" we still fail.

With both tests enabled and --sequential, and some more logging, we still have 1 login saved after resetTest, but after performTest there are 0 logins saved. Same for both tests that are running one after the other.

I cannot yet explain.

Explanation:

Our password testing, and password prompting simulation code, will call an async function for storing the known-good password:
Services.logins.addLoginAsync()

As soon as we reach that function, it apparently removes the old stored password.

Our test code continues immediately, and the new login data has not yet been stored. We're not waiting for it.
Waiting for addLoginAsync() would probably require to change a lot of our password prompting code to use async functions and await.
(functions promptPassword and promptUsernameAndPassword and call the callers)

In theory we could try to change our logic to call nsILoginManager.modifyLogin instead, because that's a synchronous function. But comments say that function is only retained for Thunderbird compatibility, not sure how long that function will continue to be available. So it wouldn't be a long term fix.

The easiest fix is to use the new files that Geoff provided, which already contain the new password, which means that during testing we don't need to re-encrypt/change the passwords, so we simply avoid that temporarily no password is stored.

I'll attach a patch that uses another callback to report the promise for saving the login.
It seems a bit ugly, but it fixes the failures.
Do you want that, or maybe it inspires you to find a cleaner fix?

(In reply to Kai Engert [:KaiE:] from comment #7)

I'll attach a patch that uses another callback to report the promise for saving the login.
It seems a bit ugly, but it fixes the failures.
Do you want that, or maybe it inspires you to find a cleaner fix?

While that fixes the IMAP test, we're still failing in various other tests, which would require a similar fix.
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=c359a8c4d19e869aa998f4a001d048681fba007d

Pushed by jtracey@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/b4ab2bdda63c
Update logins files for tests. r=kaie

Assignee: geoff → kaie

(In reply to Geoff Lankow (:darktrojan) from comment #2)

In a separate issue, if I port the migration changes, the migration fails with a rejection we can't catch, when there's no passwords to reencrypt:

FAIL test_migrateTryStartTLS - [test_migrateTryStartTLS : 266] A promise chain failed to handle a rejection: Need at least one ciphertext to decrypt - stack: decryptMany@resource://gre/modules/crypto-SDR.sys.mjs:226:24

FYI, this is also a problem in Firefox. I am taking a look at it in Bug 1987673.

See Also: → 1987673

Geoff, could you please r+ this one?
I made the change you asked for
https://phabricator.services.mozilla.com/D262952

Flags: needinfo?(geoff)
Pushed by kaie@kuix.de: https://hg.mozilla.org/comm-central/rev/2edfc6ae9e4f Migrate existing logins to use AES. r=kaie

Pushed by kaie@kuix.de:
https://hg.mozilla.org/comm-central/rev/35842fc1e059
Wait for updated logins when testing IMAP passwords. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED

This seems to have an incorrect Milestone since the 2025-10-22 was during the 146 cycle. It also shows up on
https://www.thunderbird.net/en-US/thunderbird/146.0beta/releasenotes/

Target Milestone: 144 Branch → 146 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: