Add 'self' to CSP script-src directive only when strictly necessary #54
Labels
csp
Content-Security-Policy
enhancement
New feature or request
sri
SubResource Integrity
ssr
Related to Server-Side-Rendered Content
As of today, Astro-Shield always adds the
'self'
source to avoid potential problems with static imports present inside loaded scripts.Although this is not dangerous, it is arguably less safe than just adding the hashes of the specific resources that will be loaded, and it is not always necessary (loaded scripts not always have static imports inside them, which is the only reason to add the
self
source).My proposal is to detect when those
import
statements are present in the loaded scripts, and then add theself
source only in those cases.The text was updated successfully, but these errors were encountered: