Closed Bug 2083691 Opened 1 month ago Closed 1 month ago

Clean up the Proton-specific key lookup

Categories

(MailNews Core :: Security: OpenPGP, defect)

defect

Tracking

(thunderbird_esr153 wontfix, thunderbird160 wontfix)

RESOLVED FIXED
161 Branch
Tracking Status
thunderbird_esr153 --- wontfix
thunderbird160 --- wontfix

People

(Reporter: mkmelin, Assigned: mkmelin)

References

Details

Attachments

(1 external file)

Discovered in bug 1998102 and later on, there's some Proton related issues we should clean up there.
Going to do that in this bug, and leave the eventual key server addition to that bug.

Some parts of this were already reviewed in D304043.

Proton serves WKD for its own domains, but can't for custom domains hosted by
Proton.

The site specific URL used to take precedence over WKD: Proton's own
domains were hardcoded to the Proton keyserver, and the MX check meant to
catch custom domains never matched, because DNS.mx() returns MXRecord objects
and the result was compared to hostname strings.

Always try WKD first, and fall back to the Proton keyserver only if the
domain's MX points to Proton, so that we don't query it for addresses whose
mail is handled elsewhere. Keys found this way are recorded with source
"keyserver" instead of "wkd" in the collected keys database.

Also clean up wkdLookup.sys.mjs a bit.

I will write below my understand of the patch, it seems to match what you explained above.

It seems the old code was inefficient, for Proton domains, and for domains that have a Proton MX record in DNS, if the first download attempt from the proton keyserver returns no result, it queried that keyserver server a second time. (Potentially that was handled by the https cache.) Your change fixes that.

You no longer exclude Proton's primary domains in the initial step, you always want to start downloading from WKD from all domains (except from domains that are on our skip-WKD list). That looks good.

(I think function isWkdAvailable() should be renamed, because isWkdAvailable doesn't make any checks for WKD, it simply decides based on a static list whether we want to skip WKD querying. I suggest renaming to skipWKD() and the return value and checks should be negated. Potentially the new function name could even cover more information. Because if a domain is in that list, you want to skip them for the MX record check, too, right? So I think you could name the function skipWKDAndMXOverrides().)

If WKD did not produce a result, and if the domain is not on the skipWKD() list, then you want to always query MX in DNS. (Previously we skipped that for Proton's primary domains, and used proton's api.protonmail.ch/pks directly.)

(This logic also assumes that the list used by skipWKD does not contain any Proton domains.)

If the list of MX hosts includes either mail.protonmail.ch or mailsec.protonmail.ch, then you want to query api.protonmail.ch/pks

"Skip" is a negative so with double negatives it gets hard to read. I'll rename it to shouldLookupByDomain().

Your understanding seems correct. The old code returned the same Proton URL for both WKD attempts, so a miss meant downloading it twice; the patch fixes that. The MX lookup now only runs after both WKD attempts find nothing

Status: NEW → ASSIGNED
Target Milestone: --- → 161 Branch

Pushed by kaie@kuix.de:
https://hg.mozilla.org/comm-central/rev/378d4b30b9e7
Look up keys of Proton hosted domains on the Proton keyserver only when WKD has no key. r=kaie

Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: