Re: [Json] Go JSON parser ignores the case of member names

John Cowan <cowan@mercury.ccil.org> Wed, 09 March 2016 01:20 UTC

Return-Path: <cowan@ccil.org>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 64CA712DD18 for <json@ietfa.amsl.com>; Tue, 8 Mar 2016 17:20:34 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.202
X-Spam-Level:
X-Spam-Status: No, score=-1.202 tagged_above=-999 required=5 tests=[BAYES_05=-0.5, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([127.0.0.1]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1KOXyRWu3xcm for <json@ietfa.amsl.com>; Tue, 8 Mar 2016 17:20:33 -0800 (PST)
Received: from earth.ccil.org (earth.ccil.org [192.190.237.11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2FEBD12DD12 for <json@ietf.org>; Tue, 8 Mar 2016 17:20:33 -0800 (PST)
Received: from cowan by earth.ccil.org with local (Exim 4.72) (envelope-from <cowan@ccil.org>) id 1adSnc-0004L3-6v; Tue, 08 Mar 2016 20:20:28 -0500
Date: Tue, 08 Mar 2016 20:20:28 -0500
From: John Cowan <cowan@mercury.ccil.org>
To: "Manger, James" <James.H.Manger@team.telstra.com>
Message-ID: <20160309012028.GQ32247@mercury.ccil.org>
References: <255B9BB34FB7D647A506DC292726F6E13BBE5873A1@WSMSG3153V.srv.dir.telstra.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <255B9BB34FB7D647A506DC292726F6E13BBE5873A1@WSMSG3153V.srv.dir.telstra.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <cowan@ccil.org>
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/lDvT54KSu1nAHY7MPMGGRR9d1hw>
Cc: "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Go JSON parser ignores the case of member names
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 09 Mar 2016 01:20:34 -0000

Manger, James scripsit:

> I noticed that the default JSON parsing in the Go language
> basically ignores the case of member names. Do JSON experts see this
> case-insensitive parsing as a useful convenience for programmers (being
> lenient with what you receive), or as a bad insecure design choice?

I see it as Very Bad Indeed.  It violates the RFC and, as you say, causes
a JSON text to be interpreted one way by one recipient and another way
by another.

> This looks quite diabolical for security as it is trivial to create
> valid JSON values that will be interpreted differently by different
> implementations. I would expect most implementations (that are expecting
> an "alg" member) to see its "HS256" value and simply ignore the extra
> "ALG" member. 

The Right Thing is to _validate your JSON_.  Make sure what you expect
is there *before* acting on it, and if not *don't act on it*.

-- 
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
My confusion is rapidly waxing
For XML Schema's too taxing:
I'd use DTDs / If they had local trees --
I think I best switch to RELAX NG.