diff --git a/src/routes/solid-start/guides/security.mdx b/src/routes/solid-start/guides/security.mdx index ff1351caf..ad249f652 100644 --- a/src/routes/solid-start/guides/security.mdx +++ b/src/routes/solid-start/guides/security.mdx @@ -2,35 +2,205 @@ title: Security --- -As a non-opinionated framework, SolidStart doesn't enforce any security practices, though it enables developers to implement them as needed. -It is important to know what are the requirements for your own app and implement the fitting security measures. -If at any point you are unsure about the security of your app, or how to achieve something within the constraints of SolidStart reach us on [Discord](https://discord.gg/solidjs). +## XSS (Cross Site Scripting) -Below you will find a few notes on how to establish some measures. +Solid automatically escape values passed to JSX expressions to reduce the risk of XSS attacks. +However, this protection does not apply when using [`innerHTML`](/reference/jsx-attributes/innerhtml-or-textcontent#innerhtml-or-textcontent). -## Security Headers +To protect your application from XSS attacks: -Through the use of a [middleware](/solid-start/reference/server/create-middleware#example) it is possible to tab into the `onRequest` event handlers and make sure every request going through your servers have the proper security headers set. -With this, it is possible to setup headers like `Content-Security-Policy`, `X-Frame-Options`, `X-XSS-Protection`, `X-Content-Type-Options`, among others. +- Avoid using `innerHTML` when possible. + If necessary, make sure to sanitize user-supplied data with libraries such as [DOMPurify](https://github.com/cure53/DOMPurify). +- Validate and sanitize user inputs, especially form inputs on the server and client. +- Set a [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP). +- Sanitize attributes containing user-supplied data within `