inline gpg can be corrupted by non-gpg aware mail clients (e.g. gmail)

Bug #894045 reported by graingert
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

I submit 4cfcc785e7e9294a84a55160991c1a9f5f6eec4f to the +editpgpkeys page

when I actually get an email message with a bad pgp message:

$ echo "-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.10 (GNU/Linux)

hQIMAxq+iuq21RFEAQ//VEXK0W4BV+9wlItjVxbbpvBbVltYA3U9t+Ndc1HfjJEa
xWlW+ivoVRzEzzvNftQNX8uJws9PPxzxGkLJPPQJsaq+moqjHm8hfd+56O1IxnEX
TZ2OiH6AvH8Q1sxrnv0o6tejf1kuhtIVzm/anaYOOUxfZqZBh0BHM9b88xS0Wcc3
f7kr0aCkgBqn3DCu+mka6N37JcGmReX5klkdw6n7koweXdxA8zru4F5FF4n36xzG
gzIeVbGxTa2MuGqVHxMx8eT07Llvs3wmVKSDwV9l6aJb63apuGeKaaIhqXOhYbml
lCybB5Zm+EMdTv2lzlsw8RIOcGGIPrWJlTo76VmbhM3PamL4Y1G/H97Lp06xmAk5
bGoIXQjeyKKaTjebbww07U0Rsdj/rJCpLXH8wV3qc3A1EIjNv4ehWIx+W2sLLEe5
8+Hnusv111+fdLKs792fZGkzI6ufpUnHbCxjV2ZFMeBO6DefQuMczVJuXFWh45e3
yMOVkFec0jGWM1WI1bv9mmDbwxKHG/hyFJbI+9KjLPHomqmQGQN6klhcltL+Lvsw
dHP8j4l6rPzY5cQfzUOsPJKYoUqjI++rkhM7dylQtk9XOLo3lC3ubKJkIjKGd8+v
AnyjMaZpU3gJox+7r1ki5uEsDxFnOWnQi2fvQ6ZqjPuX9/AA+vSTTj0BT2tEnO7S
wK8BREKCe9fvpR7ZXMBRfoa13Me/N7k/RZOJXgNQNv/nYGg9AZz+0eCZYfeE14t1
LH1LFtESo9zp3gjwMpvwPcTA7EG3YgKYtuGatbTpwh1eFxfQqd1zt6xtCO5AQ5yX
tFnroqAYnVAke9SdqhYokyX4pZWpzLzS/TG4uVKaaXISnl94dQ5EQT/SxN+f6jHL
RZh1N6wJbpFAEwLlwrQ7pS9JM9I6bTXzDRPCEa3nqwfojK/pWkx6waeZ1yP3mU7z
jwlfV+/mlBPVQHLVv4JJ7Rq22vteHprHDjvo75GyWYO+iEUC30It/3H1DsCHdWyb
+CprA78hPvPtzG9XNH4YlwgcRO6Xh0nOY4U+HqLFJMMbEEgunEdfOlLdjS6Jcvxh
fit+9z1/RLsvT+6wS+D2UH2GJoPMgO37/eIyshH/DmcbEQ6uJdvRTdU3YfKVelu/
c9t6wVHh+rx/Mgg7zwYcL1jaDEpbYXPTqAhM2cKMRTNM
=3DmZwE
-----END PGP MESSAGE-----" | gpg
gpg: CRC error; 999C04 - DC3999

This may have been because I only had revoked keys available to encrypt with and it took till 4096R/B6D51144 got synced with the ubuntu keyserver to be added before it sent me a valid message

Revision history for this message
Gavin Panella (allenap) wrote :

I don't really understand what the problem is. Where did the message originate? What did you expect to happen?

Changed in launchpad:
status: New → Incomplete
Revision history for this message
graingert (tagrain) wrote :

I didn't expect launchpad to send me invalid PGP data. Launchpad should check the CRC before sending messages

Revision history for this message
Gavin Panella (allenap) wrote :

Okay, my problem was discovering where the message originated; Launchpad is a big code base and, off hand, I didn't know of anywhere that generated encrypted mail. Having an unedited copy of the original message, with headers, might have helped me triage this bug more quickly. (It might still be helpful if you could do that.)

Marking as High, but someone with a lot better understanding of PGP/GPG might want to adjust that.

Note to anyone interested in further progressing this bug: a place to start looking is LoginToken.sendGPGValidationRequest().

Changed in launchpad:
status: Incomplete → Triaged
importance: Undecided → High
Revision history for this message
graingert (tagrain) wrote :

Here is the full email:

http://paste.ubuntu.com/748772/

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 894045] Re: invalid crc PHP MESSAGE sent by editpgpkeys

Launchpad sends you a gpg encrypted message when you add a gpg key.

Just to avoid any possibility of corruption while passing it around,
please click 'view original', save that to a file, then attach the
file to this bug.

I think this is a problem with copypaste and mime encoding, similar to
bug 1520. I'm not sure where in the chain the actual problem is.

'=3D' is a quopri escape of a '=' character. If you change it back
to an equals, the mesage can be unpacked correctly.

My guess is that graingert copied this out of the gmail 'view
original' view, which will show the quopri form, which gpg will not
accept. If he/she copies out of the displayed form it should be ok.

If my analysis is correct this is user error but there are a few
things lp could do to avoid the error:

1 - Send the gpg blob as an attachment rather than inline in a text/plain mail.

2 - Not require that people read and respond to an encrypted mail when
they add a gpg key - it's not clear to me that doing so is adding a
great deal of security. I suppose it makes it a bit less likely
someone will blindly confirm addition of a key they don't actually
have, but if an attacker has their web token and if the user confirms
without thinking about it, all is lost anyhow. Instead just send a
plain text mail saying "at $date you added $gpg key foo; if you didn't
do this click here; if you did do this click here to confirm."

Revision history for this message
graingert (tagrain) wrote : Re: invalid crc PHP MESSAGE sent by editpgpkeys

ah yes it's a user error then.

I did this because gmail hides sections it considers "already seen" as I had sent and resent PGP requests multiple times it detected parts of the message as repeated earlier in the "thread"

Thus corrupting the pgp message in the main view.

Sending the message as an asc attachment as well would have prevented this.

Martin Pool (mbp)
summary: - invalid crc PHP MESSAGE sent by editpgpkeys
+ sending pgp inline in plain text causes apparent crpc errors
tags: added: confusing-ui email gpg
summary: - sending pgp inline in plain text causes apparent crpc errors
+ sending pgp inline in plain text causes apparent crc errors
summary: - sending pgp inline in plain text causes apparent crc errors
+ inline gpg can be corrupted by non-gpg aware mail clients (e.g. gmail)
Changed in launchpad:
importance: High → Low
Revision history for this message
Jelmer Vernooij (jelmer) wrote : Re: [Bug 894045] Re: inline gpg can be corrupted by non-gpg aware mail clients (e.g. gmail)

  affectsmetoo

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Me too!

Ended up the same for me as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733195

-GtFiT6T1yQf799arGhJa8UNHShi3xkC0xPSIM3eyQ9LOlBUgRma87bbRjWmLEg=3D=3D
-=3DFdhF
+GtFiT6T1yQf799arGhJa8UNHShi3xkC0xPSIM3eyQ9LOlBUgRma87bbRjWmLEg==
+=FdhF

So had to replace =3D with =
It did look very odd, as the PGP block was not fully justfied.

It looks like gmail is just very broken... Despite quoted-printable encoding.

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

I wonder if the original email set that, or if gmail helpfully "improved" the email to be quoted-printable. I think i want to try if format="flowed" would be any better. Or, I have seen gmail perform better with base64 Content-Transfer-Encoding.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.