Re: [jose] #27: member names MUST be unique needs additional text

John Bradley <ve7jtb@ve7jtb.com> Thu, 27 June 2013 15:49 UTC

Return-Path: <ve7jtb@ve7jtb.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 2105D21F9DEE for <jose@ietfa.amsl.com>; Thu, 27 Jun 2013 08:49:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.999
X-Spam-Level:
X-Spam-Status: No, score=-0.999 tagged_above=-999 required=5 tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V8hdgCHSGQ6o for <jose@ietfa.amsl.com>; Thu, 27 Jun 2013 08:49:38 -0700 (PDT)
Received: from mail-qa0-f45.google.com (mail-qa0-f45.google.com [209.85.216.45]) by ietfa.amsl.com (Postfix) with ESMTP id E6BA921F9D92 for <jose@ietf.org>; Thu, 27 Jun 2013 08:49:37 -0700 (PDT)
Received: by mail-qa0-f45.google.com with SMTP id ci6so2570818qab.18 for <jose@ietf.org>; Thu, 27 Jun 2013 08:49:37 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to:x-mailer:x-gm-message-state; bh=hPSRqvmUkQFxFqly9SGSU8ivXUQQzdmsN2nI+cYQnF8=; b=Rw7gvL5N6TbPy7VHP0uPuxlxKe2rTDP352FNU/puYfYpSzm7lFyPTFF93EIHFjEDkt lCoRFJ82UcdVoBqgTp2vkDj8VmHdB4Yd7M5rEIqch4QE9EpTmclO+hBmfAwJI3NCUzfF XXAEd+mX5aolxB4ilnbE/MO4KJ5I7FR6oGIdzT1K2liw1byQEBcOB+dFeV396QUV7kkS 28h4CSwNN2RT4ALlXKlCLDVXv5AkSFdNYyQO8OGToqG2jU0+LsT7fToygIKWgp7b46d1 ayZsai7rJfjmelt3D9iHiHXXEXYVWDdZOLFHN5p0LguMsDm5X97rdk2RHDAKhB1dZObk fumQ==
X-Received: by 10.224.79.209 with SMTP id q17mr12437043qak.88.1372348177156; Thu, 27 Jun 2013 08:49:37 -0700 (PDT)
Received: from [192.168.1.216] (190-20-7-218.baf.movistar.cl. [190.20.7.218]) by mx.google.com with ESMTPSA id ff5sm4498067qeb.6.2013.06.27.08.49.32 for <multiple recipients> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Jun 2013 08:49:35 -0700 (PDT)
Content-Type: multipart/signed; boundary="Apple-Mail=_17FACC13-7E73-42D9-8A16-9E12D9F82161"; protocol="application/pkcs7-signature"; micalg="sha1"
Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\))
From: John Bradley <ve7jtb@ve7jtb.com>
In-Reply-To: <CAHBU6iss5JbmHAue_2-AFDYSMVjAEnMLeLcESei3xTGTWP8_jQ@mail.gmail.com>
Date: Thu, 27 Jun 2013 11:49:03 -0400
Message-Id: <16F5858A-B77F-498B-9296-A42F84D5244D@ve7jtb.com>
References: <061.bb7bbe0b618ec6b74904f48bdb9bb312@trac.tools.ietf.org> <076.a597050ecb4fb25084cec65f7174dc7e@trac.tools.ietf.org> <033b01ce729b$26ff5c90$74fe15b0$@augustcellars.com> <4E1F6AAD24975D4BA5B16804296739436789B4CC@TK5EX14MBXC283.redmond.corp.microsoft.com> <03b401ce72e5$002c65f0$008531d0$@augustcellars.com> <4E1F6AAD24975D4BA5B16804296739436789D4EA@TK5EX14MBXC283.redmond.corp.microsoft.com> <CAHBU6ivNow2xhDvRj7gG2gmHQ+C-ejEHCQubK=LwUtrXxdW6MA@mail.gmail.com> <255B9BB34FB7D647A506DC292726F6E1151BE45737@WSMSG3153V.srv.dir.telstra.com> <CAHBU6itHZ4NvGLyRqfDFaC9gkWD1_6dxhY=uVmwpyL+5Ay+j2w@mail.gmail.com> <255B9BB34FB7D647A506DC292726F6E1151BEDDD3C@WSMSG3153V.srv.dir.telstra.com> <CAHBU6iss5JbmHAue_2-AFDYSMVjAEnMLeLcESei3xTGTWP8_jQ@mail.gmail.com>
To: Tim Bray <tbray@textuality.com>
X-Mailer: Apple Mail (2.1508)
X-Gm-Message-State: ALoCoQkgg5fPvrCZ1xqz9ih9OUd5I7VnnP1yKdEF/OfaXHsvdDe1VZ7WqhlEmIRVruZBY0RA7MJE
Cc: Mike Jones <Michael.Jones@microsoft.com>, "Manger, James H" <James.H.Manger@team.telstra.com>, Jim Schaad <ietf@augustcellars.com>, "jose@ietf.org" <jose@ietf.org>, "draft-ietf-jose-json-web-signature@tools.ietf.org" <draft-ietf-jose-json-web-signature@tools.ietf.org>
Subject: Re: [jose] #27: member names MUST be unique needs additional text
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.12
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: Thu, 27 Jun 2013 15:49:44 -0000

The problem is not wanting to leave a hole for malicious signers to create JWT that may be misinterpreted by the receiver.  Accidental interop problems from bad signers are not a big concern for me and are covered by MUST NOT emit dups.

Accepting malformed JSON as the envelope may lead to real security issues.

This may be more of an issue for the JSON encoding than the compact as there you need to be careful the body you process for the signature is the body that the application uses.

What happens if you receive.

{"protected":<integrity-protected shared header contents>",
      "unprotected":<non-integrity-protected shared header contents>",
      "payload":"<original payload contents>",
      "payload":"<bad payload contents inserted by attacker>"
      "signatures":[
       {"header":"<per-signature unprotected header 1 contents>",
        "signature":"<signature 1 contents>"},
       ...
       {"header":"<per-signature unprotected header N contents>",
        "signature":"<signature N contents>"}],
     }

If the JOSE library validates on the first version of "payload" and the application using a different JSON parser only sees the second "payload" we have a wrapping attack similar to xmldsig.

I can't off the top of my head think of what you could do in the compact serialization that would lead to a successful attack given that the signature is over the base64url encoded segments, that prevents attackers from modifying the JSON while maintaining integrity.

It is a real issue for the JSON serialization though.

John B.

On 2013-06-27, at 11:20 AM, Tim Bray <tbray@textuality.com> wrote:

> The approach just seems wrong.  If we require that conforming implementations MUST NOT emit dupes, then authors of receiving software can just pick the best-performing parser with the nicest API, because they *all* perform correctly when there are no dupes.  
> 
> Who’s going to own the responsibility for making the authoritative finding that of the many JSON parsers in the Java ecosystem, these ones, but not those ones, are usable in JOSE applications?  And suppose one that has been previously OK is quietly optimized on GitHub to run 30% faster and as a side-effect silently ignores dupes?  
> 
> The benefit of using JSON is that there is widely deployed software to handle it.  It is a known problem that sloppy spec drafting has allowed various kinds of problems to occur when dupe keys are received. “Doctor, it hurts when I do this.” “So... don’t do that.”
> 
> Are we also going to specify the behavior of receiving software when the JSON has a misplaced quotation mark?  A missing trailing “}”?
> 
>  -T
> 
> 
> 
> On Wed, Jun 26, 2013 at 11:29 PM, Manger, James H <James.H.Manger@team.telstra.com> wrote:
> Most JSON libraries that silently accept [sob] dupe keys at least consistently use the last key. Allowing just that behaviour (or rejecting dupes), while forbidding acceptance of a non-last dupe (eg first key), is safe and allows most JSON libraries to be used. Since this accepts most libraries I think it is practical.
> 
>  
> 
> Hence I suggest:
> 
>  
> 
> >   A creator of a JOSE message MUST NOT put duplicate names in any JSON
> 
> > object in a JOSE header.
> 
> >   To prevent attacks where a JOSE message is interpreted as different
> 
> > valid messages by different recipients, each recipient MUST either
> 
> > reject messages with duplicate names or accept only the last name.
> 
>  
> 
> This isn’t “truly predictable” as a message with dupes might be accepted or rejected. The crucial point is that if a message is accepted it is predictable.
> 
>  
> 
> --
> 
> James Manger
> 
>  
> 
> From: Tim Bray [mailto:tbray@textuality.com] 
> Sent: Thursday, 27 June 2013 4:16 PM
> To: Manger, James H
> Cc: Mike Jones; Jim Schaad; jose@ietf.org; draft-ietf-jose-json-web-signature@tools.ietf.org
> 
> 
> Subject: Re: [jose] #27: member names MUST be unique needs additional text
> 
>  
> 
> Well, you have a practical problem in that most implementers will want to use a standard JSON library, which is good practice because it will be well-debugged, and most libraries [sob] silently take care of dupe keys and don’t have a way to tell the client software what happened. So if you want truly predictable behavior, you’re forcing the use of hand-constructed JSON parsers. And that sucks, because getting good performance in JSON parsing is surprisingly hard, with dramatic performance differences between implementations. So you’re forcing receiving software which wants to be conformant to use a hand-rolled parser which will probably have lousy performance and have other bugs which in fact may compromise security more than dupe-key tricks could.  -T
> 
>  
> 
> On Wed, Jun 26, 2013 at 10:39 PM, Manger, James H <James.H.Manger@team.telstra.com> wrote:
> 
> > I think it’s a nice clean minimal solution to say that producers MUST
> > NOT generate dupes, end of story.  I don’t think saying anything beyond
> > that adds value. -T
> 
> Clean and minimal that may be, but it ignores the security issue. We don't want a malicious producer (who is so malicious they ignore a MUST) to create JOSE messages that a JOSE-compliant security layer accepts as "benign interpretation #1" so it passes the message on to the JOSE-compliant backend app that acts on "nasty interpretation #2".
> 
> --
> James Manger
> 
>  
> 
>