Skip to content

[pre-flight] Match 'self' against non-special-scheme URLs via tuple-origin components - #2

Closed
jonathanKingston wants to merge 1 commit into
cifrom
self-tuple-origin
Closed

jonathanKingston wants to merge 1 commit into
cifrom
self-tuple-origin

Conversation

@jonathanKingston

Copy link
Copy Markdown

Pre-flight only — do not merge. This PR exists to run the fork's own CI
against the branch before it goes to rust-ammonia/rust-content-security-policy.
Merging it would put the commit on this fork's master and make future rebases
onto upstream messier.

The base is ci, which is upstream master plus the fork-only workflow. The diff
above is just the patch: the workflow file is on the base side only, so it never
reaches the branch we send upstream.

The 'self' fast path compares the protected resource's origin against
url.origin(), but the URL standard gives every non-special-scheme URL an
opaque origin - so for a document served over a scheme the user agent has
registered itself, 'self' could never match even an exactly same-origin
subresource, and the fallback branch only admits http(s)/ws(s). Any policy
at all therefore blocked every same-origin subresource on such a document.

A user agent that models those documents with tuple origins - the treatment
Chromium and WebKit give schemes registered as "standard", and what makes
`script-src 'self'` work on a chrome-extension:// or moz-extension:// page
today - now gets component comparison: equal scheme, equal host, and equal
ports, where "no port on either side" (tuple sentinel port 0, no default
port for the scheme) also counts as equal.

Same scheme only, and only for schemes with no default port. The existing
relaxation is the http -> https/wss upgrade allowance, which is meaningful
only for those schemes; extending it to a registered scheme would let
'self' in a custom://example.com document match https://example.com/.
Special schemes are otherwise unaffected: a same-scheme match there was
already taken by the origin-equality fast path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant