|
|
|
|
|
by iamkonstantin
720 days ago
|
|
What is a rendering engine with CSP in mind? The server can, at best, set the correct CSP header. It’s a validation performed entirely in the browser. Even the best intended rendering from the server can’t prevent CSP violation attempts when the client is executing some kind of script. That’s why even frameworks like Vue and React need a correctly configured CSP. |
|
The renderer could rewrite
to (the boilerplate can be amortized over many such handlers)Or at least use 'unsafe-hashes' and compute the hashes for onclick handlers and the like and include those in the CSP.
Separation of style/scripts/content has been encouraged for a long time, I don't know why people are walking it back. But if they insist then templates could also be structured more like a multipart document where those aspects sit in separate parts of the document.
As long as you do any of those when the template renderers are compiled then only scripts whitelisted at buildtime will be executed and scripts injected by dynamic content will get blocked.