Re: [OAUTH-WG] JSON parsing in the browser (was: Proposal for single JSON response format)

Evan Gilbert <uidude@google.com> Mon, 28 June 2010 17:54 UTC

Return-Path: <uidude@google.com>
X-Original-To: oauth@core3.amsl.com
Delivered-To: oauth@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 31A6F3A68FD for <oauth@core3.amsl.com>; Mon, 28 Jun 2010 10:54:04 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -100.655
X-Spam-Level:
X-Spam-Status: No, score=-100.655 tagged_above=-999 required=5 tests=[AWL=0.721, BAYES_50=0.001, FM_FORGED_GMAIL=0.622, GB_I_LETTER=-2, HTML_MESSAGE=0.001, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V5rk7nDLULoq for <oauth@core3.amsl.com>; Mon, 28 Jun 2010 10:54:03 -0700 (PDT)
Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.35]) by core3.amsl.com (Postfix) with ESMTP id D0F383A6925 for <oauth@ietf.org>; Mon, 28 Jun 2010 10:54:02 -0700 (PDT)
Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id o5SHsBus015944 for <oauth@ietf.org>; Mon, 28 Jun 2010 10:54:11 -0700
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1277747651; bh=KD5kBp/S9k68Jt3qFI+yRSBVUcI=; h=MIME-Version:In-Reply-To:References:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VjuvMicJXnRp00GKTXYhZGuzbc2zcoa48wKUPZiBlZQmqIfM7Hmba0RM+YuWZabqG jUkV15vXpK/B6FJUockRQ==
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:from:date:message-id: subject:to:cc:content-type:x-system-of-record; b=VnbNuwOIqL6DYdFmlD8SOpdVgZUgBsBfsfhejQGTCli3uf1ff1wdtRjQbDlGLzkRZ mFDgjIKHAS7jlK1K/CTdw==
Received: from qwe5 (qwe5.prod.google.com [10.241.194.5]) by wpaz37.hot.corp.google.com with ESMTP id o5SHs4fH031679 for <oauth@ietf.org>; Mon, 28 Jun 2010 10:54:10 -0700
Received: by qwe5 with SMTP id 5so1709276qwe.31 for <oauth@ietf.org>; Mon, 28 Jun 2010 10:54:10 -0700 (PDT)
Received: by 10.224.72.143 with SMTP id m15mr3618837qaj.231.1277747650179; Mon, 28 Jun 2010 10:54:10 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.229.11.229 with HTTP; Mon, 28 Jun 2010 10:53:47 -0700 (PDT)
In-Reply-To: <AANLkTimgJSdxjfz7kY1a3zSaK9QQCtxVzVcICoseo3V6@mail.gmail.com>
References: <AANLkTimgJSdxjfz7kY1a3zSaK9QQCtxVzVcICoseo3V6@mail.gmail.com>
From: Evan Gilbert <uidude@google.com>
Date: Mon, 28 Jun 2010 10:53:47 -0700
Message-ID: <AANLkTilYLA2AktwMv3ZIHTHFMwvDOOsOTxANhKzYhyrZ@mail.gmail.com>
To: Robert Sayre <sayrer@gmail.com>
Content-Type: multipart/alternative; boundary="00c09f88cfafcd3599048a1acea3"
X-System-Of-Record: true
Cc: "OAuth WG (oauth@ietf.org)" <oauth@ietf.org>
Subject: Re: [OAUTH-WG] JSON parsing in the browser (was: Proposal for single JSON response format)
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: OAUTH WG <oauth.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/oauth>, <mailto:oauth-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/oauth>
List-Post: <mailto:oauth@ietf.org>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/oauth>, <mailto:oauth-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Jun 2010 17:54:04 -0000

On Sun, Jun 27, 2010 at 1:46 PM, Robert Sayre <sayrer@gmail.com> wrote:

> On Sun, Jun 13, 2010 at 11:20 AM, Evan Gilbert <uidude@google.com> wrote:
> >
> >>
> >> Can you explain the XSS hole from parsing a random JSON string?
> >
> > Naive processor calls:
> > var href = document.location.href;
> > var jsonBlob = href.substring(href.indexOf('#'), href.length)
> > var userData  = eval(jsonBlob);
> > This code would allow executing arbitrary code by sending a user a link,
> > which could, for example, steal your cookies on a site.
> > The fix is just a really complicated RegEx match
>
> I don't agree with this assessment.


What specifically don't you agree with? I agree that the RegEx match or a
library will fix the security hole.

The problem is that the insecure behavior - "eval(json)" - will just work,
is obvious for developers to try, and non-obvious why this is a security
hole.



> The fix is to use json2.js from
> json.org (which does indeed use a really complicated regex) if there
> is no global JSON object available in the browser. A global JSON
> object is available in IE8+, Firefox 3.5+, Safari 4.0.x+, and Chrome
> and Opera (don't have the versions handy).


> "Skate to where the puck is going, not to where it is." -- Wayne Gretzky
>
> --
>
> Robert Sayre
>
> "I would have written a shorter letter, but I did not have the time."
>