Re: [Json] Security Considerations

Stefan Drees <stefan@drees.name> Fri, 07 June 2013 07:15 UTC

Return-Path: <stefan@drees.name>
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 8BF8721F94BA for <json@ietfa.amsl.com>; Fri, 7 Jun 2013 00:15:01 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.249
X-Spam-Level:
X-Spam-Status: No, score=-2.249 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, HELO_EQ_DE=0.35]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UHGw2ah4MEIw for <json@ietfa.amsl.com>; Fri, 7 Jun 2013 00:14:55 -0700 (PDT)
Received: from mout.web.de (mout.web.de [212.227.15.3]) by ietfa.amsl.com (Postfix) with ESMTP id 75EB221F8CB5 for <json@ietf.org>; Fri, 7 Jun 2013 00:14:55 -0700 (PDT)
Received: from newyork.local.box ([93.129.186.5]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MKa6N-1UmEat20nv-001xDu; Fri, 07 Jun 2013 09:14:41 +0200
Message-ID: <51B1885F.3080908@drees.name>
Date: Fri, 07 Jun 2013 09:14:39 +0200
From: Stefan Drees <stefan@drees.name>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
MIME-Version: 1.0
To: Douglas Crockford <douglas@crockford.com>
References: <51B0E02E.4070209@crockford.com> <1BD0044B-D7A6-4C7F-899E-5D3E72C62956@vpnc.org> <51B116FE.9050406@crockford.com>
In-Reply-To: <51B116FE.9050406@crockford.com>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
X-Provags-ID: V03:K0:9jBhMFOFpQ6VLCpbeX7M2EDg9LIggWHAUJHmsJu1If2ri05IWCU NVRbnPzpT4dBO6V9aTAvcjhE2fwP6VRO+YCg23MT+risTzNilHs11gxMq294q/hpcoQV1Ps uu3ntXqg8dByL/ErSJN0klqA7TblsMnJBH/iok2ObYsTLsLS/aFLPIhqqgX5yzUG2fArUjC VMjEpfNArBURiJiyzRv1g==
Cc: Paul Hoffman <paul.hoffman@vpnc.org>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Security Considerations
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
Reply-To: stefan@drees.name
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: <http://www.ietf.org/mail-archive/web/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: Fri, 07 Jun 2013 07:15:01 -0000

On 07.06.13 01:10, Douglas Crockford wrote:
> On 6/6/2013 4:04 PM, Paul Hoffman wrote:
>>
>> On Jun 6, 2013, at 12:17 PM, Douglas Crockford <douglas@crockford.com>
>> wrote:
>>
>>> Proposal:
>>>
>>>    With any data format, it is important to encode correctly.  Care must
>>>    be taken when constructing JSON texts by concatenation.  For example:
>>>
>>>    account = 4627;
>>>    comment = "\",\"account\":262";   // provided by attacker
>>>    json_text = "(\"account\":" + account + ",\"comment\":\"" +
>>> comment + "\"}";
>> The example is language-specific and, due to the escaping, hard to read.
> Which specific language would you say it is? Confusion attacks are often
> hard to read. That is why they work. ...

I propose to keep the example, but remove the need for quoting by 
switching to single quotes where needed:

"""
account = 4627;
comment = '","account":262';  // provided by attacker
json_text = '("account":' + account + ',"comment":"' + comment + '"}';
"""

this is valid (Java|ECMA)Script, right and also much more readable, 
isn't it?

All the best,
Stefan.