Re: [Cbor] List of not-well-formed CBOR and test vectors

Carsten Bormann <cabo@tzi.org> Tue, 30 July 2019 09:23 UTC

Return-Path: <cabo@tzi.org>
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 5423B1201DD for <cbor@ietfa.amsl.com>; Tue, 30 Jul 2019 02:23:08 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.198
X-Spam-Level:
X-Spam-Status: No, score=-4.198 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=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 1Onnsd09pAfc for <cbor@ietfa.amsl.com>; Tue, 30 Jul 2019 02:23:05 -0700 (PDT)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AE1091201D7 for <cbor@ietf.org>; Tue, 30 Jul 2019 02:23:05 -0700 (PDT)
Received: from [192.168.217.120] (p548DCCB9.dip0.t-ipconnect.de [84.141.204.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 45yWLb5xHMz105P; Tue, 30 Jul 2019 11:23:03 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <CF3F871E-7489-4770-B2FE-1746C392ACF0@island-resort.com>
Date: Tue, 30 Jul 2019 11:23:03 +0200
Cc: cbor@ietf.org
X-Mao-Original-Outgoing-Id: 586171381.503354-e6a30237c7fdcd350a288f4d226fea48
Content-Transfer-Encoding: quoted-printable
Message-Id: <39259861-43D9-4498-A2F5-E07DBC998CA6@tzi.org>
References: <CF3F871E-7489-4770-B2FE-1746C392ACF0@island-resort.com>
To: Laurence Lundblade <lgl@island-resort.com>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/vGlxvg-IGH75rI9RSYN2gFtqgaQ>
Subject: Re: [Cbor] List of not-well-formed CBOR and test vectors
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: Tue, 30 Jul 2019 09:23:09 -0000

> I think I’ve made a comprehensive list of all things that are not well formed by going through the latest draft and my decoder. There are about a dozen of them. I’ve also created 110 test vectors that cover them pretty thoroughly. 

Nice!
I actually find 111 vectors there.  
If I run these through the (slightly instrumented) pseudocode of the appendix, I get:

   2 SHORT
  10 FINITE
  14 SHORT
   1 BREAK
  14 SHORT
   7 BREAK
   2 RESIDUAL
  25 SIMPLE
   4 INDEF
   4 SHORT
  24 AI
   2 SHORT
   2 BREAK

Where:

- SHORT = premature EOF
- RESIDUAL = data remaining after decoding
1 AI = reserved AI
2 SIMPLE = impermissible coding of simple value
3 FINITE = indefinite inside indefinite length string
4 BREAK = break stop code outside indefinite length item or as map value
5 INDEF = wrong major type for indefinite length

(The numbers in this list enumerate the calls to “fail()” in the pseudocode in the appendix.)

Why are you testing only 25 of the 32 impermissible SIMPLE cases?

Grüße, Carsten

PS: These test vectors base64url-encoded in JSON:

[
  "X0EA",
  "f2EA",
  "X2EA_w",
  "f0EA_w",
  "XwD_",
  "XyH_",
  "X4D_",
  "X6D_",
  "X8AA_w",
  "X-D_",
  "X19BAP__",
  "f39hAP__",
  "gQ",
  "ggA",
  "mgH_AA",
  "oQ",
  "ogEC",
  "nw",
  "nwEC",
  "vw",
  "vwECAQI",
  "n4AA",
  "gZ8",
  "gYGBgYGBgYGB",
  "n5-fn5______",
  "n4GfgZ-f____",
  "n4KfgZ-f_____w",
  "GA",
  "GQ",
  "Gg",
  "Gw",
  "GQE",
  "GgEC",
  "GwECAwQFBgc",
  "OA",
  "WA",
  "eA",
  "mA",
  "uA",
  "2A",
  "-A",
  "gf8",
  "ggD_",
  "of8",
  "of8A",
  "oQD_",
  "ogAA_w",
  "_w",
  "gP8",
  "n___",
  "-AA",
  "-AE",
  "-AI",
  "-AM",
  "-AQ",
  "-AU",
  "-AY",
  "-Ac",
  "-Ag",
  "-Ak",
  "-Ao",
  "-As",
  "-Aw",
  "-A0",
  "-A4",
  "-A8",
  "-BA",
  "-BE",
  "-BI",
  "-BM",
  "-BQ",
  "-BU",
  "-BY",
  "-Bc",
  "-Bg",
  "Hw",
  "Pw",
  "3wA",
  "3w",
  "QQ",
  "YQ",
  "Wv____8A",
  "ev____8A",
  "HA",
  "HQ",
  "Hg",
  "PA",
  "PQ",
  "Pg",
  "XA",
  "XQ",
  "Xg",
  "fA",
  "fQ",
  "fg",
  "nA",
  "nQ",
  "ng",
  "vA",
  "vQ",
  "vg",
  "3A",
  "3Q",
  "3g",
  "_A",
  "_Q",
  "_g",
  "oQA",
  "ogAAAA",
  "vwD_",
  "vwAAAP8"
]