Commit 58fcd775 authored by Frédéric Wang's avatar Frédéric Wang Committed by Chromium LUCI CQ

Limit about: URLs that are treated as potentially trustworthy

Per [1], only about:blank and about:srcdoc URLs should be treated as
potentially trustworthy, but Chromium currently accepts all about: URLs.
This CL aligns with the current spec, with the additional assumption
that query and fragment components are accepted too [2]. This change is
not web-visible.

[1] https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url
[2] https://github.com/w3c/webappsec-secure-contexts/issues/81

Bug: 1153335, 1153336
Change-Id: I907d90596b4895a3d3b6efbfd535b2efe9e9cc8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563492
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833066}
parent 2b747ef5
...@@ -269,9 +269,7 @@ bool IsUrlPotentiallyTrustworthy(const GURL& url) { ...@@ -269,9 +269,7 @@ bool IsUrlPotentiallyTrustworthy(const GURL& url) {
// 1. If url is "about:blank" or "about:srcdoc", return "Potentially // 1. If url is "about:blank" or "about:srcdoc", return "Potentially
// Trustworthy". // Trustworthy".
// TODO(https://crbug.com/1153335): This should probably instead rely on if (url.IsAboutBlank() || url.IsAboutSrcdoc())
// something like url.IsAboutBlank() || url.IsAboutSrcdoc().
if (url.SchemeIs(url::kAboutScheme))
return true; return true;
// 2. If url’s scheme is "data", return "Potentially Trustworthy". // 2. If url’s scheme is "data", return "Potentially Trustworthy".
......
...@@ -50,8 +50,7 @@ TEST(IsPotentiallyTrustworthy, MainTest) { ...@@ -50,8 +50,7 @@ TEST(IsPotentiallyTrustworthy, MainTest) {
EXPECT_TRUE(IsPotentiallyTrustworthy("about:srcdoc#ref")); EXPECT_TRUE(IsPotentiallyTrustworthy("about:srcdoc#ref"));
EXPECT_TRUE(IsPotentiallyTrustworthy("about:srcdoc?x=2#ref")); EXPECT_TRUE(IsPotentiallyTrustworthy("about:srcdoc?x=2#ref"));
// TODO(https://crbug.com/1153335): This should return false. EXPECT_FALSE(IsPotentiallyTrustworthy("about:about"));
EXPECT_TRUE(IsPotentiallyTrustworthy("about:about"));
// TODO(https://crbug.com/1119740): Should return true for data: URLs. // TODO(https://crbug.com/1119740): Should return true for data: URLs.
EXPECT_FALSE(IsPotentiallyTrustworthy("data:test/plain;blah")); EXPECT_FALSE(IsPotentiallyTrustworthy("data:test/plain;blah"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment