-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Some <meta>
tags are informational (let's call these passive)
<meta name="description" content="...">
And some affect the page in some way (let's call these active)
<meta http-equiv="Set-Cookie" content="SESSID=1">
In CSP there is no way to revoke the power of these active ones.
<meta http-equiv="...
is a tag on the page that may emulate a subset of functions normally reserved for page headers. Equally, some of these functions appear in JavaScript (which is obviously already heavily governed by CSP).
Dangerous functions that can be performed by <meta http-equiv="...
include
- Set-Cookie
- Refresh
- Redirect to any regular URL
- Redirect to any data: URL
Of course you can also set the content-type, or cache-control etc... but as far as I'm aware the user-agent conventionally prefers to honour the value in a header if that's specified (though if they can easily be covered in the same directive, these could be addressed in CSP too).
So focusing on functions that cannot currently be disabled, consider the example
With a CSP
Content-Security-Policy: default-src 'self';
While the above policy would prevent <script>document.cookie='SESSID=1'</script>
from executing, if injected by an adversary; CSP is currently unable to prevent <meta http-equiv="Set-Cookie" content="SESSID=1">
from executing – which performs the same function (even on noscript browsers).
Allowing this type of <meta>
tag allows any XSS injection vector to be coupled with Session Fixation even if a good CSP is specified.
Refresh, of course doesn't open up scripting in the page context. What it does do however, is load a new page context – meaning CSP specified now won't matter.
An entire page can be specified within a 'data:' URL, e.g. containing a form that could post to "http://phisher.example.com/collect.php" – even if the page that had triggered the redirect had a CSP restricting form POSTs to go to 'self'.
I mention both of these, because they can both be addressed by the same directive: http-equiv
e.g.
Content-Security-Policy: default-src 'self';
, or Content-Security-Policy: http-equiv 'self';
would disallow http-equiv in <meta>
, 'self' would infer the equivalent headers should be used. 'none' keyword would have equivalent meaning here.
Hashes could be used to selectively enable based on the content="...". Similarly nonces could be specified inline.
Optionally, the values for http-equiv could be selectively specified to enable them
Content-Security-Policy: http-equiv 'set-cookie' 'refresh';
, or Content-Security-Policy: http-equiv set-cookie refresh;
Content-Security-Policy: http-equiv 'unsafe-inline';
could be used restore default unsafe behaviour.
Obviously there are a few ways this could be implemented, the above is a suggestion. The main aim here is that site owners have a mechanism whereby they may disable active <meta>
tags if they don't want to use them.