Skip to content

Conversation

carlosjoan91
Copy link

@carlosjoan91 carlosjoan91 commented Aug 20, 2025

This implements the work described in w3ctag/design-reviews#1128


Preview | Diff

Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Carlos, thanks for the PR. I took a quick pass through and have a few questions.

That said, as we move CSP into a more stable maintenance model, we're going to be a little stricter about what we land in the spec to ensure that we have support from implementers, reasonably solid tests, etc. Can you help me understand the current state of the feature from that perspective?


6. Let |documentURLTokens| and |resourceURLPathTokens| be the result of
<a lt="strictly split a string">strictly splitting</a> |documentURLPath|
and |resourceURLPath| respectively on the U+002F SOLIDUS character (`/`).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the point of serializing and then splitting. Could you more simply access the URL's path, which is already either a single segment or a list of segments? I think that dropping the last item off the list (assuming it's non-empty) would address 5, and get you something similar to what you get with the serializing/splitting.


Given a {{URL}} |resourceURL| and a {{URL}} |documentURL|,
this algorithm returns a {{String}} that represents the relative path of
|resourceURL| according to |documentURL| if they are same origin.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand the value of the check here? I think the goal is to specify what to hash in a way that's consistent across pages, but I don't understand why, for example, it's better to build a relative path than to hash the absolute path. Is the deployment story impacted one way or the other?

Comment on lines +4351 to +4355
15. [=list/iterate|For each=] |index| of [=the exclusive range=] 0 to |resultTokens|' [=list/size=] - 1:

1. Append |resultTokens|[|index|] to |result|.

2. Append U+002F SOLIDUS character (`/`) to |result|.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to rely on https://infra.spec.whatwg.org/#string-concatenate to construct |result|, which would let you consolidate 15.* and 16.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, I'll add a commit that switches to it

MegaCorp, Inc. now wants to deploy a more strict policy using <a grammar>`url-hash-source`</a>s:

<pre>
<a http-header>Content-Security-Policy</a>: <a>script-src</a> https: 'unsafe-inline' 'strict-dynamic-url' 'url-hash-EAaArVRs5qV39C9S3zO0z9ynVoWeZkuNfeMpsVDQnOk='
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this hash referring to? It's not script.js, /script.js, or https://example.com/script.js, so I feel like I'm missing something.


1. If the result of executing [[#match-request-to-source-list]] on
|request|, |directive|'s <a for="directive">value</a>, and
|policy|, is "`Does Not Match`", return "`Blocked`".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understands this step. If a url-hash-source expression is present, won't it be checked exhaustively in step 3, returning Allowed if it matches? We only get here when that expression doesn't match, in which case I'm not sure I understand why we ignore the rest of the source list checks. Do these expressions exclude other source list checks (non-URL hashes, for instance)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let @meacer correct me since he worked more on this section, but I think the intention is to ignore hosts if any URL hashes are set

@dveditz
Copy link
Member

dveditz commented Aug 25, 2025

From Mike's comment up top (#784 (review))

That said, as we move CSP into a more stable maintenance model, we're going to be a little stricter about what we land in the spec [...]

Part of that is that we need to have an issue in this repo, not TAG, where we can discuss and track the proposal before we ever get to landing a PR for it.

carlosjoan91 and others added 2 commits September 18, 2025 14:26
Co-authored-by: Mike West <[email protected]>
Co-authored-by: Mike West <[email protected]>
@carlosjoan91
Copy link
Author

Hey Carlos, thanks for the PR. I took a quick pass through and have a few questions.
Hey Mike, thanks for reviewing. I'm sorry about the delay, my default email for github notifications was set to one that I don't monitor, I've fixed it now. I left two of your questions unresolved because I think @meacer will have more context as he worked on the URL hashes section more than I did.

That said, as we move CSP into a more stable maintenance model, we're going to be a little stricter about what we land in the spec to ensure that we have support from implementers, reasonably solid tests, etc. Can you help me understand the current state of the feature from that perspective?

Our intention is to do an origin trial in Chrome 141, so this is currently fully implemented in Chrome (behind a runtime enabled feature), and we have some tentative WPTs (under https://github.com/web-platform-tests/wpt/tree/master/content-security-policy/script-src/tentative), as far as other implementers we have filed position requests, but have not received responses yet.

@carlosjoan91
Copy link
Author

From Mike's comment up top (#784 (review))

That said, as we move CSP into a more stable maintenance model, we're going to be a little stricter about what we land in the spec [...]

Part of that is that we need to have an issue in this repo, not TAG, where we can discuss and track the proposal before we ever get to landing a PR for it.

I think I might be misunderstanding the order of things. I had originally assumed that TAG review should happen before the PR can land (in fact I originally requested TAG review before even creating a PR, and just pointed the TAG review request to a diff, but a PR was requested as part of TAG review).

Is the correct order to handle discussions directly in the repo and get the PR landed (or maybe approved but not landed) before requesting TAG review?

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.

5 participants