RESOLVED FIXED 181460
REGRESSION(r225650): The scores of MotionMark tests Multiply and Leaves dropped by 8%
https://bugs.webkit.org/show_bug.cgi?id=181460
Summary REGRESSION(r225650): The scores of MotionMark tests Multiply and Leaves dropp...
Said Abou-Hallawa
Reported 2018-01-09 16:34:35 PST
After the change https://trac.webkit.org/changeset/225650>, the score of the MotionMark tests MotionMark tests Multiply and Leaves dropped by 8%.
Attachments
patch (1.66 KB, patch)
2018-01-10 02:51 PST, Antti Koivisto
rniwa: review+
Archive of layout-test-results from ews106 for mac-sierra-wk2 (2.65 MB, application/zip)
2018-01-10 04:00 PST, EWS Watchlist
no flags
patch (1.65 KB, patch)
2018-01-10 07:54 PST, Antti Koivisto
no flags
patch (1.75 KB, patch)
2018-01-12 00:53 PST, Antti Koivisto
no flags
Said Abou-Hallawa
Comment 1 2018-01-09 16:35:20 PST
Antti Koivisto
Comment 2 2018-01-10 02:51:55 PST
EWS Watchlist
Comment 3 2018-01-10 04:00:17 PST
Comment on attachment 330885 [details] patch Attachment 330885 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/6018037 New failing tests: webgl/1.0.2/conformance/uniforms/uniform-default-values.html
EWS Watchlist
Comment 4 2018-01-10 04:00:19 PST
Created attachment 330890 [details] Archive of layout-test-results from ews106 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Darin Adler
Comment 5 2018-01-10 07:49:31 PST
Comment on attachment 330885 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=330885&action=review > Source/WebCore/css/parser/CSSParser.cpp:81 > + , hasDocumentSecurityOrigin(document.baseURL() == baseURL ? true : document.securityOrigin().canRequest(baseURL)) I would use || here instead of ? :
Antti Koivisto
Comment 6 2018-01-10 07:54:09 PST
WebKit Commit Bot
Comment 7 2018-01-10 10:19:42 PST
Comment on attachment 330906 [details] patch Clearing flags on attachment: 330906 Committed r226721: <https://trac.webkit.org/changeset/226721>
WebKit Commit Bot
Comment 8 2018-01-10 10:19:44 PST
All reviewed patches have been landed. Closing bug.
Alexey Proskuryakov
Comment 9 2018-01-10 15:36:40 PST
Comment on attachment 330906 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=330906&action=review > Source/WebCore/css/parser/CSSParser.cpp:81 > + , hasDocumentSecurityOrigin(document.baseURL() == baseURL || document.securityOrigin().canRequest(baseURL)) Can this tweak be made in canRequest to make it fast instead? But also, I'm actually not sure if identical base URL is good enough for not having a security boundary, between origins in this case.
Darin Adler
Comment 10 2018-01-10 21:09:50 PST
Comment on attachment 330906 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=330906&action=review >> Source/WebCore/css/parser/CSSParser.cpp:81 >> + , hasDocumentSecurityOrigin(document.baseURL() == baseURL || document.securityOrigin().canRequest(baseURL)) > > Can this tweak be made in canRequest to make it fast instead? > > But also, I'm actually not sure if identical base URL is good enough for not having a security boundary, between origins in this case. As for the first question, maybe there is some other way to make a fast path, but we can’t make this exact optimization because canRequest does not have access to the document’s baseURL. For the second question, I suggest we work together to turn your uncertainty into a test case.
Antti Koivisto
Comment 11 2018-01-11 02:06:22 PST
Yeah, SecurityOrigin::canRequest is inefficient (heap allocating a temporary SecurityOrigin for example) and could be optimized. However that will require bit more refactoring than should be done in this patch. The logic here is about figuring out if the stylesheet content is readable via getMatchedCSSRules. The rules from the document itself are supposed to be accessible.
Ryosuke Niwa
Comment 12 2018-01-11 13:09:06 PST
(In reply to Antti Koivisto from comment #11) > Yeah, SecurityOrigin::canRequest is inefficient (heap allocating a temporary > SecurityOrigin for example) and could be optimized. However that will > require bit more refactoring than should be done in this patch. > > The logic here is about figuring out if the stylesheet content is readable > via getMatchedCSSRules. The rules from the document itself are supposed to > be accessible. Are you sure this won't allow two null-origin documents to be treated as if sharing the same origin?
Antti Koivisto
Comment 13 2018-01-11 14:00:18 PST
> Are you sure this won't allow two null-origin documents to be treated as if > sharing the same origin? CSSParser parses rules either from the document or from stylesheets loaded by the document. I don't know how that would happen.
Ryosuke Niwa
Comment 14 2018-01-11 14:02:17 PST
(In reply to Antti Koivisto from comment #13) > > Are you sure this won't allow two null-origin documents to be treated as if > > sharing the same origin? > > CSSParser parses rules either from the document or from stylesheets loaded > by the document. I don't know how that would happen. How about data URLs?
Antti Koivisto
Comment 15 2018-01-11 14:27:30 PST
> How about data URLs? Can you be more specific about the scenario?
Alexey Proskuryakov
Comment 16 2018-01-11 15:01:49 PST
The new security check is different form the old one. Base URL can be anything, as the page author can specify any base with the <base> element. It's not the same URL that the security context is created from. The sheetBaseURL argument seems like a misnomer. Chris and I looked at one caller, and it was actually passing final stylesheet URL there (the one after redirects). So that's controllable by the attacker, who can start with their own server, and redirect to the victim. It does seem likely that documents with unique origins also get extra powers with this change. But I can't follow CSS code enough to tell what the observable effect is. Given that we started with a security check, it probably is a security regression of some sort.
Chris Dumez
Comment 17 2018-01-11 15:10:19 PST
Comment on attachment 330906 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=330906&action=review >>> Source/WebCore/css/parser/CSSParser.cpp:81 >>> + , hasDocumentSecurityOrigin(document.baseURL() == baseURL || document.securityOrigin().canRequest(baseURL)) >> >> Can this tweak be made in canRequest to make it fast instead? >> >> But also, I'm actually not sure if identical base URL is good enough for not having a security boundary, between origins in this case. > > As for the first question, maybe there is some other way to make a fast path, but we can’t make this exact optimization because canRequest does not have access to the document’s baseURL. > > For the second question, I suggest we work together to turn your uncertainty into a test case. I would worry a lot less if this would be using document.url() rather than document.baseURL(). AFAIK, the document baseURL can be overridden by a <base> element and the document's securityOrigin comes from its URL, not its baseURL.
Alexey Proskuryakov
Comment 18 2018-01-11 16:07:35 PST
I think that document.url() would make the problem less obvious, but it needs to be explicitly demonstrated that unique origins are not a problem here. Even so, spreading slightly alternative security checks across the code base is a long term liability.
WebKit Commit Bot
Comment 19 2018-01-12 00:38:25 PST
Re-opened since this is blocked by bug 181583
Antti Koivisto
Comment 20 2018-01-12 00:53:45 PST
Alexey Proskuryakov
Comment 21 2018-01-12 10:06:02 PST
Comment on attachment 331184 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=331184&action=review > Source/WebCore/ChangeLog:13 > + Don't do the expensive security origin test if the supplied sheet base URL is null. This > + is true for rules coming from the same document. I think that this is still changing the behavior when the document can't make requests to its own base URL (which is the case at least whenever there is a <base> element with a different origin URL, or for unique origins).
Antti Koivisto
Comment 22 2018-01-12 11:19:21 PST
> I think that this is still changing the behavior when the document can't > make requests to its own base URL (which is the case at least whenever there > is a <base> element with a different origin URL, or for unique origins). The purpose of this bit is to block access to stylesheet via getMatchedCSSRules legacy API in cases where it could not be accessed otherwise via DOM. As you can see from CSSStyleSheet::canAccessRules normal access is granted when the sheet base URL is empty. (There is also a cors related test that is missing here, not sure if it is relevant).
Alexey Proskuryakov
Comment 23 2018-01-12 22:08:41 PST
> The purpose of this bit is to block access to stylesheet via getMatchedCSSRules legacy API in cases where it could not be accessed otherwise via DOM. As you can see from CSSStyleSheet::canAccessRules normal access is granted when the sheet base URL is empty. This may mean that the patch is OK, I didn't analyze CSS code deep enough to agree or disagree. But I think that it's missing a couple tests. We have three different behaviors here: 1. Original behavior before r226721. 2. Behavior with r226721. 3. Behavior with this patch. It seems wrong to not have any tests differentiating between these.
Antti Koivisto
Comment 24 2018-01-17 06:49:00 PST
Improving test coverage would be nice but bit outside the scope of this bug.
youenn fablet
Comment 25 2018-01-18 07:24:56 PST
I agree canRequest should be optimized. We should not allocate a SecurityOrigin object, at least in the usual cases of http/data URLs. If we were doing so, the proposed additional check might no longer be needed. If we land that patch, can we either add a FIXME in CSSParserContext::CSSParserContext or even better quickly come with an optimization of canRequest and revert this change at that time?
youenn fablet
Comment 26 2018-01-18 08:57:49 PST
Comment on attachment 331184 [details] patch Can we write a test with a data frame containing inline CSS? That would also allow us to check what other browsers are doing there.
Antti Koivisto
Comment 27 2018-01-18 09:15:58 PST
Gecko never implemented getMatchedCSSRules in the first place and Chrome is trying to remove it (or already removed?).
WebKit Commit Bot
Comment 28 2018-01-18 09:50:05 PST
Comment on attachment 331184 [details] patch Clearing flags on attachment: 331184 Committed r227147: <https://trac.webkit.org/changeset/227147>
WebKit Commit Bot
Comment 29 2018-01-18 09:50:07 PST
All reviewed patches have been landed. Closing bug.
Simon Fraser (smfr)
Comment 30 2018-01-18 10:54:38 PST
Comment on attachment 331184 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=331184&action=review > Source/WebCore/css/parser/CSSParser.cpp:83 > + Extra blank line here.
Note You need to log in before you can comment on or make changes to this bug.