Re: [jose] High risk vulnerability in RFC 7515

Quan Nguyen <quannguyen@google.com> Thu, 15 September 2016 02:30 UTC

Return-Path: <quannguyen@google.com>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B679312B141 for <jose@ietfa.amsl.com>; Wed, 14 Sep 2016 19:30:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.208
X-Spam-Level:
X-Spam-Status: No, score=-4.208 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-1.508, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=google.com
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 9LVUPtaM7v9i for <jose@ietfa.amsl.com>; Wed, 14 Sep 2016 19:30:42 -0700 (PDT)
Received: from mail-oi0-x22b.google.com (mail-oi0-x22b.google.com [IPv6:2607:f8b0:4003:c06::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id C529412B13E for <jose@ietf.org>; Wed, 14 Sep 2016 19:30:42 -0700 (PDT)
Received: by mail-oi0-x22b.google.com with SMTP id w11so50774652oia.2 for <jose@ietf.org>; Wed, 14 Sep 2016 19:30:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fwQ+H5AeRzbDZk78KlU8FhH2mBqH4liluxomxpM1E3E=; b=JLZvwijdLcQsj3IqyaG58k3vSwKtyz7p+q4FW1xclQrmSJEldXsdskgwoj8BGsmZwM lIdx/AzDlrkus7pFhzHKBL+3J5uRt7GKYQEhX5sWwAcYxUrjudIDFjX7DtIaiFJMJ+5A qQJYFTSdu7MPhJCHzlngvN5uJP84RlEvHXnYRRIi63D++UK+DUsjWtwyx6HWVaxnrnbo TsDwJLmHAp6EqcQXHE12+duzJZyQyMRK1EezWdatGEwc4euTVw9lHCW0JeC/uDz0W9Qc cNy3P+dfJZBo2TUh36QZPtXFyx83WLEKsViO98JV1Xw4Q31gjadoAGQud2UpmAIATRXH GbPA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fwQ+H5AeRzbDZk78KlU8FhH2mBqH4liluxomxpM1E3E=; b=iCmca7/9LlWKMHiNNhj7YhW2SU5PiDaNeuQVmFOgfATcip7lz2bHbh+1ckaLcIhjF5 KhfqaNQY1zs01CSjQMhFaJVPAXOC9a1uZyRJfXzpS8JR27d/90M8ByQXexWcjCMCBsY+ JIWhHD5aFrQDGfJ8LNfqD4Ka9SOalw2PlGgM+3bJ30mpAivT/yr1VHcdMwPrMxP6JXfu CFrVphf6PRBp1QeZP5cGZ4dsRmIOJHjHcwURu1nqXX5UMCFsScGzlpJTpwPmm+enR1sv hFPZdnAcyYMw2CVnEgqEmVxi4aXspETon66IAdw4QZd47+i8/e8YL/Z2dUu1DIQTeJs2 LtxA==
X-Gm-Message-State: AE9vXwM+wj0c/WgLCUuXSl9Nbq9Te7KGaqqKK8J2fdYZ/YMmtuaVln0+j3DD9JG4F3TFBkiaqhI0YDBon/t3hhgy
X-Received: by 10.202.172.82 with SMTP id v79mr5150644oie.178.1473906641733; Wed, 14 Sep 2016 19:30:41 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.202.52.11 with HTTP; Wed, 14 Sep 2016 19:30:21 -0700 (PDT)
In-Reply-To: <CAPnkLjwyCm1wRN83ir6zCBQKTa_zV32Z_Dhe7NzW046-PoUOXg@mail.gmail.com>
References: <CAKkgqz3GdMG2Q=5jcuLnccWTs4jOjjR_8DzBdoiRE2uEkTLr1g@mail.gmail.com> <CAKkgqz2s8GKSYQ4_LGgupahrkyhmb0e9jWYenLR3X7bMePFy5w@mail.gmail.com> <1473871534.10979.12.camel@redhat.com> <009201d20eb0$16c11030$44433090$@augustcellars.com> <CAPnkLjwyCm1wRN83ir6zCBQKTa_zV32Z_Dhe7NzW046-PoUOXg@mail.gmail.com>
From: Quan Nguyen <quannguyen@google.com>
Date: Wed, 14 Sep 2016 19:30:21 -0700
Message-ID: <CAKkgqz1wtGLq6Rq+nMYBE+V76ZNRCtbcBPO=xxx145MqQnUp2w@mail.gmail.com>
To: Thai Duong <thaidn@google.com>
Content-Type: multipart/alternative; boundary="001a113c37bad08ccd053c82a159"
Archived-At: <https://mailarchive.ietf.org/arch/msg/jose/5T3vpwiX7-NKIY5ReVgwe7x9vNo>
Cc: Jim Schaad <ietf@augustcellars.com>, Nathaniel McCallum <npmccallum@redhat.com>, Michael Jones <mbj@microsoft.com>, jose@ietf.org, John Bradley <ve7jtb@ve7jtb.com>, 崎村夏彦 <n-sakimura@nri.co.jp>
Subject: Re: [jose] High risk vulnerability in RFC 7515
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.17
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: <https://mailarchive.ietf.org/arch/browse/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: Thu, 15 Sep 2016 02:30:46 -0000

On Wed, Sep 14, 2016 at 10:53 AM, Thai Duong <thaidn@google.com> wrote:

>
>
> On Wed, Sep 14, 2016 at 10:47 AM, Jim Schaad <ietf@augustcellars.com>
> wrote:
>
>> The jwk parameter is required when doing ephermal-static ECDH as that is
>> the only way to carry the ephemeral key from the sender to the recipient.
>>
>
> Quoting https://tools.ietf.org/html/rfc7515#section-4.1.3
>
> "The "jwk" (JSON Web Key) Header Parameter is the public key that
>    corresponds to the key used to digitally sign the JWS.  This key is
>    represented as a JSON Web Key [JWK].  Use of this Header Parameter is
>    OPTIONAL."
>
> At any rate there's no reason that the ECDH ephemeral key shouldn't be
> part of the ciphertext.
>

Re ECDH issue: As we're here, it's worth to differentiate between
encryption (e.g. ECDH, RSA encryption) and signature.

"jwk" is also allowed in encryption
https://tools.ietf.org/html/rfc7516#section-4.1.5. I was *not* concerned
about it. It's not ideal but it has limited security impact because at
best, the attacker can force the receiver to use one of the keys in
*receiver*'s key set.

On the other hand, embedded public key in signature has a significant
security impact.

>
>
>> One always needs to validate the key no matter how it is obtained so I
>> would have a hard time not saying that this is a library user problem.
>>
>
> Blaming users is easy. Helping them not make mistakes is right.
>
>> Jim
>>
>>
>> > -----Original Message-----
>> > From: jose [mailto:jose-bounces@ietf.org] On Behalf Of Nathaniel
>> McCallum
>> > Sent: Wednesday, September 14, 2016 9:46 AM
>> > To: Quan Nguyen <quannguyen@google.com>; Michael Jones
>> > <mbj@microsoft.com>; John Bradley <ve7jtb@ve7jtb.com>; 崎村夏彦 <n-
>> > sakimura@nri.co.jp>; Thai Duong <thaidn@google.com>; jose@ietf.org
>> > Subject: Re: [jose] High risk vulnerability in RFC 7515
>> >
>> > OTOH, removing the 'jwk' parameter means that all attributes of keys
>> need to be
>> > duplicated in the header namespace.
>> >
>> > I concur that nobody should trust the contents of the jwk parameter
>> without
>> > additional verification. And I would support language of this type in
>> an errata.
>> > But I think the 'jwk' parameter does have real value.
>> >
>> > On Wed, 2016-09-14 at 08:34 -0700, Quan Nguyen wrote:
>> > >
>> > >
>> > On Tue, Sep 13, 2016 at 8:43 PM, Quan Nguyen <quannguyen@google.com>
>> > > wrote:
>> > Hi,
>> >
>> > I'm Quan Nguyen, a Google Information Security Engineer.
>> >
>> > RFC 7515, https://tools.ietf.org/html/rfc7515#section-4.1.3  "jwk"
>> > > (JSON Web Key) Header Parameter allows the signature to include the
>> > > public key that corresponds to the key used to digitally sign the JWS.
>> > > This is a really dangerous option [1]
>> >
>> > This option allows any attacker to just generate private key /public
>> > > key pair, send the public key together with the signature and and
>> > > signature will be valid. It means that the signature is meaningless
>> > > and easily bypassed. Note that even if it's OPTIONAL, the attacker or
>> > > MITM can always include that field.
>> >
>> > I'm aware that you have a section 6 and Appendix D talking about key
>> > > trust decision. However:
>> >      1.  There is no reason to trust this key
>> >      2.  There is no way to verify public key's truthfulness to make
>> > > trust decision, unless the receiver already knows the public key in
>> > > advance (in that case, "kid" is enough).
>> >
>> > I've seen library making this mistake, but they just followed the
>> > > RFC, so it's hard to convince them to fix the issue. In the end of the
>> > > day, users are vulnerable. Furthermore, I believe this is RFC's
>> > > vulnerability, not the library.
>> >
>> > Regards,
>> >
>> > -Quan
>> >
>> > [1] I'm aware that there may be a rare use-case that needs to send
>> > > the public key, e.g., certificate signing request, but even in that
>> > > case, the user can send the public key, e.g, in opaque field in JWT.
>> >
>> >
>> > _______________________________________________
>> > jose mailing list
>> > jose@ietf.org
>> > https://www.
>> >
>> > _______________________________________________
>> > jose mailing list
>> > jose@ietf.org
>> > https://www.ietf.org/mailman/listinfo/jose
>>
>>
>