[secdir] secdir review of draft-ietf-jsonbis-rfc7159bis-03

Benjamin Kaduk <kaduk@mit.edu> Wed, 08 March 2017 01:48 UTC

Return-Path: <kaduk@mit.edu>
X-Original-To: secdir@ietfa.amsl.com
Delivered-To: secdir@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 907DA129482; Tue, 7 Mar 2017 17:48:35 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.222
X-Spam-Level:
X-Spam-Status: No, score=-4.222 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-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 6s9YZnzysVYy; Tue, 7 Mar 2017 17:48:34 -0800 (PST)
Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu [18.9.25.13]) (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 C240B129447; Tue, 7 Mar 2017 17:48:30 -0800 (PST)
X-AuditID: 1209190d-af7ff70000003148-0c-58bf62ece4dc
Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 45.44.12616.CE26FB85; Tue, 7 Mar 2017 20:48:28 -0500 (EST)
Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id v281mRZg014404; Tue, 7 Mar 2017 20:48:28 -0500
Received: from kduck.kaduk.org (24-107-191-124.dhcp.stls.mo.charter.com [24.107.191.124]) (authenticated bits=56) (User authenticated as kaduk@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id v281mOPt003933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 7 Mar 2017 20:48:26 -0500
Date: Tue, 07 Mar 2017 19:48:24 -0600
From: Benjamin Kaduk <kaduk@mit.edu>
To: secdir@ietf.org, ietf@ietf.org, draft-ietf-jsonbis-rfc7159bis.all@ietf.org
Message-ID: <20170308014823.GF30306@kduck.kaduk.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
User-Agent: Mutt/1.6.1 (2016-04-27)
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsUixCmqrPsmaX+EwbRDGhaznv1gtHi2cT6L xYeFD1kcmD2WLPnJFMAYxWWTkpqTWZZapG+XwJXR2ziTvaDHqmLHr37GBsZd+l2MnBwSAiYS s1+cYeti5OIQEmhjkrh36i8rhLOBUeL/hdXsEM4VJokHe0+wgrSwCKhIfJ83iw3EZgOyG7ov M4PYIgJ+Em+W7GcHsYUFrCTWHpjKCGLzAq1o+7mDDcIWlDg58wkLiM0soCVx499Lpi5GDiBb WmL5Pw6QsKiAskTDjAfMExh5ZyHpmIWkYxZCxwJG5lWMsim5Vbq5iZk5xanJusXJiXl5qUW6 Rnq5mSV6qSmlmxjB4SXJu4Px312vQ4wCHIxKPLweZ/dFCLEmlhVX5h5ilORgUhLlXRy9P0KI Lyk/pTIjsTgjvqg0J7X4EKMEB7OSCG+7JVCONyWxsiq1KB8mJc3BoiTOK67RGCEkkJ5Ykpqd mlqQWgSTleHgUJLgNQbGkZBgUWp6akVaZk4JQpqJgxNkOA/Q8J+JIMOLCxJzizPTIfKnGBWl xHk/JQAlBEASGaV5cL2g+JfI3l/zilEc6BVhXj6QFTzA1AHX/QpoMBPQYG3XvSCDSxIRUlIN jNYOxRkNvSuZFD49ufBlx2Gvvq9NVmbxstYXNn/16I4Rz9/bG7+js+CevfeP60n6mvemM8YL 73udac0gfOnplCnnu3JdhYttd/zxX73bNmbbXMkdH7fcqBTdGXXjuNGBb2YibI0bLQ4uYjqx baq5xY5t6W95hT3nNf6NX7dJcuLFzwwmDN+ONCqxFGckGmoxFxUnAgB18B3W2gIAAA==
Archived-At: <https://mailarchive.ietf.org/arch/msg/secdir/I-3VX587UO2UUM-a3VdDuJssfi8>
Subject: [secdir] secdir review of draft-ietf-jsonbis-rfc7159bis-03
X-BeenThere: secdir@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: Security Area Directorate <secdir.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/secdir>, <mailto:secdir-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/secdir/>
List-Post: <mailto:secdir@ietf.org>
List-Help: <mailto:secdir-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/secdir>, <mailto:secdir-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 08 Mar 2017 01:48:35 -0000

Hi all,

I have reviewed this document as part of the security directorate's
ongoing effort to review all IETF documents being processed by the
IESG.  These comments were written primarily for the benefit of the
security area directors.  Document editors and WG chairs should
treat these comments just like any other last call comments.

It is rather surprising to find notable omissions with what is
effectively rfc4627ter, though that seems to be my conclusion after
performing this review.  Luckily, they should be easy to resolve
with just a touch more text in the security considerations, for the
most part.

As an overall summary, this document is a simple, clean, crisp
writeup of the JSON interchange format, which is expected to match
that of the ECMAscript standard.

Since this is a data format and not a protocol, any security issues
with this document are expected to be second-order effects, relating
to how the format is used or could be (mis)used by consuming
protocols.  It is useful to give guidance on issues that may occur
due to known-bad implementations, edge cases that can cause trouble,
etc., and this document does so, noting that the fields in an object
are unordered (but some implementations respect the order in their
APIs), when comparing field names the potential for escaped
characters must be taken into account, many implementations have
limited precision/bounds for numbers, non-number mathematical values
cannot be expressed in JSON, etc.

However, I think that the security considerations section would
benefit from some discussion of potential/example consequences of
failing to heed those issues:

Doing name comparison without respect for excaping could let an
attacker inject unsanitized data into what is supposed to be a
trusted structure, potentially giving privilege escalation,
compromising authentication and authorization, etc.

Considering only the first (or last) of duplicated name/value pairs
can lead to vulnerabilities by bypassing security checks, in mixed
environments.  Similarly, a reliance on fields being returned in
order could cause issues (certainly denial of service, potentially
worse) if an attacker uses a different order than expected.  Perhaps
the start of section 4 could refer forward to discussion in the
security considerations, which give some exposition on the
consequences of breaking the "names within an object SHOULD be
unique" guidance.

Implementations should probably check that their numerical routines
do not attempt to emit "NaN" or "Inf" or simlar, though I do not
have a good picture of how that would affect real systems
(hopefully, just a parse error on the receiver, as those are not
permitted by the grammar).  Similarly, the use of extremely large or
precise numbers in mixed environments can lead to unexpected
results.  I expect that there could be vulnerabilities here, such as
if code can be induced into a loop with incearingly large values,
where a sender ends up producing numbers larger than can be
represented on the receiver, which then saturates its
strtonum-equivalent and hits an unexpected codepath.


I'm also concerned about the freewheeling use of Unicode.  While
this document does discuss the potential encodings and lists UTF-8
as the default (and most interoperable), I think it would benefit
from a stricter warning that parties using JSON for communication
must have some out-of-band way to agree on what encoding is to be
used.  I would expect that this is usually going to be done by the
protocol using JSON, but could see a place for the actual
communicating peers to have out-of-band knowledge.  (An application
having to guess what encoding is being used based on heuristics is a
recipe for disaster.)

Additionally, the document makes no mention of Unicode
normalization, which can be a minefield.  The precis working group
has a lot of work in this area, from which the executive summary is:
it's a lot of work to do things correctly, and being sloppy usually
leads to vulnerabilities.  The most obvious issue would be in (the
comparison of) field names using strings that can be represented
differently in different normalization forms (for example, e with
acute accent), which can be either U+00e9 or U+0064 and the
combining character U+0301.  Simply converting to Unicode code
points is insufficient for an implementation to cause those strings
to compare as equivalent.  I think this document should at least
mention that Unicode normalization forms exist and should be
considered by protocol designers when using JSON with characters
outside of US-ASCII.


Section 9 (parsers) mentions that an implementation "may set limits"
on various parameters.  That seems like a good place to give some
guidance on what limits are in common use and how protocols or
protocol peers might discover and/or negotiate each others'
implementation limits.


With the proposed additions to the security considerations out of
the say, on to some other minutiae.

Section 3 describes that "[a] JSON value MUST be an object, array,
number, or string, or one of the following three literal names:
false null true"; in the introduction, this (equivalent) list is
given as "object, array, number, string, boolean, or null", in the
guise of "four primitive types (strings, numbers, booleans, and
null) and two structured types (objects and arrays)".  There may be
some value in using consistent terminology between the two
locations, but it would be pretty minor value and might not be worth
the effort.

The format for numbers (Section 6) permits an explicit (redundant)
plus sign in the exponent part, but not in front of the overall
number.  This feels slightly strange to me, but I don't know if
there are any implementations that get this wrong.  (I also don't
really see security consequences of getting it wrong.)  Similarly,
the fractional part must contain a digit (that is, a number ending
in a decimal point is forbidden), which is probably harmless.  I'll also
note that the number 3.141592653589793238462643383279 is used as an
example of a precision unrepresentable in 64-bit IEEE 754
floating-point, but the next digit in the expansion of pi is a '5',
which would round up to ...80.  Maybe another digit should be added
to keep overly pedantic readers from worrying about rounding modes :)

Should section 8.3 (string comparison) use any RFC 2119 language
with respect to treating strings as equal that use escapes (or even
normalization forms, as covered above)?

The IANA considerations (section 11) might be a little more explicit
that the IANA "Media Types" registry is what is being modified.
I'm also rather curious about the claim that no "charset" parameter
is needed as it "really has no effect on compliant recipients".  Why
is this not a good way to communicate whether UTF-8, UTF-16, or
UTF-32 is in use for a given text?

It might also be useful to have an example of an array object that
contains elements of different type, to reinforce that this is
permitted.

With respect to section 1.3, I personally am more used to seeing a
"changes since <previous document>" section that lays out what
changed inline, as opposed to with (opaque) references to specific
errata.  But that is rather an editorial issue so my personal
preference should not bind you.

-Ben