Re: Precision of numbers using JSON Header Field Values

Kazuho Oku <kazuhooku@gmail.com> Fri, 15 July 2016 09:19 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 27CE412DB11 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 15 Jul 2016 02:19:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -8.308
X-Spam-Level:
X-Spam-Status: No, score=-8.308 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.287, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.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 I5YXemXlQRFU for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 15 Jul 2016 02:19:49 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 4BFD712DA34 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Fri, 15 Jul 2016 02:18:59 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1bNzCo-0008Bx-7N for ietf-http-wg-dist@listhub.w3.org; Fri, 15 Jul 2016 09:14:46 +0000
Resent-Date: Fri, 15 Jul 2016 09:14:46 +0000
Resent-Message-Id: <E1bNzCo-0008Bx-7N@frink.w3.org>
Received: from lisa.w3.org ([128.30.52.41]) by frink.w3.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <kazuhooku@gmail.com>) id 1bNzCk-0008BC-CD for ietf-http-wg@listhub.w3.org; Fri, 15 Jul 2016 09:14:42 +0000
Received: from mail-wm0-f48.google.com ([74.125.82.48]) by lisa.w3.org with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <kazuhooku@gmail.com>) id 1bNzCj-0006A3-1i for ietf-http-wg@w3.org; Fri, 15 Jul 2016 09:14:41 +0000
Received: by mail-wm0-f48.google.com with SMTP id o80so20020597wme.1 for <ietf-http-wg@w3.org>; Fri, 15 Jul 2016 02:14:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=uRkihB1+RnfNucv47m3aJTgH7af4kQE0SbUuaD00H/0=; b=El0sK2LwJfitDZHe192/HEnbEAtxlUwLkoXlpovTrR2XVkMwpYRd7rqFolY7Ntu9TK EnsyDXcLTXQGQl0aTHeDIw3Yn4nCZJFVxr75Jkomcc79ZtuvODQekvMx8QceMkJZi54k bXW32q7//CjZH9AgVK3xYLTSc4Nwxex4xhB/Np1igNY5Ef1evCemtGxmE8fUt1sgrPWC j2tVzX6gsSVCxEH7vODSaCadC75D4PdSYzIXIFr18bETt2fYOo4GbWPIP7YHzKdyriwt HpMoQHRp9oPaXrljGBUN04HAuvfE/k8kvbA3VJ9/xPQpFywhvP55VOJXOGxrYo71JKjl jkEg==
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:content-transfer-encoding; bh=uRkihB1+RnfNucv47m3aJTgH7af4kQE0SbUuaD00H/0=; b=hfD2B3+Nd8uk4AjjRdmcRcLHAT+dV3TyCWQNEQou/K1h0AXxKRX9kdkw+1qdyz/CYv juoYET1IXACaJUM1rDO52qX7dkHadAOXs2Pi3SRUyBzPEccThts5YSpiKXQ6X92h9Fw/ tXQBixIvkoTuopHUHE6/2J9r/VWN8U5c/N0QRpAqwDHeifwBY4qAd8yX8WL/Z5kogiHU wz8hJfgZ2qttOIGGsAhPj95lrhqCvqMPLDouDOG35QQ/Pd17Gpkv4b0PlaA/YmWczRlk vnW/qXV9TvRO9gMTL8MqZr8PdOCN4fKRKj3E4fV5xPjOA9rqR938P97vZwRWtLxtty/R WNkA==
X-Gm-Message-State: ALyK8tIfIdIxnJF5mB5OAFMk5xXyEmTmF35gY//ufWd1WbhAK2Hhe0drWj7bLZDD9DlmGDi54SsdXolQYdqSeg==
X-Received: by 10.28.141.74 with SMTP id p71mr20757260wmd.37.1468574054452; Fri, 15 Jul 2016 02:14:14 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.195.31.170 with HTTP; Fri, 15 Jul 2016 02:14:13 -0700 (PDT)
In-Reply-To: <CANatvzwDMF50KcFGR72SUtLCJc6fqJJ2pZaCOK9qv2RK5vZ+=g@mail.gmail.com>
References: <CANatvzwDMF50KcFGR72SUtLCJc6fqJJ2pZaCOK9qv2RK5vZ+=g@mail.gmail.com>
From: Kazuho Oku <kazuhooku@gmail.com>
Date: Fri, 15 Jul 2016 18:14:13 +0900
Message-ID: <CANatvzy5pFMan3GRNf+_oXbi1sxVZUd9BdDamr0VOAqWZiQC1g@mail.gmail.com>
To: Julian Reschke <julian.reschke@gmx.de>, HTTP Working Group <ietf-http-wg@w3.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=74.125.82.48; envelope-from=kazuhooku@gmail.com; helo=mail-wm0-f48.google.com
X-W3C-Hub-Spam-Status: No, score=-5.5
X-W3C-Hub-Spam-Report: AWL=-0.755, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, W3C_AA=-1, W3C_WL=-1
X-W3C-Scan-Sig: lisa.w3.org 1bNzCj-0006A3-1i c28739c3cde5905fb19dc000b6949904
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Precision of numbers using JSON Header Field Values
Archived-At: <http://www.w3.org/mid/CANatvzy5pFMan3GRNf+_oXbi1sxVZUd9BdDamr0VOAqWZiQC1g@mail.gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/31977
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

2016-07-15 13:13 GMT+09:00 Kazuho Oku <kazuhooku@gmail.com>:
> Hello,
>
> I have a question about how numbers are going to be handled using JSON
> Header Field Values.
>
> In section 6.1, the draft uses Content-Length header as an example,
> and states that in case the header is to be represented using JSON,
> the definition should "restrict all numbers to be non-negative
> integers without fractions."
>
> Does this mean that numbers should not be expressed using the
> exponential notation (which would mean that we would be adding a
> restriction to JSON encoder / parser), or does it mean that we should
> validate the number _after_ parsing it using method defined in RFC
> 7159?
>
> The reason I ask is because RFC 7159 does not define the precision of
> numbers, and in some cases existing JSON decoders disagree in how the
> number expressions are parsed.
>
> For example, using node.js v.6.2.1,
> 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100e400
> is evaluated as 100. OTOH, using ruby 2.0.0, the same expression is
> interpreted as zero.
> (please refer to
> https://gist.github.com/kazuho/7e72372111fa0655692d9e44be70c7ea for
> the full output)

FYI the ruby's behavior has been fixed (see
https://github.com/ruby/ruby/commit/5292b2727a089821f2bf21dfcc8a7be899eb744c),
but anyways I agree with PHK and Julian that this illustrates the
danger of using a loose specification such as JSON.

> IMO such disagreement is a mine of vulnerabilities.  For example in
> case of HTTP/1.1, it could lead to HTTP response splitting.
>
> So personally, I think we should forbid the use of exponential
> notation at least in some cases, but I wonder if adding such
> restriction is intended or aligns with the motive to use an existing
> notation for HTTP headers.
>
> --
> Kazuho Oku



-- 
Kazuho Oku