Skip to content
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

Does the privacy test need a same origin-domain or a same origin check? #187

Closed
rakuco opened this issue Feb 21, 2023 · 11 comments · Fixed by #236
Closed

Does the privacy test need a same origin-domain or a same origin check? #187

rakuco opened this issue Feb 21, 2023 · 11 comments · Fixed by #236

Comments

@rakuco
Copy link
Member

rakuco commented Feb 21, 2023

In other words, do we need to check for https://html.spec.whatwg.org/multipage/browsers.html#same-origin or https://html.spec.whatwg.org/multipage/browsers.html#same-origin-domain?

AFAICS the latter (which we currently use) just takes document.document into consideration compared to the "same origin" check.

I am not informed enough to know which to choose, so this is an honest question. Looking at https://dontcallmedom.github.io/webdex/s.html, "same origin-domain" is used by fewer specs, and https://bugs.chromium.org/p/chromium/issues/detail?id=1027191#c6 says "Specs use 'same origin' in pretty much all cases except where forced to otherwise for compat reasons. On particular, any modern spec is likely to not use 'same origin-domain' at all".

@kenchris
Copy link
Contributor

Me neither to be honest, which is why I followed the advice to do as other spec do and do the same as generic sensors :-)

But with what you write above, it seems that we should just use "same origin"

@rakuco
Copy link
Member Author

rakuco commented Feb 21, 2023

Yeah, I was trying to do some digging but only found out "same origin-domain" was introduced with w3c/sensors#206, w3c/sensors#213 and w3c/sensors#267 but there was no discussion about why it was preferred over just "same origin".

See also: whatwg/html#3747 (comment) and whatwg/html#2757 (comment)

It might be worth filing an HTML spec issue to double check, or find someone who can help clarify which one should be chosen here.

@kenchris
Copy link
Contributor

@cynthia @marcoscaceres would anyone of you two know / understand the difference between these two (same origin vs same origin domain), or know who would be the best to answer that?

@marcoscaceres
Copy link
Member

marcoscaceres commented Feb 21, 2023

Half joking... ChatGPT knows the HTML spec. If it wasn't down right now, I would ask it for an explanation 😂

Wait, the difference is in the algorithm (as those two concepts - same origin and same origin domain - are both just algorithms). There is even an example table in HTML:

Screenshot 2023-02-21 at 10 19 18 pm

So, looking at the third example in the table, "same origin domain" doesn't seem to take the port into consideration, but the domain must be the same:

("https", "example.org", 314, "example.org") | ("https", "example.org", 420, "example.org")

I think that's it! 🤞

(You can call me MarcosGPT from now on)

@marcoscaceres
Copy link
Member

Just as bit more clarification, have a look a little bit further up in the html spec where it turn URLs into tuples origins:

A tuple consists of:

A scheme (an ASCII string).
A host (a host).
A port (null or a 16-bit unsigned integer).
A domain (null or a domain). Null unless stated otherwise.

@kenchris
Copy link
Contributor

Thanks @marcoscaceres MarcosGPT :-) That indeed seems like a minor difference, and we probably should take that into consideration. As the same-origin domain is considered legacy/interopt, I don't see any reason why not to use same-origin instead.

@kenchris
Copy link
Contributor

A domain (null or a domain). Null unless stated otherwise.

Yes that is pretty much the part that I didn't follow. You will always have a domain when you have a document, so I guess that might break it for using this in workers as that would not have a document

@rakuco
Copy link
Member Author

rakuco commented Feb 21, 2023

I did take a look at the concepts and algorithms when filing this issue as well. What's not clear to me is whether "same origin-domain" is really something that should be phased out in specs and whether there's any case where it actually makes sense to use it rather than "same origin".

In any case, looking at https://developer.mozilla.org/en-US/docs/Web/API/Document/domain#setting_the_domain and https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#changing_origin it does look like we should be using "same origin" instead.

@marcoscaceres
Copy link
Member

If two knowledgeable (and extremely talented!) browser engineers are confused by what it written in that spec, then that's clearly a spec bug. I'd strongly encourage you to file a bug on HTML.

Clearly the editors of the HTML spec knew these two things would be super confusing, as they added the example table to help a bit... it might be good to just point them to the text that is troubling you above.

@marcoscaceres
Copy link
Member

Here is what ChatGPT said 🤣:

Kenneth and Raphael went to sea,
To learn about web security.
They learned about two concepts new,
Called "same origin" and "same origin-domain" too.

They found that when two URLs,
Have the same scheme, host, and port as well,
They're considered "same origin" true,
And that's all you need to know, it's true!

But if you want to check if two,
Origins have the same domain too,
Then "same origin-domain" you'll use,
And run an algorithm to prove the truth.

Kenneth and Raphael were happy to learn,
These concepts are useful, they could discern.
Now they'll use them to build websites,
With security that's rock-solid, and that's great!

@arskama
Copy link
Contributor

arskama commented Sep 28, 2023

It seems to be that we all agree that "same origin" is more suitable than "same origin-domain".
Furthermore more hints are showing that implementations are getting away from "same origin-domain" usage:

https://html.spec.whatwg.org/multipage/browsers.html#relaxing-the-same-origin-restriction
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/weborigin/security_origin.h;l=313;drc=933be5e5db24585647edcd7f507ba2d48c5757c8

As @rakuco pointed out also earlier, "same origin-domain" is used by fewer specs.

If no one really goes against it, I would propose the change from "same origin-domain" to "same origin"

arskama added a commit to arskama/compute-pressure that referenced this issue Sep 28, 2023
arskama added a commit to arskama/compute-pressure that referenced this issue Oct 2, 2023
From different sources [1][2][3], it looks like same origin-domain is not anymore recommended.
There is no obvious reason to keep same origin-domain in compute pressure specifications.
Instead same origin seems to be a better security check.

[1] https://html.spec.whatwg.org/multipage/browsers.html#relaxing-the-same-origin-restriction
[2] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/weborigin/security_origin.h;l=313;drc=933be5e5db24585647edcd7f507ba2d48c5757c8
[3] https://dontcallmedom.github.io/webdex/s.html

Fixes w3c#187
arskama added a commit that referenced this issue Oct 2, 2023
From different sources [1][2][3], it looks like same origin-domain is not anymore recommended.
There is no obvious reason to keep same origin-domain in compute pressure specifications.
Instead same origin seems to be a better security check.

[1] https://html.spec.whatwg.org/multipage/browsers.html#relaxing-the-same-origin-restriction
[2] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/weborigin/security_origin.h;l=313;drc=933be5e5db24585647edcd7f507ba2d48c5757c8
[3] https://dontcallmedom.github.io/webdex/s.html

Fixes #187
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 a pull request may close this issue.

4 participants