Closed Bug 1762832 Opened 2 months ago Closed 25 days ago

Repair broken OpenPGP encrypted message fails with error dialog "1"

Categories

(MailNews Core :: Security: OpenPGP, defect)

Thunderbird 91
defect

Tracking

(thunderbird_esr91 affected)

RESOLVED FIXED
101 Branch
Tracking Status
thunderbird_esr91 --- affected

People

(Reporter: costescuandrei, Assigned: KaiE)

Details

Attachments

(2 files)

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

Steps to reproduce:

In Thunderbird 91.7.0, I received an encrypted email from someone. It says it is corrupted by MSExchange and has a fix/repair button. I clicked the repair button.

In the past we could send and read encrypted emails both ways (using Thunderbird on both ends), even thought it always reported that it's corrupted and needs to be fixed. But the repair button used to work.

Actual results:

I get an error dialog with failure info "1". You have the screenshots attached.
I opened developer tools and put some breakpoints. I seems that "r.boundary" is "" and that is what it does not like - in fixExchangeMsg.jsm : 143

Debug logging (used a conditional breakpoint to see what EnigmailLog.DEBUG would produce) looks like this:

2022-04-04 10:03:54.619 [DEBUG] enigmailMessengerOverlay.js: messageFrameUnload
debugger eval code:1:9
2022-04-04 10:03:54.621 [DEBUG] enigmailMessengerOverlay.js: messageCleanup
debugger eval code:1:9
2022-04-04 10:03:54.621 [DEBUG] enigmailMessengerOverlay.js: setAttachmentReveal
debugger eval code:1:9
2022-04-04 10:03:54.627 [DEBUG] enigmailMsgHdrViewOverlay.js: _listener_onStartHeaders
debugger eval code:1:9
2022-04-04 10:03:54.628 [DEBUG] enigmailMessengerOverlay.js: setAttachmentReveal
debugger eval code:1:9
2022-04-04 10:03:54.628 [DEBUG] enigmailMsgHdrViewOverlay.js: setWindowCallback
debugger eval code:1:9
2022-04-04 10:03:54.654 [DEBUG] enigmailMsgHdrViewOverlay.js: _listener_onEndHeaders
debugger eval code:1:9
2022-04-04 10:03:54.654 [DEBUG] enigmailMessengerOverlay.js: setAttachmentReveal
debugger eval code:1:9
2022-04-04 10:03:54.666 [DEBUG] enigmailMsgHdrViewOverlay.js: this.messageLoad
debugger eval code:1:9
2022-04-04 10:03:54.667 [DEBUG] enigmailMessengerOverlay.js: messageAutoDecrypt:
debugger eval code:1:9
2022-04-04 10:03:54.667 [DEBUG] enigmailMessengerOverlay.js: messageDecrypt: null
debugger eval code:1:9
2022-04-04 10:03:54.678 [DEBUG] enigmailMessengerOverlay.js: messageDecryptCb:
debugger eval code:1:9
2022-04-04 10:03:54.679 [DEBUG] enigmailMessengerOverlay.js: header content-transfer-encoding: ''
debugger eval code:1:9
2022-04-04 10:03:54.679 [DEBUG] enigmailMessengerOverlay.js: header x-enigmail-version: ''
debugger eval code:1:9
2022-04-04 10:03:54.679 [DEBUG] enigmailMessengerOverlay.js: header x-pgp-encoding-format: ''
debugger eval code:1:9
2022-04-04 10:03:54.680 [DEBUG] enumerateMimeParts: partNum="1"
debugger eval code:1:9
2022-04-04 10:03:54.680 [DEBUG] multipart/mixed; boundary="b1_w57onJmGcHfpz00OCZZJG80QVuc8QrRrbkW3OLgJz2o"
debugger eval code:1:9
2022-04-04 10:03:54.680 [DEBUG] 3 subparts
debugger eval code:1:9
2022-04-04 10:03:54.681 [DEBUG] enumerateMimeParts: partNum="1.1"
debugger eval code:1:9
2022-04-04 10:03:54.681 [DEBUG] text/plain; charset="utf-8"
debugger eval code:1:9
2022-04-04 10:03:54.681 [DEBUG] 0 subparts
debugger eval code:1:9
2022-04-04 10:03:54.682 [DEBUG] enumerateMimeParts: partNum="1.2"
debugger eval code:1:9
2022-04-04 10:03:54.682 [DEBUG] application/pgp-encrypted; name="attachment.pgp"
debugger eval code:1:9
2022-04-04 10:03:54.683 [DEBUG] 0 subparts
debugger eval code:1:9
2022-04-04 10:03:54.683 [DEBUG] enumerateMimeParts: partNum="1.3"
debugger eval code:1:9
2022-04-04 10:03:54.683 [DEBUG] application/octet-stream; name="encrypted.asc"
debugger eval code:1:9
2022-04-04 10:03:54.683 [DEBUG] 0 subparts
debugger eval code:1:9
2022-04-04 10:03:54.684 [DEBUG] enigmailMessengerOverlay.js: embedded objects: 1.2 /
debugger eval code:1:9
2022-04-04 10:03:54.684 [DEBUG] enigmailMessengerOverlay: messageDecryptCb: enabling MS-Exchange hack
debugger eval code:1:9
2022-04-04 10:03:54.685 [DEBUG] enigmailMsgHdrViewOverlay.js: updateSecurityStatus: mimePart=1
debugger eval code:1:9
2022-04-04 10:03:54.685 [DEBUG] enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.isCurrentMessage: uri.spec=mailbox:///[some_path]/ThunderbirdProfile/yrzcj7fd.default/Mail/pop.googlemail.com/Inbox?number=5794
debugger eval code:1:9
2022-04-04 10:03:54.685 [DEBUG] uris.jsm: msgIdentificationFromUrl: url.pathQueryRef=/[some_path]/ThunderbirdProfile/yrzcj7fd.default/Mail/pop.googlemail.com/Inbox?number=5794
debugger eval code:1:9
2022-04-04 10:03:54.686 [DEBUG] uris.jsm: msgIdentificationFromUrl: msgNum=5794 / folder=/[some_path]/ThunderbirdProfile/yrzcj7fd.default/Mail/pop.googlemail.com/Inbox
debugger eval code:1:9
2022-04-04 10:03:54.686 [DEBUG] uris.jsm: msgIdentificationFromUrl: url.pathQueryRef=/[some_path]/ThunderbirdProfile/yrzcj7fd.default/Mail/pop.googlemail.com/Inbox?number=5794
debugger eval code:1:9
2022-04-04 10:03:54.686 [DEBUG] uris.jsm: msgIdentificationFromUrl: msgNum=5794 / folder=/[some_path]/ThunderbirdProfile/yrzcj7fd.default/Mail/pop.googlemail.com/Inbox
debugger eval code:1:9
2022-04-04 10:03:54.687 [DEBUG] enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.isCurrentMessage: url=mailbox:///[some_path]/ThunderbirdProfile/yrzcj7fd.default/Mail/pop.googlemail.com/Inbox?number=5794
debugger eval code:1:9
2022-04-04 10:03:54.687 [DEBUG] enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.isCurrentMessage: true
debugger eval code:1:9
2022-04-04 10:03:54.688 [DEBUG] enigmailMsgHdrViewOverlay.js: updateSecurityStatus: found unauthenticated part
debugger eval code:1:9
2022-04-04 10:03:54.688 [DEBUG] enigmailMsgHdrViewOverlay.js: this.updateHdrIcons: exitCode=0, statusFlags=16777216, extStatusFlags=0, keyId=, userId=,
debugger eval code:1:9
2022-04-04 10:03:54.688 [DEBUG] enigmailMsgHdrViewOverlay.js: this.updateMsgDb
debugger eval code:1:9
2022-04-04 10:03:59.069 [DEBUG] enigmailMessengerOverlay.js: fixBuggyExchangeMail:
debugger eval code:1:9
2022-04-04 10:03:59.073 [DEBUG] fixExchangeMsg.jsm: fixExchangeMessage: msgUriSpec: mailbox-message://[some_username]%40gmail.com@pop.googlemail.com/Inbox#5794
debugger eval code:1:9
2022-04-04 10:03:59.074 [DEBUG] fixExchangeMsg.jsm: getMessageBody:
debugger eval code:1:9
2022-04-04 10:03:59.074 [DEBUG] fixExchangeMsg.jsm: getting data from URL [xpconnect wrapped (nsIURI, nsIMsgMailNewsUrl)]
debugger eval code:1:9
2022-04-04 10:03:59.084 [DEBUG] fixExchangeMsg.jsm: analyzeDecryptedData: got 6834 bytes
debugger eval code:1:9
2022-04-04 10:03:59.086 [DEBUG] fixExchangeMsg.jsm: getFixedHeaderData: hdrLines[]:'60'
debugger eval code:1:9
2022-04-04 10:03:59.087 [DEBUG] fixExchangeMsg.jsm: fixExchangeMessage: caught rejection: 1
debugger eval code:1:9
uncaught exception: 1

Expected results:

Message should not be corrupted in the first place (not sure who corrupts that... the email servers? because we use Thuderbird on both ends (Mac <-> Windows)). When corrupted, the repair button should work as before.

If you need more info about the message that I received, let me know.

Maybe you can submit a fix? See https://developer.thunderbird.net/

I would but I don't really understand the code... So I don't have a fix.

Can you please provide a message that you're unable to repair?
I need the original message, unmodified, and simply forwarding messages breaks them.
If you have such a message, please use thunderbird, file save as, and then add the saved file with the .eml extension into a zip file. If you don't want to share the email in public, then please send that zip file to me by personal email to kaie@kuix.de, and in your message, be sure to mention the number of this bugzilla ticket.

I sent it via email.

Thanks. We have code that attempts to repair this kind of message, but it has a bug. It doesn't work if the content-type header is the last header, as in your example.

Assignee: nobody → kaie
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9273465 - Attachment description: Bug 1762832 - Fix broken OpenPGP exchange repairing if content-type is last header. r=mkmelin → Bug 1762832 - Fix broken OpenPGP exchange repairing if content-type is last header. r=PatrickBrunschwig
Attachment #9273465 - Attachment description: Bug 1762832 - Fix broken OpenPGP exchange repairing if content-type is last header. r=PatrickBrunschwig → Bug 1762832 - Fix broken OpenPGP exchange repairing if content-type is last header. r=mkmelin

Pushed by kaie@kuix.de:
https://hg.mozilla.org/comm-central/rev/2fbc49c56157
Fix broken OpenPGP exchange repairing if content-type is last header. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 25 days ago
Resolution: --- → FIXED

Thank you!

Do you have any idea why the message is corrupted/needs repairing in the first place?
It was sent using the same version of Thunderbird (on Mac). Or does one of the email servers (like google) alter/corrupt it?

I don't think Thunderbird ever creates messages like this.

You can verify that easily yourself, by comparing the message that Thunderbird stores in the sent folder, with the version that you receive.
Only the headers until the first blank line should be different.

If any lines below the blank lines are different, then it was modified in transport by email servers.

Target Milestone: --- → 101 Branch

Then it looks like the sender mail server (in this case protonmail) is the one that messes with it... I can receive via the same (receiving) email from other sources just fine it seems.
If you are curious, the message from the sender's "Sent" folder has, after the first empty line:

--aa1d2b0bc2d10ab7642a38b29df650ed46cca8d64904a2a0210c79ad4f3e4b34
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8


--aa1d2b0bc2d10ab7642a38b29df650ed46cca8d64904a2a0210c79ad4f3e4b34
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=attachment.pgp
Content-Type: application/pgp-encrypted; name=attachment.pgp

VmVyc2lvbjogMQ0K
--aa1d2b0bc2d10ab7642a38b29df650ed46cca8d64904a2a0210c79ad4f3e4b34
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=encrypted.asc
Content-Type: application/octet-stream; name=encrypted.asc

While the one from my inbox has this after the first empty line (I guess you already know this):

This is a multi-part message in MIME format.

--b1_61pZsCKpHsWu4FF0CtOwGrthNbrDbwIHo7aCTdh04Y
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Empty Message
--b1_61pZsCKpHsWu4FF0CtOwGrthNbrDbwIHo7aCTdh04Y
Content-Type: application/pgp-encrypted; name=attachment.pgp
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=attachment.pgp

VmVyc2lvbjogMQ0K

--b1_61pZsCKpHsWu4FF0CtOwGrthNbrDbwIHo7aCTdh04Y
Content-Type: application/octet-stream; name=encrypted.asc
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=encrypted.asc

There is also an extra blank line in the received message after the encrypted content - so between that and last --b1_61pZsCKpHsWu4FF0CtOwGrthNbrDbwIHo7aCTdh04Y--. And one other extra blank line at the end of the file.
Maybe it's worth mentioning this to the protonmail team - we'll see. Thanks again & regards.

You need to log in before you can comment on or make changes to this bug.