Bug 66720 - chromium WebFrameImpl - don't load javascript URLs against chrome internal pages.
Summary: chromium WebFrameImpl - don't load javascript URLs against chrome internal pa...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: chrome://...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-22 14:58 PDT by Thomas Sepez
Modified: 2011-08-24 14:07 PDT (History)
4 users (show)

See Also:


Attachments
Patch (7.51 KB, patch)
2011-08-22 15:19 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff
Patch (9.58 KB, patch)
2011-08-22 17:12 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff
Patch (10.89 KB, patch)
2011-08-23 09:27 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff
Patch (12.14 KB, patch)
2011-08-23 09:42 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff
Patch (12.41 KB, patch)
2011-08-24 10:22 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff
Patch (12.98 KB, patch)
2011-08-24 11:55 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Sepez 2011-08-22 14:58:42 PDT
Running JS against a chrome:// page risks sensitive information.  Add a safeguard against malicious bookmarklets and the like to WebKit/Source/WebKit/chromium/src/WebFrameImpl.cpp
Comment 1 Thomas Sepez 2011-08-22 15:19:05 PDT
Created attachment 104751 [details]
Patch
Comment 2 Adam Barth 2011-08-22 15:46:36 PDT
Comment on attachment 104751 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=104751&action=review

> Source/WebKit/chromium/src/WebFrameImpl.cpp:2291
> +    // Protect privileged pages against bookmarklets and other javascript
> +    // manipulations.
> +    if (m_frame->document()->url().protocolIs("chrome")
> +        || m_frame->document()->url().protocolIs("chrome-extension"))
> +        return;

We shouldn't have these string literals in this code.  Isn't there something in SchemeRegistry we could use?
Comment 3 Thomas Sepez 2011-08-22 16:00:36 PDT
Didn't see an appropriate shouldTreatScheme... method in SchemeRegistry.h.  Also didn't see the literal "chrome" anywhere under webkit :( ... would this be added to a SchemeRegistry category outside of webkit by the browser itself?

eg,
$ find . -name \*.h -exec grep '"chrome' {} /dev/null \;
./Source/WebKit/chromium/base/logging.h://     "chromeos" directory.
$ find . -name \*.cpp -exec grep '"chrome' {} /dev/null \;
./Source/WebKit/chromium/src/BackForwardListChromium.cpp:const char backForwardNavigationScheme[] = "chrome-back-forward";
./Source/WebKit/chromium/src/WebFrameImpl.cpp:    if (m_frame->document()->url().protocolIs("chrome")
./Source/WebKit/chromium/src/WebFrameImpl.cpp:        || m_frame->document()->url().protocolIs("chrome-extension"))
./Source/WebKit/chromium/tests/WebFrameTest.cpp:          chromeURL("chrome://"
Comment 4 Adam Barth 2011-08-22 16:02:20 PDT
You can add a new type to SchemeRegistry.h.  Chrome registers a bunch of schemes at with SchemeRegistry when it initializes WebKit.
Comment 5 Thomas Sepez 2011-08-22 17:12:39 PDT
Created attachment 104770 [details]
Patch
Comment 6 Thomas Sepez 2011-08-22 17:15:56 PDT
Ok, but feels kind of wrong since only the chromium code path checks this particular registry.
Comment 7 Thomas Sepez 2011-08-22 17:33:21 PDT
Probably needs to get wrapped in a WebSecurityPolicy method ???
Comment 8 Adam Barth 2011-08-22 17:37:51 PDT
> Ok, but feels kind of wrong since only the chromium code path checks this particular registry.

Yeah, you should probably check this in ScriptController::executeIfJavaScriptURL also.

> Probably needs to get wrapped in a WebSecurityPolicy method ???

Yep!
Comment 9 Thomas Sepez 2011-08-23 09:27:41 PDT
Created attachment 104857 [details]
Patch
Comment 10 Thomas Sepez 2011-08-23 09:32:01 PDT
would ScriptController::executeIfJavaScriptURL affect <a href="javascript:"> cases, or only navigation from the browser itself?   Current patch only applies this test as before.
Comment 11 Thomas Sepez 2011-08-23 09:42:17 PDT
Created attachment 104860 [details]
Patch
Comment 12 Thomas Sepez 2011-08-23 09:42:51 PDT
Patch with two ChangeLogs.  For review.  Thanks.
Comment 13 Adam Barth 2011-08-24 10:05:32 PDT
Comment on attachment 104860 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=104860&action=review

> Source/WebCore/ChangeLog:8
> +        No new tests. (OOPS!)

This line will prevent this change from landing.  You should replace it with a line that says you wrote a Chromium WebKit API unit test.

> Source/WebCore/ChangeLog:9
> +

It would be nice to put some more explanation in the ChangeLog as to why we're making this change and whether we think this registry is useful for WebCore's JavaScript URL implementation.

> Source/WebCore/platform/SchemeRegistry.cpp:107
> +static URLSchemesMap& notAllowingJavascriptURLsSchemes()

This name seems slightly tortured, but I can see how it fits the pattern.
Comment 14 Adam Barth 2011-08-24 10:06:32 PDT
> would ScriptController::executeIfJavaScriptURL affect <a href="javascript:"> cases, or only navigation from the browser itself?   Current patch only applies this test as before.

Only the <a href="javascript:"> case.  I think it's fine to handle that case in a separate patch, but we should say that in the ChangeLog entry.
Comment 15 Adam Barth 2011-08-24 10:06:59 PDT
+fishd for WebKit API review.
Comment 16 Thomas Sepez 2011-08-24 10:22:08 PDT
Created attachment 105013 [details]
Patch
Comment 17 Thomas Sepez 2011-08-24 10:23:01 PDT
Reworked comments in change log in latest patch.
Comment 18 WebKit Review Bot 2011-08-24 11:09:12 PDT
Comment on attachment 105013 [details]
Patch

Rejecting attachment 105013 [details] from commit-queue.

Failed to run "['./Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '--bot-id=ec2-cq-03', '--port..." exit_code: 2

Last 500 characters of output:
at 63 (offset 3 lines).
Hunk #4 succeeded at 98 (offset 3 lines).
Hunk #5 succeeded at 119 (offset 3 lines).
Hunk #6 succeeded at 145 (offset 3 lines).
Hunk #7 succeeded at 191 with fuzz 1 (offset 24 lines).
1 out of 7 hunks FAILED -- saving rejects to file Source/WebKit/chromium/tests/WebFrameTest.cpp.rej
patching file Source/WebKit/chromium/tests/data/history.html

Failed to run "[u'/mnt/git/webkit-commit-queue/Tools/Scripts/svn-apply', u'--reviewer', u'Darin Fisher', u'--for..." exit_code: 1

Full output: http://queues.webkit.org/results/9485272
Comment 19 Thomas Sepez 2011-08-24 11:55:09 PDT
Created attachment 105033 [details]
Patch
Comment 20 Thomas Sepez 2011-08-24 11:56:10 PDT
Comment on attachment 105033 [details]
Patch

Merge conflict resolved.
Comment 21 Adam Barth 2011-08-24 13:52:49 PDT
Comment on attachment 105033 [details]
Patch

Forwarding fishd's r+.
Comment 22 WebKit Review Bot 2011-08-24 14:06:57 PDT
Comment on attachment 105033 [details]
Patch

Clearing flags on attachment: 105033

Committed r93734: <http://trac.webkit.org/changeset/93734>
Comment 23 WebKit Review Bot 2011-08-24 14:07:02 PDT
All reviewed patches have been landed.  Closing bug.