Skip to content
Merged
29 changes: 29 additions & 0 deletions website/docs/security/security-hardening.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,32 @@ To prevent any user from creating/editing CAPTCHA stages block API requests to t
- `/api/v3/managed/blueprints*`

With these restrictions in place, CAPTCHA stages can only be edited using [Blueprints on the file system](../customize/blueprints/index.md#storage---file).

### Content Security Policy (CSP)

:::caution
Setting up CSP incorrectly might result in the client not loading necessary third-party code.
:::

:::caution
In some cases, a CSP header will already be set by authentik (for example, in [user uploaded content](https://github.com/goauthentik/authentik/pull/12092/)). Do not overwrite an already existing header as doing so might result in vulnerabilities. Instead, add a new CSP header.
:::

Content Security Policy (CSP) is a security standard that mitigates the risk of content injection vulnerabilities. authentik doesn't currently support CSP natively, so setting it up depends on your installation. We recommend using a [reverse proxy](../install-config/reverse-proxy.md) to set a CSP header.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should cross-reference #12092 so that that behaviour is also documented. People deploying a custom csp might overlook this and override those headers.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a general warning not to overwrite any existing CSP header.

authentik requires at least the following allowed locations:

```
default-src 'self';
img-src 'https:' 'http:' 'data:';
object-src 'none';
style-src 'self' 'unsafe-inline'; # Required due to Lit/ShadowDOM
script-src 'self' 'unsafe-inline'; # Required for generated scripts
```

Your use case might require more allowed locations for various directives, e.g.

- when using a CAPTCHA service
- when using Sentry
- when using any custom JavaScript in a prompt stage
- when using Spotlight Sidecar for development