Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Unified Diff: Source/core/frame/csp/CSPSourceListTest.cpp

Issue 1178373004: 'blob:' URLs should not match 'self' in CSP source expression lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Exclude extensions. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/csp/CSPSourceList.cpp ('k') | Source/core/frame/csp/ContentSecurityPolicy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/csp/CSPSourceListTest.cpp
diff --git a/Source/core/frame/csp/CSPSourceListTest.cpp b/Source/core/frame/csp/CSPSourceListTest.cpp
index 9c1374f77445370f3601b1ccacaf2d92d2672978..be247b10f40980c1ec7063dcb275b12aaeb8aa9f 100644
--- a/Source/core/frame/csp/CSPSourceListTest.cpp
+++ b/Source/core/frame/csp/CSPSourceListTest.cpp
@@ -9,6 +9,7 @@
#include "core/frame/csp/CSPSource.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "platform/weborigin/KURL.h"
+#include "platform/weborigin/SchemeRegistry.h"
#include "platform/weborigin/SecurityOrigin.h"
#include <gtest/gtest.h>
@@ -65,6 +66,37 @@ TEST_F(CSPSourceListTest, BasicMatchingSelf)
EXPECT_TRUE(sourceList.matches(KURL(base, "https://example.test/")));
}
+TEST_F(CSPSourceListTest, BlobMatchingSelf)
+{
+ KURL base;
+ String sources = "'self'";
+ CSPSourceList sourceList(csp.get(), "script-src");
+ parseSourceList(sourceList, sources);
+
+ EXPECT_TRUE(sourceList.matches(KURL(base, "https://example.test/")));
+ EXPECT_FALSE(sourceList.matches(KURL(base, "blob:https://example.test/")));
+
+ // Register "https" as bypassing CSP, which should trigger the innerURL behavior.
+ SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy("https");
+
+ EXPECT_TRUE(sourceList.matches(KURL(base, "https://example.test/")));
+ EXPECT_TRUE(sourceList.matches(KURL(base, "blob:https://example.test/")));
+
+ // Unregister the scheme to clean up after ourselves.
+ SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy("https");
+}
+
+TEST_F(CSPSourceListTest, BlobMatchingBlob)
+{
+ KURL base;
+ String sources = "blob:";
+ CSPSourceList sourceList(csp.get(), "script-src");
+ parseSourceList(sourceList, sources);
+
+ EXPECT_FALSE(sourceList.matches(KURL(base, "https://example.test/")));
+ EXPECT_TRUE(sourceList.matches(KURL(base, "blob:https://example.test/")));
+}
+
TEST_F(CSPSourceListTest, BasicMatching)
{
KURL base;
« no previous file with comments | « Source/core/frame/csp/CSPSourceList.cpp ('k') | Source/core/frame/csp/ContentSecurityPolicy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698