DEADBEEF vs SHA1

David Shaw <dshaw@jabberwocky.com> Thu, 17 February 2011 19:12 UTC

Received: from hoffman.proper.com (localhost [127.0.0.1]) by hoffman.proper.com (8.14.4/8.14.3) with ESMTP id p1HJCPqk027523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 Feb 2011 12:12:25 -0700 (MST) (envelope-from owner-ietf-openpgp@mail.imc.org)
Received: (from majordom@localhost) by hoffman.proper.com (8.14.4/8.13.5/Submit) id p1HJCP6A027522; Thu, 17 Feb 2011 12:12:25 -0700 (MST) (envelope-from owner-ietf-openpgp@mail.imc.org)
X-Authentication-Warning: hoffman.proper.com: majordom set sender to owner-ietf-openpgp@mail.imc.org using -f
Received: from walrus.jabberwocky.com (walrus.jabberwocky.com [173.9.29.57]) by hoffman.proper.com (8.14.4/8.14.3) with ESMTP id p1HJCMla027516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <ietf-openpgp@imc.org>; Thu, 17 Feb 2011 12:12:23 -0700 (MST) (envelope-from dshaw@jabberwocky.com)
Received: from dshaw.nasuni.net (gw-comcast1.nasuni.com [173.166.63.186]) (authenticated bits=0) by walrus.jabberwocky.com (8.14.4/8.14.4) with ESMTP id p1HJCKap000725 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for <ietf-openpgp@imc.org>; Thu, 17 Feb 2011 14:12:21 -0500
From: David Shaw <dshaw@jabberwocky.com>
Content-Type: text/plain; charset=us-ascii
Subject: DEADBEEF vs SHA1
Date: Thu, 17 Feb 2011 14:12:20 -0500
Message-Id: <D8E81788-AF18-448F-BA39-56185C1F0672@jabberwocky.com>
To: IETF OpenPGP Working Group <ietf-openpgp@imc.org>
Mime-Version: 1.0 (Apple Message framework v1081)
X-Mailer: Apple Mail (2.1081)
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by hoffman.proper.com id p1HJCNlZ027517
Sender: owner-ietf-openpgp@mail.imc.org
Precedence: bulk
List-Archive: <http://www.imc.org/ietf-openpgp/mail-archive/>
List-Unsubscribe: <mailto:ietf-openpgp-request@imc.org?body=unsubscribe>
List-ID: <ietf-openpgp.imc.org>

Hi everyone,

I was thinking about Daniel Gillmor's proposal to include the complete fingerprint in signatures, and specifically this:

> But a devious attacker could potentially create a colliding Key ID (i
> believe collisions of the low 64 bits of SHA1 are within reach today,
> i'd love to be corrected if this is not the case) and cause the
> user-friendly MUA to assume it is in state B when it is actually in
> state A.  The attacker doesn't even need access to the message or
> signature in question to do this.  They'd only need to have been able to
> supply a key to the user at some time in the past.  (e.g. push a new
> subkey to the keyservers which a user pulls during a keyring refresh)

It occurred to me that it doesn't actually matter whether a 64-bit SHA-1 collision is feasible today or not.  There is a much easier collision that makes this attack trivial without going up against SHA-1 at all.

OpenPGP uses the 64-bit key ID to find the right key to verify a signature (via the issuer subpacket).  However that key ID doesn't have to be the lower 64 bits of the fingerprint like it is in V4.  In V3, it was the lower 64 bits of the modulus, which is trivial to set to whatever the attacker likes (i.e. the DEADBEEF key problem).  The problem is that the issuer subpacket doesn't differentiate between V3 and V4, so it's possible to make a DEADBEEF V3 key and use it to do a version rollback / denial of service attack against a V4 key.

For example, Alice's key (either V3 or V4) has a key ID of E435AEDF689E2211.  Mallory makes a V3 key, matches the key ID E435AEDF689E2211, and distributes it ahead of Alice.  Now any signatures that Alice issues will result in a "bad signature" error, since they will be verified against the wrong key.

To test, I made both Alice's and Mallory's key and tested with both PGP (9.10) and GPG (1.4 from git).  Basically, the attack works as expected.  Not surprisingly, once one key is imported, you can't import the other one without explicitly deleting the first.  When trying to import the second key, GPG fails with "key 689E2211 doesn't match our copy".  PGP silently ignores the new key.  Not allowing a new key to replace an old one does make some sense (after all, how would the implementation know which is "real" and which is "fake"?), but I can see this being a frustration.  Of course, this is a double-edged sword, since if Alice beats Mallory into the keyring, Mallory is locked out.

In terms of the issue that originally started this thread, the proposal to include and compare the complete fingerprint resolves this attack as well (slightly better in this case, in fact, since a V3 fingerprint can't even accidentally collide with a V4 one).

That said, however, (and switching over to implementation thoughts here) given how easy it is to make a V3 DEADBEEF key that collides with a real V4 key, I wonder if it would also be useful for implementations to simply refuse (or at least give the option to refuse) to import any V3 keys.  That might not have been feasible 10 years ago, but nowadays, I suspect most people would not even notice.  Standards-wise, that is fine as 4880 does not require V3 (discourages it, in fact: MUST NOT create, and only MAY accept).

I've pasted the test keys below if anyone wants to play with them.

David

p.s. the PKESK packet doesn't differentiate between V3 and V4 either but the attack is less obvious there - the victim would have to encrypt to the wrong key, and we at least theoretically have the means to discourage this via the web of trust.  It would still be an annoyance, though.

Alice:

-----BEGIN PGP PRIVATE KEY BLOCK-----

lQOYBE1b9LkBCADgluafn3zba/PMOZqlfNgma16vJ0lpZO9535NgJQEQulSLHzQx
vqoTRSF/KEGjzwWpPD1LLl0ZojeVAX6quGCM0n0wVncGU3TfurPpS9VB7/7R32gY
5eTgQqGx6pFY7KqReIYvIE5pkr5Dc8/eqZxOkQgzCFlH4h4itQqvo1TK35RpcUne
i0lHUEDaYySVYpIdAmOoMLgus5vU/bocwBfpo+GxdTkWtxoWY/4h/vY+lyO3r/qH
mDk9EddxAurR/TjtWe5INxuwXJIsGmmJDdFR7FJ1cAmsYLvF3QsH8qu/89zOZL9+
oV2vcVCPXoG+l0itmDrDY33rY9xP+rG2KL4XABEBAAEAB/0eVXisF0AnlBVnVbcZ
IkXrgoBVC0BeF3+aKA62uKjD1/bdR4dRhLK3TD9cS6qknlc3EWd8ml7WvH3iBplT
ePhewiXzJmqIad3qQ0RTfqY8yVZ92ufWHQ7kaft+6p4GXbN4AchV4HjWx4wifieV
p7ZF4k7c3a7Oslq8Tf7gfstQDyaDDO4d1fBWuE5C3roQI002zOm7XhtFCsc2ANK3
a7Lo1MGJHezacM6D+pNgUfpJaZnhtF6osXmO3ZRrqO47lgzN1K1HsiexvghmLC9r
GjupbOr5g9VFzuAey4SpQalXoL04Xm0rlmHRVdrCKQXeHVZ+Mxk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