security: replace v-html with safe directive to prevent XSS#847
security: replace v-html with safe directive to prevent XSS#847serdfxe wants to merge 1 commit intodalibo:masterfrom
Conversation
|
Thanks for this contribution. Given what's written in VueJS documentation, it is possible to use Unless I'm wrong, there's no possible XSS attack. If you see any, please provide an example of a plan, query or title that could be harmful. |
|
Thanks for reviewing this! I discovered this issue while integrating PEV2 into a production environment at a big tech company. Our security audit flagged the Concrete example of the vulnerability: When a user submits input like: The generated HTML contains unsanitized user input which gets executed via Real-world risk: The vulnerability becomes critical in public-facing deployments (similar to services like explain.tensor.ru). An attacker could craft a malicious SQL query with XSS payload and share the link. When another user views it, the XSS executes in their browser, potentially stealing session cookies or sensitive data from query plans. Impact on project adoption: For an opensource project, having known XSS vulnerabilities in the codebase makes it:
My PR adds defense in depth with DOMPurify, which is a security best practice for handling HTML rendering when user input is involved. |
|
@serdfxe would you mind rebasing your branch to fix conflicts with changes on the master branch? |
|
I see one problem with the implementation. The custom directive should not be created in the example application. Because, if PEV2 is used as a library (ie. without the code from the example directory), the directive won't exist. Can you please find a way to declare the directive somewhere in the code in |
Summary
Replaces unsafe
v-htmlusage with a sanitizedv-safe-htmldirective to prevent XSS vulnerabilities.Problem
Several components use
v-htmlto render content, which could execute malicious scripts if the content contains user-controlled input. This creates XSS vulnerabilities.Solution
v-safe-htmlthat sanitizes HTML before renderingv-htmlwithv-safe-htmlTesting
npm run build)npm run lint)