Modified: trunk/LayoutTests/ChangeLog (229867 => 229868)
--- trunk/LayoutTests/ChangeLog 2018-03-22 21:59:41 UTC (rev 229867)
+++ trunk/LayoutTests/ChangeLog 2018-03-22 22:02:58 UTC (rev 229868)
@@ -1,3 +1,19 @@
+2018-03-22 Daniel Bates <[email protected]>
+
+ CSS mask images should be retrieved using potentially CORS-enabled fetch
+ https://bugs.webkit.org/show_bug.cgi?id=179983
+ <rdar://problem/35678149>
+
+ Reviewed by Brent Fulgham.
+
+ Add a test to ensure we do not fetch a cross-origin CSS mask image that does
+ not allow CORS access.
+
+ * http/tests/security/css-mask-image-expected.html: Added.
+ * http/tests/security/css-mask-image.html: Added.
+ * http/tests/security/resources/black-square.png: Added.
+ * http/tests/security/resources/fail-mask.png: Added.
+
2018-03-22 Zalan Bujtas <[email protected]>
[Simple line layout] Text with letter spacing is not positioned properly.
Added: trunk/LayoutTests/http/tests/security/css-mask-image-expected.html (0 => 229868)
--- trunk/LayoutTests/http/tests/security/css-mask-image-expected.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/css-mask-image-expected.html 2018-03-22 22:02:58 UTC (rev 229868)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.square {
+ width: 128px;
+ height: 128px;
+}
+</style>
+</head>
+<body>
+<p>This tests that a potentially CORS fetch is performed for a CSS mask image. This test PASSED if you see a solid yellow square and solid blue square below (in order). Otherwise, it FAILED.</p>
+<p>Without CORS access:</p>
+<div class="square" style="background-color: yellow"></div>
+<p>With CORS access:</p>
+<div class="square" style="background-color: blue"></div>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/security/css-mask-image.html (0 => 229868)
--- trunk/LayoutTests/http/tests/security/css-mask-image.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/css-mask-image.html 2018-03-22 22:02:58 UTC (rev 229868)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.square {
+ width: 128px;
+ height: 128px;
+}
+
+.blue-background {
+ background-color: blue;
+}
+
+.mask-cors-no-access {
+ mask-image: url("http://localhost:8000/security/resources/image-access-control.php?file=fail-mask.png");
+ mask-size: 128px 128px;
+ -webkit-mask-image: url("http://localhost:8000/security/resources/image-access-control.php?file=fail-mask.png");
+ -webkit-mask-size: 128px 128px;
+}
+
+.mask-cors-has-access {
+ mask-image: url("http://localhost:8000/security/resources/image-access-control.php?allow=true&file=black-square.png");
+ mask-size: 128px 128px;
+ -webkit-mask-image: url("http://localhost:8000/security/resources/image-access-control.php?allow=true&file=black-square.png");
+ -webkit-mask-size: 128px 128px;
+}
+</style>
+</head>
+<body>
+<p>This tests that a potentially CORS fetch is performed for a CSS mask image. This test PASSED if you see a solid yellow square and solid blue square below (in order). Otherwise, it FAILED.</p>
+<p>Without CORS access:</p>
+<div class="square" style="background-color: yellow"><div class="square blue-background mask-cors-no-access"></div></div>
+<p>With CORS access:</p>
+<div class="square blue-background mask-cors-has-access"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (229867 => 229868)
--- trunk/Source/WebCore/ChangeLog 2018-03-22 21:59:41 UTC (rev 229867)
+++ trunk/Source/WebCore/ChangeLog 2018-03-22 22:02:58 UTC (rev 229868)
@@ -1,3 +1,29 @@
+2018-03-22 Daniel Bates <[email protected]>
+
+ CSS mask images should be retrieved using potentially CORS-enabled fetch
+ https://bugs.webkit.org/show_bug.cgi?id=179983
+ <rdar://problem/35678149>
+
+ Reviewed by Brent Fulgham.
+
+ As per <https://drafts.fxtf.org/css-masking-1/#priv-sec> (Editor's Draft, 23 December 2017)
+ we should fetch CSS mask images using a potentially CORS-enabled fetch.
+
+ Both cross-origin CSS shape-outside images and CSS mask images may be sensitive to timing
+ attacks that can be used to reveal their pixel data when retrieved without regard to CORS.
+ For the same reason that we fetch CSS shape-outside images using a potentially CORS-enabled
+ fetch we should fetch CSS mask the same way. This also makes the behavior of WebKit more
+ closely align with the behavior in the spec.
+
+ Test: http/tests/security/css-mask-image.html
+
+ * style/StylePendingResources.cpp: Substitute LoadPolicy::NoCORS and LoadPolicy::Anonymous for
+ LoadPolicy::Normal and LoadPolicy::ShapeOutside, respectively, to match the terminology used
+ in the HTML, CSS Shapes Module Level 1, and CSS Masking Module Level 1 specs.
+ (WebCore::Style::loadPendingImage): Ditto.
+ (WebCore::Style::loadPendingResources): Use load policy LoadPolicy::Anonymous when fetching
+ a mask image or shape-outside image.
+
2018-03-22 Zalan Bujtas <[email protected]>
[Simple line layout] Text with letter spacing is not positioned properly.
Modified: trunk/Source/WebCore/style/StylePendingResources.cpp (229867 => 229868)
--- trunk/Source/WebCore/style/StylePendingResources.cpp 2018-03-22 21:59:41 UTC (rev 229867)
+++ trunk/Source/WebCore/style/StylePendingResources.cpp 2018-03-22 22:02:58 UTC (rev 229868)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,8 +41,9 @@
namespace WebCore {
namespace Style {
-enum class LoadPolicy { Normal, ShapeOutside };
-static void loadPendingImage(Document& document, const StyleImage* styleImage, const Element* element, LoadPolicy loadPolicy = LoadPolicy::Normal)
+// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attributes> (21 March 2018)
+enum class LoadPolicy { NoCORS, Anonymous };
+static void loadPendingImage(Document& document, const StyleImage* styleImage, const Element* element, LoadPolicy loadPolicy = LoadPolicy::NoCORS)
{
if (!styleImage || !styleImage->isPending())
return;
@@ -50,8 +51,7 @@
ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
options.contentSecurityPolicyImposition = element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
- // FIXME: Why does shape-outside have different policy than other properties?
- if (loadPolicy == LoadPolicy::ShapeOutside) {
+ if (loadPolicy == LoadPolicy::Anonymous) {
options.mode = FetchOptions::Mode::Cors;
options.credentials = FetchOptions::Credentials::SameOrigin;
options.storedCredentialsPolicy = StoredCredentialsPolicy::DoNotUse;
@@ -85,11 +85,14 @@
if (auto* reflection = style.boxReflect())
loadPendingImage(document, reflection->mask().image(), element);
+ // Masking operations may be sensitive to timing attacks that can be used to reveal the pixel data of
+ // the image used as the mask. As a means to mitigate such attacks CSS mask images and shape-outside
+ // images are retreived in "Anonymous" mode, which uses a potentially CORS-enabled fetch.
for (auto* maskLayer = &style.maskLayers(); maskLayer; maskLayer = maskLayer->next())
- loadPendingImage(document, maskLayer->image(), element);
+ loadPendingImage(document, maskLayer->image(), element, LoadPolicy::Anonymous);
if (style.shapeOutside())
- loadPendingImage(document, style.shapeOutside()->image(), element, LoadPolicy::ShapeOutside);
+ loadPendingImage(document, style.shapeOutside()->image(), element, LoadPolicy::Anonymous);
}
}