Closed Bug 1667054 Opened 4 years ago Closed 4 years ago

After importing secret key OpenGPG Key Manager shows properties of wrong key.

Categories

(MailNews Core :: Security: OpenPGP, defect, P1)

Tracking

(thunderbird_esr68 unaffected, thunderbird_esr78+ fixed, thunderbird83 affected)

RESOLVED FIXED
84 Branch
Tracking Status
thunderbird_esr68 --- unaffected
thunderbird_esr78 + fixed
thunderbird83 --- affected

People

(Reporter: blacklion, Assigned: aleca)

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0

Steps to reproduce:

  1. Open Thunderbird 78.3.0 (candidate).
  2. Open Tools|OpenPGP Key Manager.
  3. Select File|Import Secret Key(s) From File.
  4. Select gpg-exported secret key file.
  5. Ensure, that one key is found and marked with checkbox.
  6. Click Continue.
  7. On dialog with (successful results) click Key Properties.

Actual results:

Properties of some random public key from key storage are shown.

Expected results:

Properties of freshly-imported personal secret key are shows,

Attached image Results of import
Component: Untriaged → Security: OpenPGP
Product: Thunderbird → MailNews Core

Can anyone reproduce this bug?

Flags: needinfo?(alessandro)
Flags: needinfo?(alessandro)

Andreas, can you reproduce?

Flags: needinfo?(ak.bugzilla)

Yes, I can reproduce this as described with Thunderbird 78.4.
The key properties shown in the last import dialog are the ones from the key which is preselected in the key manager list, not from the newly imported key.

This error doesn't occur when importing a key through the account settings tab.

Flags: needinfo?(ak.bugzilla)

Thanks for confirming this, I'll take care of fixing it.

Assignee: nobody → alessandro
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Keywords: regression
Priority: -- → P1
Attached patch 1667054-key-properties.diff (obsolete) — Splinter Review

The problem was in the enigmailKeyDetails() method of the Key Manager that was always and only opening properties of selected keys, ignoring the passed value of the recently imported key.

This patch fixes it, alongside a small UI fix.

Attachment #9186381 - Flags: review?(kaie)

Comment on attachment 9186381 [details] [diff] [review]
1667054-key-properties.diff

Pinging Magnus for a review as well just to see if I can get a quicker review since this is a quick fix but pretty important for error prevention.

Attachment #9186381 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9186381 [details] [diff] [review]
1667054-key-properties.diff

>+function enigmailKeyDetails(keyId = null) {
>+  let keyList = getSelectedKeys();

if you already have a keyId, it it seems better to avoid calling getSelectedKeys()

>+  // Interrupt if we don't have a selected key nor a key was passed.
>+  if (!keyId && !keyList.length) {
>+    return;
>+  }
>+
>+  let selectedKey = keyId || gKeyList[keyList[0]].keyId;
>+  if (EnigmailWindows.openKeyDetails(window, selectedKey, false)) {
>+    refreshKeys();
>   }
> }

It's a matter of taste, but I think the following is cleaner, it avoids the unnecessary call, and it protects you against an null keyId in gKeyList:

  // Interrupt if we don't have a selected key nor a key was passed.
  if (!keyId) {
    let keyList = getSelectedKeys();
    if (!keyList.length) {
      return;
    }
    keyId = gKeyList[keyList[0]].keyId;
  }
  if (!keyId) {
    return;
  }
  if (EnigmailWindows.openKeyDetails(window, keyId, false)) {
    refreshKeys();
  }
Attachment #9186381 - Flags: review?(kaie)

The second if (!keyId) check shouldn't be necessary.

Thanks for the review

Attachment #9186381 - Attachment is obsolete: true
Attachment #9186381 - Flags: review?(mkmelin+mozilla)
Attachment #9187008 - Flags: review?(kaie)
Attachment #9187008 - Flags: review?(kaie) → review+
Target Milestone: --- → 84 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/945a6cae42e2
Fix incorrect key reported in Key Properties dialog after importing secret key from the Key manager. r=KaiE

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED

Comment on attachment 9187008 [details] [diff] [review]
1667054-key-properties.diff

[Approval Request Comment]
Regression caused by (bug #): unknown
User impact if declined: confusing import experience
Testing completed (on c-c, etc.): c-c + beta
Risk to taking this patch (and alternatives if risky): fairly safe

Attachment #9187008 - Flags: approval-comm-esr78?

Comment on attachment 9187008 [details] [diff] [review]
1667054-key-properties.diff

[Triage Comment]
Approved for esr78

Attachment #9187008 - Flags: approval-comm-esr78? → approval-comm-esr78+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: