From f3a032dee5d2da64b0e925bf81293dd42d58e7fc Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sun, 14 Feb 2021 22:07:40 +0300 Subject: [PATCH] nixos/mastodon: enable sandbox mode --- nixos/modules/services/web-apps/mastodon.nix | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix index ea7aebc3b12..16e8ae2ec0b 100644 --- a/nixos/modules/services/web-apps/mastodon.nix +++ b/nixos/modules/services/web-apps/mastodon.nix @@ -43,8 +43,32 @@ let LogsDirectoryMode = "0750"; # Access write directories UMask = "0027"; + # Capabilities + CapabilityBoundingSet = ""; + # Security + NoNewPrivileges = true; # Sandboxing + ProtectSystem = "strict"; + ProtectHome = true; PrivateTmp = true; + PrivateDevices = true; + PrivateUsers = true; + ProtectClock = true; + ProtectHostname = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectControlGroups = true; + RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" "AF_NETLINK" ]; + RestrictNamespaces = true; + LockPersonality = true; + MemoryDenyWriteExecute = false; + RestrictRealtime = true; + RestrictSUIDSGID = true; + PrivateMounts = true; + # System Call Filtering + SystemCallArchitectures = "native"; + SystemCallFilter = "~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @reboot @resources @setuid @swap"; }; envFile = pkgs.writeText "mastodon.env" (lib.concatMapStrings (s: s + "\n") (