-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure out if TrustedURL needs to be absolute. #8
Comments
I think we should allow relative URLs so that's my bias but below I enumerate some intermediate measures and pros/cons. Not remotely exhaustive. Possible PosturesAllow relative URLsDisallow all relative URLsIncluding
Allow Fragment-only URLs but not othersThere are several kinds of relative URLs, but Std66 calls them out for special treatment because fragments are part of a URI reference, and a fragment-only change does not cause the browser to issue a network fetch. Make this per-IDL propertyPerhaps with an additional property AllowRelative annotation. RisksRequiring absolute URLs makes migration difficultI can't really quantify this but my sense is that relative URLs are so widely used that disallowing them would be a significant blocking factor to adoption, and that the main workaround would be to insert code that resolves relative URLs against the document's base URL at creation time which would have a similar risks to just allowing them, and would deprive the IDL property handlers of possibly valuable context. Safe URL resolved against base URL with unexpected protocolThis is possible since not all URLs are resolved against the document's base. For example, imported stylesheets are resolved against the URL of the stylesheet containing the import statement. Similarly for HTML imports. Part of a system blesses simple path URLs like //foo/
alert(1) My understanding is that a non-hierarchical URL like the above can be a base URL because some opaque schemes like
In any event, resolving a relative URL against an opaque URL should result in a URL in a different origin per https://url.spec.whatwg.org/#origin:
Relative URL masks attackIn some cases, an attack is more apparent when seen in context:
Encouraging user code to convert a relative URL to an absolute TrustedURL might give user code a place to flag this, and would prevent directory traversal by the server, but network requests by browsers do not contain excess ".." path segments (modulo ), and IDL endpoints can do as good a job of this as user code and doing it in the IDL handlers could provide more context to heuristic intrusion detection systems. |
This seems obsolete as types are just wrappers for strings, and the sinks perform the value normalization; please reopen if not. |
If we absolutize the TrustedURLs on creation, this might be backwards-incompatible, as
String(TrustedURL.unsafelyCreate(foo)) !== foo
. On the other hand, relative URLs may actually be a well-formed absolute URLs (http://foo.bar
is a valid URL path IIRC, so is//foo.bar/
), which may cause obvious problems when assigned to a sink.The text was updated successfully, but these errors were encountered: