Bug 35773 - [chromium] add logging of cross-frame property accesses for site isolation
Summary: [chromium] add logging of cross-frame property accesses for site isolation
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: John Gregg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-04 17:11 PST by John Gregg
Modified: 2013-04-09 16:09 PDT (History)
8 users (show)

See Also:


Attachments
patch to pass accesses through chromiumbridge (7.50 KB, patch)
2010-03-04 17:21 PST, John Gregg
no flags Details | Formatted Diff | Diff
same patch without debug print (7.40 KB, patch)
2010-03-04 17:25 PST, John Gregg
abarth: review-
Details | Formatted Diff | Diff
patch with style updates (7.42 KB, patch)
2010-03-10 16:30 PST, John Gregg
no flags Details | Formatted Diff | Diff
patch with event id (8.15 KB, patch)
2010-03-16 17:25 PDT, John Gregg
no flags Details | Formatted Diff | Diff
corrected patch (6.69 KB, patch)
2010-03-17 09:53 PDT, John Gregg
fishd: review-
Details | Formatted Diff | Diff
patch using FrameLoaderClient (7.49 KB, patch)
2010-03-23 17:13 PDT, John Gregg
fishd: review-
Details | Formatted Diff | Diff
patch with renames and Frame parameter (7.65 KB, patch)
2010-03-30 12:19 PDT, John Gregg
fishd: review-
Details | Formatted Diff | Diff
patch with rename and reinterpret_cast (7.72 KB, patch)
2010-03-30 14:14 PDT, John Gregg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Gregg 2010-03-04 17:11:55 PST
chromium would like to measure how often pages request properties from frames from other origins.
Comment 1 John Gregg 2010-03-04 17:21:33 PST
Created attachment 50067 [details]
patch to pass accesses through chromiumbridge
Comment 2 John Gregg 2010-03-04 17:25:33 PST
Created attachment 50068 [details]
same patch without debug print
Comment 3 Charles Reis 2010-03-05 12:21:01 PST
A little context: knowing whether many pages access cross-origin frames will help us decide about some potential changes to improve site isolation in Chromium.
Comment 4 WebKit Review Bot 2010-03-10 11:31:14 PST
Attachment 50068 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/ChangeLog:9:  Line contains tab character.  [whitespace/tab] [5]
WebCore/bindings/v8/V8Utilities.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
WebCore/bindings/v8/V8Utilities.cpp:152:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 3 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Adam Barth 2010-03-10 13:45:00 PST
Comment on attachment 50068 [details]
same patch without debug print

Please fix the stylebot's nits.  Also you'll need to remove the following line before we can actually commit your patch:

+ No new tests. (OOPS!)

(It's ok not to have tests for this patch because it doesn't change any functionality.)
Comment 6 John Gregg 2010-03-10 16:30:32 PST
Created attachment 50454 [details]
patch with style updates

style nits fixed, except header ordering which I believe is a false-positive.
Comment 7 WebKit Review Bot 2010-03-10 16:34:19 PST
Attachment 50454 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/bindings/v8/V8Utilities.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Adam Barth 2010-03-10 16:56:51 PST
Comment on attachment 50454 [details]
patch with style updates

LGTM.  I think the header ordering issue is cased by the #include <v8.h>, which we can probably just remove.
Comment 9 John Gregg 2010-03-15 19:00:02 PDT
Comment on attachment 50454 [details]
patch with style updates

this will break chromium
Comment 10 John Gregg 2010-03-16 17:25:29 PDT
Created attachment 50856 [details]
patch with event id

new version which also passes an ID for the current event when there is a cross-site access, so we can track when a page makes repeated accesses during a single event.
Comment 11 WebKit Review Bot 2010-03-16 17:26:06 PDT
Attachment 50856 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/bindings/v8/V8Utilities.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 WebKit Review Bot 2010-03-16 17:37:13 PDT
Attachment 50856 [details] did not build on chromium:
Build output: http://webkit-commit-queue.appspot.com/results/916019
Comment 13 John Gregg 2010-03-17 09:53:21 PDT
Created attachment 50916 [details]
corrected patch
Comment 14 WebKit Review Bot 2010-03-17 09:57:18 PDT
Attachment 50916 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/bindings/v8/V8Utilities.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Darin Fisher (:fishd, Google) 2010-03-21 23:07:46 PDT
Comment on attachment 50916 [details]
corrected patch

> Index: WebKit/chromium/public/WebFrameClient.h
...
> +    // Notifies that a cross-frame access was made.
> +    virtual void didMakeCrossFrameAccess(WebFrame*, bool crossOrigin, const WebString& property, unsigned long long) { }

> Index: WebKit/chromium/src/ChromiumBridge.cpp
...
> +void ChromiumBridge::recordCrossFrameAccess(Frame* frame, bool crossOrigin, const String& name, unsigned long long eventId)
> +{
> +    WebFrameImpl* frameImpl = WebFrameImpl::fromFrame(frame);
> +    frameImpl->client()->didMakeCrossFrameAccess(frameImpl, crossOrigin, name, eventId);
> +}
> +

If it belongs on WebFrameClient, then it also belongs on FrameLoaderClient.
Also, we should avoid dumping things into ChromiumBridge that are not purely
the domain of WebCore/platform.  The easy test:  is the method parameterized
by a Frame?  If so, then it should actually be on FrameLoaderClient.
Comment 16 John Gregg 2010-03-23 17:13:25 PDT
Created attachment 51468 [details]
patch using FrameLoaderClient

submitting new patch which uses FrameLoaderClient and does not use ChromiumBridge
Comment 17 WebKit Review Bot 2010-03-23 17:16:21 PDT
Attachment 51468 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/bindings/v8/V8Utilities.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 18 Darin Fisher (:fishd, Google) 2010-03-24 00:04:47 PDT
Comment on attachment 51468 [details]
patch using FrameLoaderClient

ndex: WebCore/bindings/v8/V8Utilities.cpp
...
> +void logSiteIsolationAccess(v8::Local<v8::String> name, const v8::AccessorInfo& info)
> +{
> +    Frame* target = V8DOMWindow::toNative(info.Holder())->frame();
> +    Frame* active = V8BindingState::Only()->getActiveWindow()->frame();
> +    if (target == active)
> +        return;
> +
> +    bool crossSite = !V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false);
> +    String propName = toWebCoreString(name);
> +
> +    // For cross-site, we also want to identify the current event to record repeat accesses.

It would be helpful if this comment explained why we want to do this for
cross-site only.

What happens if this code is reached from within an isolated world?


> +    unsigned long long eventId = 0;
> +    if (crossSite) {
> +        v8::HandleScope handleScope;
> +        v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(active);
> +        if (!v8Context.IsEmpty()) {
> +            v8::Context::Scope scope(v8Context);
> +            v8::Handle<v8::Object> global = v8Context->Global();
> +            v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
> +            if (V8DOMWrapper::isValidDOMObject(jsEvent))
> +                eventId = (unsigned long long) V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent));
> +        }
> +    }
> +    active->loader()->client()->didMakeCrossFrameAccess(crossSite, propName, eventId);
> +}

it might be nice to make these function names, logSiteIsolationAccess and
didMakeCrossFrameAccess, be related.  also, isn't this code running *before*
the cross frame access?  probably that "did" should be a "will"?

could it be useful to pass the target frame as a parameter to
didMakeCrossFrameAccess?  then, the embedder could gather additional
information from the target frame if needed.  maybe that is not useful?


> Index: WebKit/chromium/public/WebFrameClient.h
...
> +    // Notifies that a cross-frame access was made.
> +    virtual void didMakeCrossFrameAccess(WebFrame*, bool crossOrigin, const WebString& property, unsigned long long) { }

nit: please name the 'unsigned long long' argument.
nit: the comment is redundant with the method name, so it should probably be eliminated.
Comment 19 John Gregg 2010-03-24 09:01:29 PDT
(In reply to comment #18)
> (From update of attachment 51468 [details])
> ndex: WebCore/bindings/v8/V8Utilities.cpp
> ...
> > +void logSiteIsolationAccess(v8::Local<v8::String> name, const v8::AccessorInfo& info)
> > +{
> > +    Frame* target = V8DOMWindow::toNative(info.Holder())->frame();
> > +    Frame* active = V8BindingState::Only()->getActiveWindow()->frame();
> > +    if (target == active)
> > +        return;
> > +
> > +    bool crossSite = !V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false);
> > +    String propName = toWebCoreString(name);
> > +
> > +    // For cross-site, we also want to identify the current event to record repeat accesses.
> 
> It would be helpful if this comment explained why we want to do this for
> cross-site only.
> 

Adding more context.

> What happens if this code is reached from within an isolated world?

I'm not exactly sure what is different in an isolated world, but the code above is the same code that runs to do the actual access check; and the code below should just produce a 0 eventId if the mainWorldContext is empty.
 
> 
> > +    unsigned long long eventId = 0;
> > +    if (crossSite) {
> > +        v8::HandleScope handleScope;
> > +        v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(active);
> > +        if (!v8Context.IsEmpty()) {
> > +            v8::Context::Scope scope(v8Context);
> > +            v8::Handle<v8::Object> global = v8Context->Global();
> > +            v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
> > +            if (V8DOMWrapper::isValidDOMObject(jsEvent))
> > +                eventId = (unsigned long long) V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent));
> > +        }
> > +    }
> > +    active->loader()->client()->didMakeCrossFrameAccess(crossSite, propName, eventId);
> > +}
> 
> it might be nice to make these function names, logSiteIsolationAccess and
> didMakeCrossFrameAccess, be related.  also, isn't this code running *before*
> the cross frame access?  probably that "did" should be a "will"?

logSiteIsolationAccess is called before we know that it's cross frame (you'll see this code just returns if it turns out to be the same frame).  I can change it to logAccessToCrossFrameProperty, I guess that is still accurate and more related.

I would argue the code is running *during* the access and that 'did' is okay, but I'll change it if you feel strongly.

> could it be useful to pass the target frame as a parameter to
> didMakeCrossFrameAccess?  then, the embedder could gather additional
> information from the target frame if needed.  maybe that is not useful?

Charlie Reis, any opinion?  

> 
> > Index: WebKit/chromium/public/WebFrameClient.h
> ...
> > +    // Notifies that a cross-frame access was made.
> > +    virtual void didMakeCrossFrameAccess(WebFrame*, bool crossOrigin, const WebString& property, unsigned long long) { }
> 
> nit: please name the 'unsigned long long' argument.
> nit: the comment is redundant with the method name, so it should probably be
> eliminated.

done on #1; all the methods in that file have comments, so instead of removing it i'll make it more informative.
Comment 20 Charles Reis 2010-03-24 10:17:13 PDT
> > could it be useful to pass the target frame as a parameter to
> > didMakeCrossFrameAccess?  then, the embedder could gather additional
> > information from the target frame if needed.  maybe that is not useful?
> 
> Charlie Reis, any opinion?  

That's not a bad idea.  It'll unfortunately require an update to the Chromium side, but it would allow us to eventually check whether an event that makes multiple cross-site frame accesses is doing it on the same frame or different frames.
Comment 21 Eric Seidel (no email) 2010-03-24 14:30:20 PDT
Comment on attachment 50454 [details]
patch with style updates

Cleared Adam Barth's review+ from obsolete attachment 50454 [details] so that this bug does not appear in http://webkit.org/pending-commit.
Comment 22 Darin Fisher (:fishd, Google) 2010-03-24 21:13:06 PDT
> > it might be nice to make these function names, logSiteIsolationAccess and
> > didMakeCrossFrameAccess, be related.  also, isn't this code running *before*
> > the cross frame access?  probably that "did" should be a "will"?
> 
> logSiteIsolationAccess is called before we know that it's cross frame (you'll
> see this code just returns if it turns out to be the same frame).  I can change
> it to logAccessToCrossFrameProperty, I guess that is still accurate and more
> related.
> 
> I would argue the code is running *during* the access and that 'did' is okay,
> but I'll change it if you feel strongly.

True.  How about logPropertyAccess and logCrossFramePropertyAccess?

The logSiteIsolationAccess name is a little awkward as well since it
is not about access to "site-isolation" that you are logging.
Comment 23 John Gregg 2010-03-30 12:19:39 PDT
Created attachment 52067 [details]
patch with renames and Frame parameter
Comment 24 WebKit Review Bot 2010-03-30 12:22:41 PDT
Attachment 52067 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/bindings/v8/V8Utilities.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 25 Darin Fisher (:fishd, Google) 2010-03-30 13:30:51 PDT
Comment on attachment 52067 [details]
patch with renames and Frame parameter

> Index: WebCore/bindings/v8/V8Utilities.cpp
...
> +void logPropertyAccess(v8::Local<v8::String> name, const v8::AccessorInfo& info)
...
> +                eventId = (unsigned long long) V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent));

^^^ shouldn't that be a reinterpret_cast?


> Index: WebKit/chromium/public/WebFrameClient.h
> ===================================================================
> --- WebKit/chromium/public/WebFrameClient.h	(revision 56799)
> +++ WebKit/chromium/public/WebFrameClient.h	(working copy)
> @@ -284,6 +284,9 @@ public:
>      // scripts.
>      virtual void didCreateIsolatedScriptContext(WebFrame*) { }
>  
> +    // Notifies that a cross-frame access was made.
> +    virtual void didMakeCrossFrameAccess(WebFrame* active, WebFrame* target, bool crossOrigin, const WebString& property, unsigned long long eventId) { }

Any reason not to name this the same as the FrameLoaderClient method?
Unless there is a good reason, I think it would be better to make them
match.
Comment 26 John Gregg 2010-03-30 14:14:33 PDT
Created attachment 52079 [details]
patch with rename and reinterpret_cast
Comment 27 WebKit Review Bot 2010-03-30 14:19:08 PDT
Attachment 52079 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/bindings/v8/V8Utilities.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 28 Darin Fisher (:fishd, Google) 2010-03-30 14:46:35 PDT
Comment on attachment 52079 [details]
patch with rename and reinterpret_cast

R=me, but cq- since there is some style issue.
Comment 29 John Gregg 2010-03-30 15:05:14 PDT
the style issue is a non-issue (see comments 6-8), unless that would cause the commit queue to not commit it?
Comment 30 Darin Fisher (:fishd, Google) 2010-03-30 15:49:21 PDT
Comment on attachment 52079 [details]
patch with rename and reinterpret_cast

OK.  sorry, i missed the earlier discussion!
Comment 31 WebKit Commit Bot 2010-03-31 01:37:20 PDT
Comment on attachment 52079 [details]
patch with rename and reinterpret_cast

Clearing flags on attachment: 52079

Committed r56829: <http://trac.webkit.org/changeset/56829>
Comment 32 WebKit Commit Bot 2010-03-31 01:37:26 PDT
All reviewed patches have been landed.  Closing bug.
Comment 33 Pavel Feldman 2010-03-31 10:03:48 PDT
Rolled out in http://trac.webkit.org/changeset/56849 due to inspector tests breakage.
Comment 34 Stephen Chenney 2013-04-09 16:09:41 PDT
LayoutTest failures for Chromium are being marked WontFix. The Bug is still accessible and referenced from TestExpectations.