Re: [Trans] Mutability of Certificate Signatures

Andrew Ayer <agwa@andrewayer.name> Tue, 06 June 2017 17:00 UTC

Return-Path: <agwa@andrewayer.name>
X-Original-To: trans@ietfa.amsl.com
Delivered-To: trans@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E55461294AC for <trans@ietfa.amsl.com>; Tue, 6 Jun 2017 10:00:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.002
X-Spam-Level:
X-Spam-Status: No, score=-2.002 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=andrewayer.name
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ehV7wCvXQ3Sq for <trans@ietfa.amsl.com>; Tue, 6 Jun 2017 10:00:24 -0700 (PDT)
Received: from alcazar.beanwood.com (alcazar.beanwood.com [70.85.129.230]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 320881270FC for <trans@ietf.org>; Tue, 6 Jun 2017 10:00:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=andrewayer.name; s=beanwood20160511; t=1496768423; bh=RAtp+ZloiKhYRCjZAQ5+LX4naTU3ObgyP8Kp1AJ32M0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=YEEsxibU/y649qRoZugwubH7+48ndb1cfkQXQUXcGLA1zTgKpSH+7tcJR0K52KJ+Y BB/fSoU9Oh9BJj5udgyOSyzGBbBqLMvbyNj+318YgROauSNA//68dHPsZvY4mnyPIw 4B/ndDXqWuNGOy9ToGFaRYfgZOJBdYHCY+BbRxiQLfQh8NL8kCZejwqSKrb1aFLc62 U2puJFKXli3UqKCo2oc3dPnGYSgJUduQKEGT3OKk0B4xF/toOIvlkvE1gnoy8UU7bb AGvsol9KY2RGeUeqYFylSRVPlZn80DeRnsYTB2G3zMTFYBoFzcmXJxny0HogrIvyDC Y7GyxveU/Pb1Q==
Date: Tue, 06 Jun 2017 10:00:22 -0700
From: Andrew Ayer <agwa@andrewayer.name>
To: Eran Messeri <eranm@google.com>
Cc: "trans@ietf.org" <trans@ietf.org>
Message-Id: <20170606100022.581f35cc2775fcc3abdfcfa2@andrewayer.name>
In-Reply-To: <CALzYgEc6fV7n3mDFfDP9gktA7igghVA7duRWYMytzKAZ51O3sQ@mail.gmail.com>
References: <20170528191028.20f285073eea33a3f23b6b5a@andrewayer.name> <CALzYgEc6fV7n3mDFfDP9gktA7igghVA7duRWYMytzKAZ51O3sQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/trans/7_Ma9Y__14cVFyOOApDvxvUKRDk>
Subject: Re: [Trans] Mutability of Certificate Signatures
X-BeenThere: trans@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Public Notary Transparency working group discussion list <trans.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/trans>, <mailto:trans-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/trans/>
List-Post: <mailto:trans@ietf.org>
List-Help: <mailto:trans-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/trans>, <mailto:trans-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 06 Jun 2017 17:00:26 -0000

On Mon, 5 Jun 2017 22:42:08 +0300
Eran Messeri <eranm@google.com> wrote:

> I think that the suggestion to fix this by defining as misbehaviour
> the presentation of an incorrectly-signed certificate chain in
> get-entries is the right one.
> Reasoning:
> - An SCT is useless to an attacker without a valid signature over the
> certificate/precertificate: The collusion described above is only
> harmful if a CA an a log are compromised, and even then, all it
> enables is for the CA to wash its hands of a particular certificate
> (which wouldn't be accepted by TLS clients without a valid signature).
> - It is pretty straightforward for a monitor to validate that all
> chains presented in get-entries are valid chains.
> - If we can't solve it properly for precertificates, then having
> different security guarantees for different kinds of entries  would
> be confusing, at best.
> 
> The upside of the change to only use the TBSCertificate + Issuer key
> hash in the log entry is that it's much easier to reconstruct the
> input for SCT signature validation: The same code is used for certs
> and precertificates.

You raise a good point: since there are far more TLS clients than
monitors, it makes more sense to fix this problem by adding complexity
to monitors than to TLS clients.  So I agree that defining this as
misbehavior and having monitors check is the right solution.

Let's make sure we agree what monitors need to check for certificates
(mutatis mutandis for precertificates):

1. The tbs_certificate in the x509_entry_v2 TransItem structure returned
by get-entries must be byte-for-byte identical to the TBSCertificate
portion of the leaf_certificate in the corresponding X509ChainEntry
structure returned by get-entries.

2. The issuer_key_hash in the x509_entry_v2 TransItem structure returned
by get-entries must correspond to the public key of the issuer of the
leaf_certificate in the corresponding X509ChainEntry structure returned
by get-entries.

3. The signature of the leaf_certificate in the X509ChainEntry
structure returned by get-entries must be a valid signature from the
key of its issuer.

How should a monitor get the issuer public key to perform checks 2 and
3? The obvious way is to look at the first item in the X509ChainEntry's
certificate_chain if the certificate is not self-signed, and at the
certificate itself if it is self-signed.

Unfortunately, if the logged certificate is a non-self-signed trust
anchor accepted by the log, then certificate_chain is empty and there
is no way to get the issuer public key.  So a log could evade
responsibility by making the certificate with a mutated signature a
trust anchor.

The inability to always get the issuer public key has been an
inconvenience for me when monitoring RFC6962 logs. Sometimes I end up
with a certificate and all I know about its issuer is its subject, when
ideally I would like to know its public key as well (since a CA is
uniquely identified by its subject and public key).  (I suspect crt.sh
has the same problem, based on some weird things I've observed there.)
I previously considered this a mere inconvenience, but now I see it as a
security problem.

I think that the TimestampedCertificateEntryDataV2 structure should
contain the full public key of the issuer instead of just its hash.
That way, monitors are guaranteed access to the issuer public key, and
it's easy to get.  Step 2 above could be eliminated, and step 3 becomes
simpler (no need to parse the issuer certificate to extract the public
key).

Thoughts?

Regards,
Andrew