LavaMoat / snow

Use Snow to finally secure your web app's same origin realms!
https://lavamoat.github.io/snow/demo/
MIT License
100 stars 9 forks source link

[WIP] How can we steer away from relying on CSP for security? #137

Closed weizman closed 10 months ago

weizman commented 10 months ago

Again with CSP?!

A surprising take, considering #133, I know, so let me make things clear:

I'm not saying "hi, let's stop using CSP and make Snow unsafe again on purpose", I'm saying "can we block uncommonly used patterns to achieve the same level of security in Snow without relying on CSP?"

For that, there are some questions to be answered:

List of specific concerns Snow relies on CSP for

unsafe-inlines (test @ https://lavamoat.github.io/snow/demo/?disable_csp)

String-based attacks made things really complicated for Snow, these are the vectors Snow 2.0.1 loses to when CSP is turned off:

  1. javascript: URIs - these allow some wacky scenarios which make things rather complicated for Snow, for example I can't think of good protection against TAGarxenix great finds:
// https://github.com/LavaMoat/snow/issues/80
// leverages the ability to establish a new tab with sync power to harm the opening realm
(function(){
    testdiv.innerHTML = `<form id="pwn" method="GET" target="lolpwnd" action="javascript:opener.bypass([window])">`;
    document.querySelector("#pwn").submit();
}());
(function(){
// https://github.com/LavaMoat/snow/issues/80
// leverages the ability to establish a new tab with sync power to harm the opening realm
    testdiv.innerHTML = `<a id="pwn" target="lolpwnd" href="javascript:opener.bypass([window])">`;
    document.querySelector("#pwn").click();
}());

What makes these two complicated is that fact they can be formed via HTML, which means Snow must deal with all sort of new DOM APIs in order to win this (for example, the need to start hooking into DOM nodes attribute setting :kill-me:)

  1. srcdoc attribute - Also a lot of pain, srcdoc introduces a lot of problems, mainly around its ability to introduce nesting documents which can be used to harm Snow, some great former examples by TAGmmndaniel :