WICG / Realms-Initialization-Control

Introduce security controls to same origin realms in web applications
MIT License
9 stars 0 forks source link

Escalation to code execution #16

Open weizman opened 2 weeks ago

weizman commented 2 weeks ago

The escalation-to-code-execution part of the explainer requires us to address it and think about it:

More thoughts:

I think I'm leaning towards option#2 (meta tag) which is a great sweet spot in the middle between a header and a JS API, because:

That being said, when comparing option#3 to the serviceWorker API, it makes a lot of sense, as the 2 are much alike in terms of power and SOP sensitivity

All in all, a lot to ponder, but what's becoming more clear to me is that option#1 (current proposal's state) is probably the worst one...

guybedford commented 2 weeks ago

In the case of the meta tag, would the CSP rules still apply to the script? If that were the case it would seem to rule out the remaining con?

weizman commented 2 weeks ago

Originally, I said the same thing before #15 got merged (exactly here), but then @yoavweiss said (rightfully so) how this wasn't a good answer, given how many consumers of the API could very likely be not very well informed about the importance of a strong CSP configuration. Now, it's one thing that they don't embrace a mechanizm such as CSP that can only upgrade their security, but it's a different story if they embrace RIC and it actually lowers their security if they are not capable of doing so in combination with CSP settings they weren't expecting. Or also, what if they just don't want to limit such scenarios with CSP, but do want to make use of RIC? If such a state lowers their security in some sense (as opposed to only improve it or leave it at the same level), then the API design might require some more thinking.

guybedford commented 2 weeks ago

Perhaps the RIC script it self could be script-src on the fallback but have a more refined CSP policy like ric-src that could be used to provide more granular control via the CSP?

mhofman commented 1 week ago

The biggest issue with non-header alternatives is in how to make sure it applies before any script in the current document. For example a script tag could appear before the meta tag. And for service workers, they are designed to not impede the first load of a page that previously didn't have a service worker installed.

weizman commented 1 week ago

Perhaps the RIC script it self could be script-src on the fallback but have a more refined CSP policy like ric-src that could be used to provide more granular control via the CSP?

Perhaps, but feels like things are getting messier going down this path.. Would prefer to come up with something that introduces less things to be aware of

weizman commented 1 week ago

The biggest issue with non-header alternatives is in how to make sure it applies before any script in the current document. For example a script tag could appear before the meta tag. And for service workers, they are designed to not impede the first load of a page that previously didn't have a service worker installed.

Why is it important though? From my perspective, being able to decide when RIC kicks in, and to allow scripts to run before it, is a feature rather than a bug.

Obviously you should make sure it's dictated before other scripts, but maybe you prefer not to for whatever use case relevant to you, nothing wrong with that.

mhofman commented 1 week ago

Why is it important though? From my perspective, being able to decide when RIC kicks in, and to allow scripts to run before it, is a feature rather than a bug.

The RIC script will apply to other realms as the first script running. If the same RIC script also applies to the main realm, it may run after these other scripts have run. I suppose there is a bigger question of in the common use case, would the main page RIC script would be the same as for dependent realms.

weizman commented 5 days ago

Being an issue worth pondering, we dived into this concern in the last Endo meeting and came back with some excellent conclusions of what restrictions we must apply so that a header remains the proper way to go with:

These should be formalized and integrated into the explainer.

https://youtu.be/V1qHJXX9BZk

weizman commented 2 days ago

while #26 address this issue, we (@yoavweiss) decided to consult the Security WG on our conclusions, so this issue remains open for wno