As explained in the Chromium documentation [1], "URLs are often not sufficient for security decisions, since the origin may not be present in the URL (e.g., about:blank), may be tricky to parse (e.g., blob: or filesystem: URLs), or may be opaque despite a normal-looking URL (e.g., the security context may be sandboxed)".
Unfortunately, Brave uses at the moment GURL in several places where url::Origin should be used instead (e.g. in brave::BraveRequestInfo::tab_origin, and other places), which is becoming an increasingly bigger problem as upstream Chromium is progressively migrating away from GURL as well.
Also, note that this not only affects C++ files but also mojo definitions as well, see for instance:
Thus, filing this issue to track down the effort of converting as much as possible to url::Origin instead of using GURL (and maybe cases using strings as well, such as this one).
In summary, as mentioned in [1], we should use the following datatypes to represent origins:
C++: url::Origin or blink::SecurityOrigin (instead of GURL or blink::KURL).
Mojo: url.mojom.Origin (instead of url.mojom.Url).
Java: org.chromium.url.Origin (see also url::Origin::FromJavaObject and url::Origin::CreateJavaObject).
Description
As explained in the Chromium documentation [1], "URLs are often not sufficient for security decisions, since the origin may not be present in the URL (e.g., about:blank), may be tricky to parse (e.g., blob: or filesystem: URLs), or may be opaque despite a normal-looking URL (e.g., the security context may be sandboxed)".
Unfortunately, Brave uses at the moment
GURL
in several places whereurl::Origin
should be used instead (e.g. inbrave::BraveRequestInfo::tab_origin
, and other places), which is becoming an increasingly bigger problem as upstream Chromium is progressively migrating away from GURL as well.Also, note that this not only affects C++ files but also mojo definitions as well, see for instance:
Thus, filing this issue to track down the effort of converting as much as possible to
url::Origin
instead of usingGURL
(and maybe cases using strings as well, such as this one).In summary, as mentioned in [1], we should use the following datatypes to represent origins:
url::Origin
orblink::SecurityOrigin
(instead ofGURL
orblink::KURL
).url.mojom.Origin
(instead ofurl.mojom.Url
).org.chromium.url.Origin
(see alsourl::Origin::FromJavaObject
andurl::Origin::CreateJavaObject
).[1] https://chromium.googlesource.com/chromium/src/+/main/docs/security/origin-vs-url.md