Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(180)

Issue 104062: Issue 1019: InnocentCodeRewriter causes valid ES5-strict code to fail (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
16 years, 8 months ago by MikeSamuel
Modified:
16 years, 8 months ago
Reviewers:
MarkM
CC:
google-caja-discuss_googlegroups.com
Base URL:
http://google-caja.googlecode.com/svn/trunk/
Visibility:
Public.

Description

http://code.google.com/p/google-caja/issues/detail?id=1019 On Thu, Apr 23, 2009 at 5:53 PM, Adam Moore <adamoore@yahoo-inc.com> wrote: >[...] > YUI = function(o) { > > var Y = this; > > // Allow instantiation without the new operator > if (!(Y instanceof YUI)) { > return new YUI(o); > } else { >[...] The pattern above is valid in Valija, ES5-strict, ES5-nonstrict, and ES3. If YUI is called as a function rather than a method or constructor, then * in ES3 or ES5-nonstrict, 'this' will be the global object. * in ES5-strict, 'this' will be 'undefined'. * in Valija today, 'this' will be cajita.USELESS. (But we should also fix Valija to track ES5-strict.) All the above cases work because all of these values are not "instanceof YUI". However, as Adam reports, it does not currently work as transformed by the InnocentCodeRewriter. Currently, to protect against a privilege escalation attack, the InnocentCodeRewriter rewrites all functions containing 'this' to throw if their 'this' is bound to the global object. Now that we understand how this causes valid ES5-strict code to fail, we should fix the innocent code transformer here so to track ES5-strict. We should rewrite all occurrences of 'this' in these functions so that, if the real 'this' was bound to the global object, their rewritten 'this' will instead be bound to 'undefined'. I'm classifying this as Security relevant, since this bug inhibits use of the InnocentCodeRewriter, thereby creating a security hazard. Submitted @3647

Patch Set 1 #

Total comments: 6

Patch Set 2 : Issue 1019: InnocentCodeRewriter causes valid ES5-strict code to fail #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+39 lines, -18 lines) Patch
M src/com/google/caja/parser/quasiliteral/InnocentCodeRewriter.java View 1 5 chunks +34 lines, -15 lines 0 comments Download
M tests/com/google/caja/parser/quasiliteral/InnocentCodeRewriterTest.java View 1 1 chunk +5 lines, -3 lines 1 comment Download

Messages

Total messages: 4
MikeSamuel
16 years, 8 months ago (2009-08-07 22:00:39 UTC) #1
MarkM
Thanks for picking up this issue! http://codereview.appspot.com/104062/diff/1/3 File src/com/google/caja/parser/quasiliteral/InnocentCodeRewriter.java (right): http://codereview.appspot.com/104062/diff/1/3#newcode70 Line 70: // bound ...
16 years, 8 months ago (2009-08-08 00:32:46 UTC) #2
MikeSamuel
http://codereview.appspot.com/104062/diff/1/3 File src/com/google/caja/parser/quasiliteral/InnocentCodeRewriter.java (right): http://codereview.appspot.com/104062/diff/1/3#newcode70 Line 70: // bound to the global object. On 2009/08/08 ...
16 years, 8 months ago (2009-08-08 01:10:15 UTC) #3
MarkM
16 years, 8 months ago (2009-08-08 01:40:23 UTC) #4
LGTM

http://codereview.appspot.com/104062/diff/1005/1006
File tests/com/google/caja/parser/quasiliteral/InnocentCodeRewriterTest.java
(right):

http://codereview.appspot.com/104062/diff/1005/1006#newcode156
Line 156: "assertEquals(assertEquals, this.assertEquals);",
What is this testing?
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b