|
Block execution of failed 'crossorigin' <script>s.
The HTML spec tells us that if a script element has a 'crossorigin'
attribute, a potentially CORS enabled fetch of its source URL must be
performed:
http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#dfnReturnLink-39
http://www.whatwg.org/specs/web-apps/current-work/multipage/fetching-resources.html#potentially-cors-enabled-fetch
If the CORS cross-origin request status of that fetch is not a success
due to a failed CORS resource sharing check, the implementation must
act as if no script resource has been obtained.
No such CORS check was in place for parser inserted elements, allowing
a cross-origin CORS resource that either didn't permit the script
access or the resource wasn't CORS enabled, to load in the presence of
'crossorigin'.
Address this here by interposing a CORS check prior to starting script
execution. This (tries) to mirror how the operations are sequenced in
the underlying spec.
Specifically,
ScriptLoader::executePotentiallyCrossOriginScript()
now performs the needed access check for fetched scripts _if_ the
fetch was initiated as potentially CORS-enabled. That is, if the
script was fetched from same-origin or the CORS check passes in the
cross-origin case, then script execution can go ahead. If not and a
cross-origin script, a console error message is added and an error
event is dispatched. Script execution does not go ahead.
To support the above, the ResourceFetcher::canAccess() predicate over
resources now needs to be informed if the resource fetch was initiated
in a potentially CORS enabled manner. If it was, the required CORS
resource sharing check will be performed.
By making the "CORS enabled" property of a fetch something that a
loader keeps separate from the (potentially cached) resource, we can
simplify the underlying structure a bit, removing the
RequestOriginPolicy portion from the resource options.
As a result, FetchRequest now instead keeps track of any origin
restrictions of the fetch resource + the canAccess() predicate must be
supplied with the "CORS enabled" setting to use when checking access
to the actual resource.
R=mkwst,abarth
BUG= 286684
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=162417
Total comments: 2
Total comments: 13
Total comments: 4
Total comments: 2
Total comments: 2
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+278 lines, -89 lines) |
Patch |
|
M |
LayoutTests/http/tests/security/cross-origin-css.html
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+7 lines, -1 line |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/cross-origin-css-expected.txt
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/resources/cors-script.php
|
View
|
|
1 chunk |
+7 lines, -1 line |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-fails-cross-origin.html
|
View
|
1
2
|
1 chunk |
+22 lines, -0 lines |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-fails-cross-origin-2.xhtml
|
View
|
|
1 chunk |
+32 lines, -0 lines |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-fails-cross-origin-2-expected.txt
|
View
|
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
|
A + |
LayoutTests/http/tests/security/script-crossorigin-fails-cross-origin-expected.txt
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/script-crossorigin-loads-correctly.html
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
A + |
LayoutTests/http/tests/security/script-crossorigin-loads-correctly-credentials.html
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-loads-correctly-credentials-2.html
|
View
|
1
2
|
1 chunk |
+44 lines, -0 lines |
0 comments
|
Download
|
|
A + |
LayoutTests/http/tests/security/script-crossorigin-loads-correctly-credentials-2-expected.txt
|
View
|
1
2
|
1 chunk |
+3 lines, -5 lines |
0 comments
|
Download
|
|
A + |
LayoutTests/http/tests/security/script-crossorigin-loads-correctly-credentials-expected.txt
|
View
|
|
0 chunks |
+-1 lines, --1 lines |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-loads-cross-origin.html
|
View
|
|
1 chunk |
+22 lines, -0 lines |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-loads-cross-origin-2.xhtml
|
View
|
|
1 chunk |
+30 lines, -0 lines |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-loads-cross-origin-2-expected.txt
|
View
|
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
|
A |
LayoutTests/http/tests/security/script-crossorigin-loads-cross-origin-expected.txt
|
View
|
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/script-onerror-crossorigin-cors.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/script-onerror-crossorigin-no-cors.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+14 lines, -13 lines |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/script-onerror-crossorigin-no-cors-expected.txt
|
View
|
|
1 chunk |
+2 lines, -7 lines |
0 comments
|
Download
|
|
A + |
LayoutTests/http/tests/security/script-onerror-crossorigin-same-origin.html
|
View
|
1
2
3
4
5
6
|
2 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
|
A + |
LayoutTests/http/tests/security/script-onerror-crossorigin-same-origin-expected.txt
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/script-onerror-no-crossorigin-cors.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
LayoutTests/http/tests/security/script-onerror-no-crossorigin-no-cors.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
Source/core/css/CSSImageValue.h
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
Source/core/css/CSSImageValue.cpp
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+6 lines, -6 lines |
0 comments
|
Download
|
|
M |
Source/core/css/resolver/StyleResourceLoader.cpp
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+1 line, -2 lines |
0 comments
|
Download
|
|
M |
Source/core/dom/ScriptLoader.h
|
View
|
1
2
3
4
|
3 chunks |
+8 lines, -0 lines |
0 comments
|
Download
|
|
M |
Source/core/dom/ScriptLoader.cpp
|
View
|
1
2
3
4
5
6
7
8
|
6 chunks |
+20 lines, -5 lines |
0 comments
|
Download
|
|
M |
Source/core/fetch/FetchRequest.h
|
View
|
1
2
3
4
5
|
3 chunks |
+5 lines, -1 line |
0 comments
|
Download
|
|
M |
Source/core/fetch/FetchRequest.cpp
|
View
|
1
2
3
4
5
|
4 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
|
M |
Source/core/fetch/ResourceFetcher.h
|
View
|
1
2
3
4
5
6
7
8
|
3 chunks |
+7 lines, -2 lines |
0 comments
|
Download
|
|
M |
Source/core/fetch/ResourceFetcher.cpp
|
View
|
1
2
3
4
5
6
7
8
|
8 chunks |
+10 lines, -10 lines |
0 comments
|
Download
|
|
M |
Source/core/fetch/ResourceLoaderOptions.h
|
View
|
1
2
3
4
|
5 chunks |
+0 lines, -10 lines |
0 comments
|
Download
|
|
M |
Source/core/html/HTMLImportLoader.cpp
|
View
|
1
2
3
4
5
6
7
8
9
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
Source/core/html/HTMLImportsController.cpp
|
View
|
1
2
3
4
5
6
7
8
9
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
Source/core/html/parser/HTMLScriptRunner.cpp
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
Source/core/loader/DocumentLoader.cpp
|
View
|
1
2
3
4
5
6
7
8
9
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
Source/core/xml/XSLTProcessorLibxslt.cpp
|
View
|
1
2
3
4
5
6
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
Source/core/xml/parser/XMLDocumentParser.cpp
|
View
|
1
2
3
4
5
6
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
Total messages: 42 (0 generated)
|