Re: [jose] Secdir review of draft-ietf-jose-json-web-signature-31

Mike Jones <Michael.Jones@microsoft.com> Fri, 19 September 2014 19:03 UTC

Return-Path: <Michael.Jones@microsoft.com>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 435DF1A04FA; Fri, 19 Sep 2014 12:03:13 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.902
X-Spam-Level:
X-Spam-Status: No, score=-1.902 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham
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 ylNlBRXImlRE; Fri, 19 Sep 2014 12:03:09 -0700 (PDT)
Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0743.outbound.protection.outlook.com [IPv6:2a01:111:f400:fc10::743]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 07A881A02EB; Fri, 19 Sep 2014 12:03:08 -0700 (PDT)
Received: from CH1PR03CA009.namprd03.prod.outlook.com (10.255.156.154) by BY2PR0301MB0696.namprd03.prod.outlook.com (25.160.63.150) with Microsoft SMTP Server (TLS) id 15.0.1034.13; Fri, 19 Sep 2014 19:02:45 +0000
Received: from BL2FFO11FD047.protection.gbl (10.255.156.132) by CH1PR03CA009.outlook.office365.com (10.255.156.154) with Microsoft SMTP Server (TLS) id 15.0.1034.13 via Frontend Transport; Fri, 19 Sep 2014 19:02:44 +0000
Received: from mail.microsoft.com (131.107.125.37) by BL2FFO11FD047.mail.protection.outlook.com (10.173.161.209) with Microsoft SMTP Server (TLS) id 15.0.1029.15 via Frontend Transport; Fri, 19 Sep 2014 19:02:44 +0000
Received: from TK5EX14MBXC286.redmond.corp.microsoft.com ([169.254.1.23]) by TK5EX14HUBC101.redmond.corp.microsoft.com ([157.54.7.153]) with mapi id 14.03.0195.002; Fri, 19 Sep 2014 19:02:32 +0000
From: Mike Jones <Michael.Jones@microsoft.com>
To: Tero Kivinen <kivinen@iki.fi>
Thread-Topic: Secdir review of draft-ietf-jose-json-web-signature-31
Thread-Index: AQHPyDgrWdMUgOdf8EqNa4N9Ytbe4ZvzQwoggARGNkCADAcqAIAFVMkQ
Date: Fri, 19 Sep 2014 19:02:32 +0000
Message-ID: <4E1F6AAD24975D4BA5B16804296739439BA5A04D@TK5EX14MBXC286.redmond.corp.microsoft.com>
References: <21512.21725.209461.976375@fireball.kivinen.iki.fi> <4E1F6AAD24975D4BA5B16804296739439AEABA21@TK5EX14MBXC292.redmond.corp.microsoft.com> <21528.638.485017.482257@fireball.kivinen.iki.fi>
In-Reply-To: <21528.638.485017.482257@fireball.kivinen.iki.fi>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [157.54.51.71]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-EOPAttributedMessage: 0
X-Forefront-Antispam-Report: CIP:131.107.125.37; CTRY:US; IPV:CAL; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(438002)(199003)(377454003)(189002)(164054003)(51704005)(13464003)(97756001)(74662003)(50466002)(77096002)(74502003)(97736003)(77982003)(106466001)(81156004)(80022003)(86362001)(46102003)(81542003)(81342003)(79102003)(106116001)(46406003)(90102001)(15202345003)(84676001)(85806002)(20776003)(230783001)(64706001)(31966008)(68736004)(66066001)(4396001)(95666004)(47776003)(26826002)(15975445006)(69596002)(21056001)(76482002)(33656002)(50986999)(19580405001)(83322001)(107046002)(83072002)(19580395003)(2656002)(85852003)(86612001)(110136001)(6806004)(76176999)(54356999)(23726002)(99396002)(104016003)(87936001)(85306004)(92726001)(55846006)(44976005)(92566001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB0696; H:mail.microsoft.com; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en;
X-Microsoft-Antispam: UriScan:;
X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0696;
X-O365ENT-EOP-Header: Message processed by - O365_ENT: Allow from ranges (Engineering ONLY)
X-Forefront-PRVS: 0339F89554
Received-SPF: Pass (protection.outlook.com: domain of microsoft.com designates 131.107.125.37 as permitted sender) receiver=protection.outlook.com; client-ip=131.107.125.37; helo=mail.microsoft.com;
Authentication-Results: spf=pass (sender IP is 131.107.125.37) smtp.mailfrom=Michael.Jones@microsoft.com;
X-OriginatorOrg: microsoft.onmicrosoft.com
Archived-At: http://mailarchive.ietf.org/arch/msg/jose/LTq79tc-BSCSmMjceaHdc4YAVAw
Cc: "jose@ietf.org" <jose@ietf.org>, "ietf@ietf.org" <ietf@ietf.org>, "iesg@ietf.org" <iesg@ietf.org>, "draft-ietf-jose-json-web-signature.all@tools.ietf.org" <draft-ietf-jose-json-web-signature.all@tools.ietf.org>, "secdir@ietf.org" <secdir@ietf.org>
Subject: Re: [jose] Secdir review of draft-ietf-jose-json-web-signature-31
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jose>, <mailto:jose-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/jose/>
List-Post: <mailto:jose@ietf.org>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jose>, <mailto:jose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 19 Sep 2014 19:03:13 -0000

Tero - for your point "2) Hash inside "alg" and inside the signature", could you please write proposed security considerations text addressing this issue?  I'd think it should describe the need for implementations to ensure that signature verification is done for the exact algorithm specified in the "alg" header parameter, no matter what algorithm information may (or may not) have been encoded into the signature value in an algorithm-specific manner.

For your point "3) There is no explicit warning about the "alg" "none"", I plan to add the additional step that you suggested.

For your point "4) Thumbprint formats" if you or someone else wants to define an additional thumbprint format for use in IoT contexts (or any other contexts), I encourage you to write an Internet Draft that does so, registering the new header parameter defined in the JSON Web Signature and Encryption Header Parameters registry.

				Thanks,
				-- Mike

-----Original Message-----
From: Tero Kivinen [mailto:kivinen@iki.fi] 
Sent: Tuesday, September 16, 2014 2:27 AM
To: Mike Jones
Cc: iesg@ietf.org; secdir@ietf.org; ietf@ietf.org; draft-ietf-jose-json-web-signature.all@tools.ietf.org; jose@ietf.org
Subject: Re: Secdir review of draft-ietf-jose-json-web-signature-31

Mike Jones writes:
>> This document is part of the jose-json document set, and describres 
>> the JSON Web Signatures.
>> 
>> The security considerations section includes text which says:
>> 
>>    The entire list of security considerations is beyond the scope of
>>    this document, but some significant considerations are listed here.
>> 
>> but also lists quite a lot of security considerations. I think the 
>> security considerations covering this document should be in scope 
>> with the document. Of course there are generic security 
>> considerations which might be outside the scope of this document, but 
>> I do not think we need to explictly mention those.
>
> Several reviewers have objected to this sentence.  Its removal is 
> planned.

Good. 

>> 2) Hash inside "alg" and inside the signature
>> 
>> Also in some cases the signature itself has the hash function stored 
>> internally, i.e. RSASSA-PKCS1-V1_5 contains the hash function oid 
>> inside the signature, so what should the implementation do if the 
>> "alg" parameter outside the signature does not match the oid inside 
>> the signature? I.e the signature using "alg" of "RS256", but inside 
>> the signature the oid is using the "SHA1". Most crypto libraries will 
>> just take the oid from the signature, and use that to verify the 
>> message. Adding some description what to do in such situation would 
>> be needed.
>> 
> I think there's some confusion here, since the JWS spec does not use 
> any OIDs or ASN.1 for signatures. Rather, the cryptographic operations 
> to be performed are fully specified by the "alg" value and the 
> signatures are represented as base64url encoded octet sequences 
> representing the signature values produced by the signature 
> algorithms.

But JWS uses RSASSA-PKCS1-V1_5, which DOES have ASN.1 inside. I.e. if you look at the RFC3447 section 8.2 (referenced from the
draft-ietf-jose-json-web-algorithms-31) you will see that when you generate signature, you first to EMSA-PKCS1-V1_5-ENCODE operation (section 9.2 of RFC3447) to the message. This will take the hash of the message, then create the DigestInfo ASN.1 object, which includes the oid of hash algoritm used in previous step and the actual output of the hash, and finally you encode the EM by padding that DigestInfo with suitable padding. After that you do the RSA operation.

When verifying the signature, you do RSA operation, verify the padding and extract the hash oid and hash value out from the ASN.1 and then generate EM' by doing EMSA-PKCS1-V1_5-ENCODE operation to the original message using hash algorithm specified by the oid extracted by previous operation. 

In most cases the libraries will always do that automatically, and there is no way to specify that you want to use some other algorith, than what is stored in the ASN.1, as if you use any other algorithm that was exactly same than what was stored in the ASN.1 inside the RSA signature the verification will fail.

In your case there is now two algorithms, the outer "alg" algorithm and the one inside the signature itself. So even if the outer "alg"
says "RS256", the hash used in the signature might be MD5, and most crypto libraries will simply verify the signature fine, and this can cause security problems. 

>> 3) There is no explict warning about the "alg" "none".
>> 
>> In the section 5.2 it says that "at least one signature ... MUST 
>> successfully validate", but that does not limit alg "none" out from 
>> it. I.e. if the application policy is to "one signature needs to 
>> validate", and it gets JWS that has "none" as one of the algorithms, 
>> then it will accept it.
>> 
>> I think there should be warning here or in the security 
>> considerations section about the "none" algorithm, especially as the 
>> algorithm itself is defined in the different draft (perhaps just 
>> reference to the section 8.5 of the [JWA] draft).
> 
> This warning is present in the spec where the algorithm is defined 
> specifically -
> http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-31
> #section-8.5. (Note that the working group decided to define 
> algorithms in a separate spec than the ones in which they are used.)
> 
> Also note that it is up to applications which algorithms are 
> acceptable in a given context - not just "none" but also other 
> algorithms that might be deprecated or inappropriate for some other 
> reason. Unless the signature algorithm used is acceptable to the 
> application, it should not accept the JWT.

The current draft does not have any steps for such policy checks. So it would be good to add new step in section 5.2 which says that verify that the algorithms used in the signature are allowed by the policy in the current context. Also noting that "none" is not really usable signature algoritm ever... 

>> 4) Thumbprint formats
>> 
>> Section 4.1.7 and 4.1.8 defines a x5t and x5t#S256 thumbprints, but 
>> those are over the whole certificate.
>> 
>> With the thumbprints, it has been noted lately, that quite often it 
>> is more useful to use the hash of the SubjectPublicKeyInfo object of 
>> the
>> 
>> X.509 certificate, than the full X.509 certificate. This method has 
>> been used in the raw public key methods (draft-ietf-tls-oob-pubkey, 
>> draft-kivinen-ipsecme-oob-pubkey), and also in the DANE (it has two 
>> options one for the full certificate and another for the 
>> SubjectPublicKeyInfo object of the certificate).
>> 
>> Using hash of the SubjectPublicKeyInfo object allows changing the 
>> certificate without invalidiating the certificates, i.e. when 
>> changing CAs, or switching from SHA1 to SHA2 in certificates, or just 
>> renewing the certificate. It also allows using raw public keys which 
>> do not have defined X.509 certificate format, but which can be 
>> converted to the SubjectPublicKeyInfo object when calculating the 
>> thumbprints. This is very important in the Internet of Things type of 
>> things, which might not be using the full X.509 certificates.
> 
> This thumbprint definition matches existing practice in commonly used 
> software packages. For instance, both openssl and Windows use 
> certificate thumbprints of this kind.

Yes, I am not saying we should remove them. 

> That being said, there's nothing preventing another specification from 
> defining a different thumbprint calculation over the SPKI information 
> and a header parameter used to represent it. The header parameters are 
> extensible via a registry.

Yes, but as I think those formats using SPKI are much more usable, especially in the internet of things contextes, it might be good idea to define them now, not year later. On the other hand if these formats are not meant to be used in the Internet of Things contextes, then never mind... 

>> 5) Terminology ordering.
>> 
>> Terminology is not in any order. It would be useful to have it either 
>> in logical order (i.e. define terms before they are used), or in 
>> alphabetical order.
>> 
>> Now for example the "JWS Protected Header" is used before it is 
>> defined in the "JWS Signature", and "Header Paramater" is between 
>> "JWS Signature" and "JWS Protected Header", also "JWS Signature"
>> uses both "JWS Payload" and "JWS Protected Header", and one of those 
>> is defined before and one after the "JWS Signature".
> 
> The terms are listed in top-down order, with related terms grouped 
> together. Thus "JSON Web Signature" is first, the members that make up 
> a JWS object are listed together in the order that they appear in a 
> JWS, etc. That being said, I'll plan to review the orderings and make 
> sure that they consistently follow those ordering rules.

Ok, thanks.
--
kivinen@iki.fi