logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

hardening.md (4262B)


  1. # Hardening your instance
  2. Here are some suggestions which improve the security of parts of your Pleroma instance.
  3. ## Configuration file
  4. These changes should go into `prod.secret.exs` or `dev.secret.exs`, depending on your `MIX_ENV` value.
  5. ### `http`
  6. > Recommended value: `[ip: {127, 0, 0, 1}]`
  7. This sets the Pleroma application server to only listen to the localhost interface. This way, you can only reach your server over the Internet by going through the reverse proxy. By default, Pleroma listens on all interfaces.
  8. ### `secure_cookie_flag`
  9. > Recommended value: `true`
  10. This sets the `secure` flag on Pleroma’s session cookie. This makes sure, that the cookie is only accepted over encrypted HTTPs connections. This implicitly renames the cookie from `pleroma_key` to `__Host-pleroma-key` which enforces some restrictions. (see [cookie prefixes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#Cookie_prefixes))
  11. ### `:http_security`
  12. > Recommended value: `true`
  13. This will send additional HTTP security headers to the clients, including:
  14. * `X-XSS-Protection: "1; mode=block"`
  15. * `X-Permitted-Cross-Domain-Policies: "none"`
  16. * `X-Frame-Options: "DENY"`
  17. * `X-Content-Type-Options: "nosniff"`
  18. * `X-Download-Options: "noopen"`
  19. A content security policy (CSP) will also be set:
  20. ```csp
  21. content-security-policy:
  22. default-src 'none';
  23. base-uri 'self';
  24. frame-ancestors 'none';
  25. img-src 'self' data: blob: https:;
  26. media-src 'self' https:;
  27. style-src 'self' 'unsafe-inline';
  28. font-src 'self';
  29. script-src 'self';
  30. connect-src 'self' wss://example.tld;
  31. manifest-src 'self';
  32. upgrade-insecure-requests;
  33. ```
  34. #### `sts`
  35. > Recommended value: `true`
  36. An additional “Strict transport security” header will be sent with the configured `sts_max_age` parameter. This tells the browser, that the domain should only be accessed over a secure HTTPs connection.
  37. #### `ct_max_age`
  38. An additional “Expect-CT” header will be sent with the configured `ct_max_age` parameter. This enforces the use of TLS certificates that are published in the certificate transparency log. (see [Expect-CT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT))
  39. #### `referrer_policy`
  40. > Recommended value: `same-origin`
  41. If you click on a link, your browser’s request to the other site will include from where it is coming from. The “Referrer policy” header tells the browser how and if it should send this information. (see [Referrer policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy))
  42. ### Uploaded media and media proxy
  43. It is STRONGLY RECOMMENDED to serve both the locally-uploaded media and the media proxy from another domain than the domain that Pleroma runs on, if applicable.
  44. ```elixir
  45. config :pleroma, :media_proxy,
  46. base_url: "https://some.other.domain"
  47. config :pleroma, Pleroma.Upload,
  48. base_url: "https://some.other.domain/media"
  49. ```
  50. See `installation/pleroma-mediaproxy.nginx` for examples on how to configure your media proxy.
  51. ## systemd
  52. A systemd unit example is provided at `installation/pleroma.service`.
  53. ### PrivateTmp
  54. > Recommended value: `true`
  55. Use private `/tmp` and `/var/tmp` folders inside a new file system namespace, which are discarded after the process stops.
  56. ### ProtectHome
  57. > Recommended value: `true`
  58. The `/home`, `/root`, and `/run/user` folders can not be accessed by this service anymore. If your Pleroma user has its home folder in one of the restricted places, or use one of these folders as its working directory, you have to set this to `false`.
  59. ### ProtectSystem
  60. > Recommended value: `full`
  61. Mount `/usr`, `/boot`, and `/etc` as read-only for processes invoked by this service.
  62. ### PrivateDevices
  63. > Recommended value: `true`
  64. Sets up a new `/dev` mount for the process and only adds API pseudo devices like `/dev/null`, `/dev/zero` or `/dev/random` but not physical devices. This may not work on devices like the Raspberry Pi, where you need to set this to `false`.
  65. ### NoNewPrivileges
  66. > Recommended value: `true`
  67. Ensures that the service process and all its children can never gain new privileges through `execve()`.
  68. ### CapabilityBoundingSet
  69. > Recommended value: `~CAP_SYS_ADMIN`
  70. Drops the sysadmin capability from the daemon.