Re: [Cbor] Handling duplicate map keys

Laurence Lundblade <lgl@island-resort.com> Sun, 24 November 2019 18:21 UTC

Return-Path: <lgl@island-resort.com>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DE07A120041 for <cbor@ietfa.amsl.com>; Sun, 24 Nov 2019 10:21:47 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.896
X-Spam-Level:
X-Spam-Status: No, score=-1.896 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 WuXIQtwiCYEB for <cbor@ietfa.amsl.com>; Sun, 24 Nov 2019 10:21:46 -0800 (PST)
Received: from p3plsmtpa12-05.prod.phx3.secureserver.net (p3plsmtpa12-05.prod.phx3.secureserver.net [68.178.252.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 56C2912001E for <cbor@ietf.org>; Sun, 24 Nov 2019 10:21:46 -0800 (PST)
Received: from [10.86.0.10] ([45.56.150.43]) by :SMTPAUTH: with ESMTPA id YwW0ip5gmABThYwW1iWPkT; Sun, 24 Nov 2019 11:21:45 -0700
From: Laurence Lundblade <lgl@island-resort.com>
Message-Id: <B3C04481-1414-4F90-8C99-62AD7E1819DD@island-resort.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_6BF7025F-D4BF-44DE-8BC8-110F861176B0"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
Date: Sun, 24 Nov 2019 10:21:44 -0800
In-Reply-To: <CANh-dXmxzoEjb-yhL-R1p-xvBF8kZwOpzoS_fziPfuxFhbykhA@mail.gmail.com>
Cc: Jeffrey Yasskin <jyasskin=40google.com@dmarc.ietf.org>, cbor@ietf.org
To: Jeffrey Yasskin <jyasskin@chromium.org>
References: <CANh-dX=EVDa4EwrgWKof4kCD3nkfV3BvH0Cg5ZKOivmXJ_Dm8g@mail.gmail.com> <E5C74E1F-A5F4-4AB8-9787-3999C4697C3B@island-resort.com> <CANh-dX=1gkAtfSG-yzCsVAkk=oLM-=dN_JLCr1kQK3d6Jb0fSw@mail.gmail.com> <F81E1A57-6072-44FA-A148-8F3ED7520791@island-resort.com> <CANh-dXmxzoEjb-yhL-R1p-xvBF8kZwOpzoS_fziPfuxFhbykhA@mail.gmail.com>
X-Mailer: Apple Mail (2.3445.104.11)
X-CMAE-Envelope: MS4wfDK7nkFfGkVLlDySW6bP1tGG17TCYagFVzJbDMjPNcOoMV0RnXxDOCu2jgpIurBzgWxcDiAqrpeCfJNm3dnBYsSww9VPpFFsTHH0g4mzvoTmLvEEJAyE dqyfjL08sVJAoi4zwYR5waFZSeS6mjbzMKhzfvsO/IwkyJogOwFon7+nEkRVU2Ppz1jtDBMf9P2nfqR7fKxQvSzODhj1z5ZwtvtnMB8Bz6jW4IOTvxklRlu/ q0uFlUKcuJo7EcbiTKVyZw==
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/TEmUgfKPXAD2sTdm49TFvsB2opg>
Subject: Re: [Cbor] Handling duplicate map keys
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 24 Nov 2019 18:21:48 -0000


> On Nov 24, 2019, at 2:48 AM, Jeffrey Yasskin <jyasskin@chromium.org> wrote:
> 
>> I think you make a good point that if a protocol is going to specify "take first", it can probably specify "error on duplicate key" for the same cost. That might imply some much simpler text:
>> 
>> "Protocols based on CBOR SHOULD fail with an error if a map contains a duplicate key, except that if the key isn't used at all, they MAY ignore it instead. Protocols that do not reject duplicate keys MUST (?) document why the cost of rejecting duplicates is too high and why accepting them will not lead to security vulnerabilities. An array might be a better choice for such protocols.”
> 
> I think I’d invert it and say that protocols that require duplicate detection for security reasons should describe that requirement in security considerations so the implementor gets a good solid hint that they need to worry about it.
> 
> There's an interesting difference of approach here. It's plausible to say that protocol designers should pick the secure design only when they realize their design has security implications, but I prefer to say that they should pick the secure design unless they think about it and realize the design doesn't have security implications. I think the second will get us noticeably more security in a world where designers don't have time to think about every aspect of every piece of their design.

I don’t know how many generic decoders exist that really can’t do or support duplicate detection. I also don’t know how many use cases there are that can’t afford duplicate detection. If there are few of both, then making no duplicate detection the exception that needs to be called out seems right.

I have been thinking about CWT and EAT as examples. Maybe EAT should say that duplicate detection should be required unless a profile of EAT says it is not, the secure choice. For the most part EAT will be processed on servers where there is clearly no resource issue. The only issue would be the implementation  environment (Java, PHP, Python…).

EATs might be decoded on constrained devices sometimes, but that is rare. In that case a profile can relax the requirement.

EATs are always signed so duplicates would only come from bad implementations. There are plenty of ways that am implementation can go wrong other than duplicating keys that are completely undetectable.

> 
> There is lot of text implying that duplicates are bad, but I think it would be worth being explicit.
> 
> You are an idiot if you design a protocol that considers duplicate input valid or necessary. Duplicate map keys are always an error in CBOR and will not work with many generic decoders.
>  
> I wouldn't say "idiot", just "wrong". The spec already says you "MUST NOT" do this, but I'm not opposed to making that statement more direct.

Pardon my wording. Certainly, I do not want that as normative text.

> 
> Thanks,
> Jeffrey