Bug 73959 - Web Inspector: allow cross-domain requests for inspector; use XHR, not custom InspectorFrontendHost methods to fetch things
Summary: Web Inspector: allow cross-domain requests for inspector; use XHR, not custom...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Andrey Kosyakov
URL:
Keywords:
Depends on:
Blocks: 97065
  Show dependency treegraph
 
Reported: 2011-12-06 15:54 PST by Andrey Kosyakov
Modified: 2014-12-13 15:53 PST (History)
13 users (show)

See Also:


Attachments
Patch (6.16 KB, patch)
2011-12-06 15:57 PST, Andrey Kosyakov
no flags Details | Formatted Diff | Diff
Patch (7.02 KB, patch)
2011-12-06 18:33 PST, Andrey Kosyakov
no flags Details | Formatted Diff | Diff
Patch (7.02 KB, patch)
2011-12-08 10:24 PST, Andrey Kosyakov
pfeldman: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Kosyakov 2011-12-06 15:54:34 PST
We used to rely on InspectorFrontendHost::loadResourceSynchronously to fetch third-party resources into inspector front-end (currently only used by source maps). This patch changes to use XHRs instead and grants cross-domain access to inspector front-end.
Comment 1 Andrey Kosyakov 2011-12-06 15:57:24 PST
Created attachment 118127 [details]
Patch
Comment 2 Timothy Hatcher 2011-12-06 16:11:29 PST
Comment on attachment 118127 [details]
Patch

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

> Source/WebCore/inspector/InspectorFrontendHost.cpp:125
> +    "file"

Is "file" really needed? That seems like a security risk. (Though the inspector is loaded as a file URL in Safari already, so I guess this isn't any worse.)
Comment 3 WebKit Review Bot 2011-12-06 16:47:37 PST
Comment on attachment 118127 [details]
Patch

Attachment 118127 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10741168

New failing tests:
http/tests/inspector/compiler-source-mapping.html
http/tests/inspector/compiler-source-mapping-debug.html
Comment 4 Andrey Kosyakov 2011-12-06 16:53:52 PST
(In reply to comment #2)
> (From update of attachment 118127 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=118127&action=review
> 
> > Source/WebCore/inspector/InspectorFrontendHost.cpp:125
> > +    "file"
> 
> Is "file" really needed? That seems like a security risk. (Though the inspector is loaded as a file URL in Safari already, so I guess this isn't any worse.)

We currently use this only to fetch source maps. I assume for someone doing development locally, it might be useful to load source maps from files -- although, perhaps, not something they won't survive without.

The loadResourceSynchronously method I was replacing seems not to prevent loading resources from files, so at least we keep the existing behavior.

If anyone feels strongly about allowing file access in the inspector, I don't mind removing it -- yet, as you pointed out, Safari won't be more secure, as it both hosts inspector front-end in a file: scheme and considers different files to be in a same security origin. Fro Chrome, apparently, there also is an escalation path from compromising front-end to local file access, since it allows file: schema access from extensions.
Comment 5 Andrey Kosyakov 2011-12-06 18:33:48 PST
Created attachment 118158 [details]
Patch
Comment 6 Andrey Kosyakov 2011-12-06 18:34:37 PST
Fixed another occurrence of loadResourceSynchronously() that I missed.
Comment 7 Pavel Podivilov 2011-12-07 02:48:02 PST
Comment on attachment 118158 [details]
Patch

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

> Source/WebCore/inspector/InspectorFrontendHost.cpp:137
> +    for (size_t i = 0; i < sizeof schemasToAllowRequestsFor / sizeof schemasToAllowRequestsFor[0]; ++i)

Please use WTF_ARRAY_LENGTH.

> Source/WebCore/inspector/front-end/CompilerSourceMapping.js:109
> +        var mapping = this._loadSynchronously(this._sourceMappingURL);

Why this moved out of try/catch block?

> Source/WebCore/inspector/front-end/CompilerSourceMapping.js:157
> +        return this._loadSynchronously(sourceURL);

Ditto.
Comment 8 Pavel Podivilov 2011-12-07 02:49:47 PST
(In reply to comment #4)
> (In reply to comment #2)
> > (From update of attachment 118127 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=118127&action=review
> > 
> > > Source/WebCore/inspector/InspectorFrontendHost.cpp:125
> > > +    "file"
> > 
> > Is "file" really needed? That seems like a security risk. (Though the inspector is loaded as a file URL in Safari already, so I guess this isn't any worse.)
> 
> We currently use this only to fetch source maps. I assume for someone doing development locally, it might be useful to load source maps from files -- although, perhaps, not something they won't survive without.
> 
> The loadResourceSynchronously method I was replacing seems not to prevent loading resources from files, so at least we keep the existing behavior.
> 

I think it prevents loading resources from files.
Comment 9 Adam Barth 2011-12-07 10:31:50 PST
Comment on attachment 118127 [details]
Patch

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

> Source/WebCore/inspector/InspectorFrontendHost.cpp:136
> +    KURL frontendURL = frontendPage->mainFrame()->loader()->originalRequest().url();
> +    m_frontendOrigin = SecurityOrigin::create(frontendURL);

Why not just frontendPage->mainFrame()->document()->securityOrigin() ?
Comment 10 Andrey Kosyakov 2011-12-08 10:17:15 PST
(In reply to comment #7)
> > +    for (size_t i = 0; i < sizeof schemasToAllowRequestsFor / sizeof schemasToAllowRequestsFor[0]; ++i)
> Please use WTF_ARRAY_LENGTH.

Fixed.

> Why this moved out of try/catch block?

Oops. Fixed as well.

> I think it prevents loading resources from files.

It does not.
Comment 11 Andrey Kosyakov 2011-12-08 10:18:09 PST
(In reply to comment #9)

> Why not just frontendPage->mainFrame()->document()->securityOrigin() ?

Thanks, fixed.
Comment 12 Andrey Kosyakov 2011-12-08 10:24:25 PST
Created attachment 118414 [details]
Patch
Comment 13 Pavel Feldman 2011-12-11 09:38:08 PST
Comment on attachment 118414 [details]
Patch

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

> Source/WebCore/inspector/InspectorFrontendHost.cpp:137
> +        SecurityPolicy::addOriginAccessWhitelistEntry(*m_frontendOrigin, schemasToAllowRequestsFor[i], "", true);

We should not grant additional privileges to the front-end origin since we can compromise the embedder. It is up to the embedder to choose the origin for the front-end and granting additional privileges there will be unexpected.