Security: CSP policy allows unsafe inline scripts and styles on admin/API surface#586
Conversation
The CSP builder includes `script-src 'unsafe-inline'` and `style-src 'unsafe-inline'` for `/_emdash` routes. If any XSS injection occurs, inline script execution is permitted, substantially reducing CSP's mitigation value. Affected files: csp.ts Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
|
This just adds the rule without any indication as to whether this breaks the admin |
Problem
The CSP builder includes
script-src 'unsafe-inline'andstyle-src 'unsafe-inline'for/_emdashroutes. If any XSS injection occurs, inline script execution is permitted, substantially reducing CSP's mitigation value.Severity:
mediumFile:
packages/core/src/astro/middleware/csp.tsSolution
Move to nonce- or hash-based CSP for scripts/styles and remove
'unsafe-inline'. If inline styles are unavoidable, keep them scoped and remove unsafe inline scripts first. Addreport-uri/report-tofor CSP violation monitoring.Changes
packages/core/src/astro/middleware/csp.ts(modified)Testing