security: add Content-Security-Policy to all renderer pages - #441
Conversation
None of the three HTML files set a CSP meta tag, leaving the renderer exposed to potential XSS via innerHTML-built context menus and icons if any user-controlled data is ever rendered. Add a strict policy that limits script/style/image/font/connect sources to 'self' (plus the Google Fonts origins and data: image URIs used by the CSS) and blocks all inline script execution, eval, and inline event handlers. style-src keeps 'unsafe-inline' because settings.html relies heavily on inline style attributes, which do not enable script execution in modern engines; script-src 'self' still prevents inline scripts, event handlers, and eval.
|
@Kirtan-pc is attempting to deploy a commit to the Dot_NotSam's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🎉 Congratulations @Kirtan-pc! 🎉 Your pull request has been successfully merged into Paraline! Thank you so much for your valuable contribution and effort. Every single improvement helps make Paraline a better desktop experience for everyone! 🙌 🚀 What's Next?
💬 Stay Connected: Thank you again, and keep up the amazing work! 💻✨ |
Description
Fixes the missing Content-Security-Policy on all three renderer pages by adding a strict CSP meta tag that restricts sources to
'self'and blocks inline script execution.Changes
index.html,settings.html, andonboarding.html.default-src 'self'restricts all resource loading to local files.script-src 'self'blocks inline scripts, inline event handlers, andeval(), closing the XSS vector for theinnerHTML-built context menus and icon SVGs.style-src 'self' 'unsafe-inline'plushttps://fonts.googleapis.comkeeps the Google Fonts stylesheet and the inlinestyleattributes thatsettings.htmlrelies on for its layout working.font-srcallows the Inter font files fromhttps://fonts.gstatic.com.img-src 'self' data:allows the local theme previews and thedata:image/svg+xmltextures used instyles.css/settings.css.connect-srcpreserves the Google Fontspreconnecthints.script-srcremains the effective XSS mitigation while keeping the UI functional.Related Issue
Closes #400
Testing
npm testjavascript:URIs, oreval()/new Function()usage exist in any renderer HTML or JavaScript.Benefits
eval().