Skip to content

Commit a02ed4c

Browse files
Merge branch 'main' into docs/rendering-modes
2 parents 4bdba75 + 1ba7cbf commit a02ed4c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/routes/solid-start/guides/security.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ However, this protection does not apply when using [`innerHTML`](/reference/jsx-
99

1010
To protect your application from XSS attacks:
1111

12+
- Set a [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
13+
- Validate and sanitize user inputs, especially form inputs on the server and client.
1214
- Avoid using `innerHTML` when possible.
1315
If necessary, make sure to sanitize user-supplied data with libraries such as [DOMPurify](https://github.com/cure53/DOMPurify).
14-
- Validate and sanitize user inputs, especially form inputs on the server and client.
15-
- Set a [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
1616
- Sanitize attributes containing user-supplied data within `<noscript>` elements.
1717
This includes both the attributes of the `<noscript>` element itself and its children.
18+
- When URLs are provided or constructed via user input validate its `origin` and `protocol` (to avoid evaluating code via `javascript:` URLs) using the [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) API.
1819

1920
It is highly recommended to read the [Cross Site Scripting Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html) for further guidance.
2021

@@ -135,7 +136,7 @@ export default createMiddleware({
135136

136137
## CSRF (Cross-Site Request Forgery)
137138

138-
To prevent CSRF attacks, a middleware can be used to block untrusted requests:
139+
To prevent basic CSRF attacks, a middleware can be used to block untrusted requests:
139140

140141
```tsx
141142
import { createMiddleware } from "@solidjs/start/middleware";
@@ -193,6 +194,7 @@ export default createMiddleware({
193194
```
194195

195196
This example demonstrates a basic CSRF protection that verifies the `Origin` and `Referer` headers, blocking requests from untrusted origins.
197+
**Please note both of these headers can be forged.**
196198
Additionally, consider implementing a more robust CSRF protection mechanism, such as the [Double-Submit Cookie Pattern](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#alternative-using-a-double-submit-cookie-pattern).
197199

198200
For further guidance, you can look at the [Cross-Site Request Forgery Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html).

0 commit comments

Comments
 (0)