helm/modules/security.nix
Henrik Lissner 51d63a1829 Bump
* Updated agenix: github:ryantm/agenix/ed7e69bff3c17671349839f696e88e345eb9eb24 -> github:ryantm/agenix/9eb981eeb552e0856cb562b7643b311933a0e992
* Updated emacs-overlay: github:nix-community/emacs-overlay/063ee066b5095dd2f21f47c582b04024674974a8 -> github:nix-community/emacs-overlay/daa4b15755f6cccb462efed696abceee0994bb96
* Updated home-manager: github:rycee/home-manager/f45c7000d544f17e5499e2ae6b505b5f705c5d61 -> github:rycee/home-manager/040ea28e448a93d24540b7cf2eda4b25300c5ab1
* Updated nixos-hardware: github:nixos/nixos-hardware/c9b965a43e582765f797f8b75d50cb2874b30f30 -> github:nixos/nixos-hardware/831de9cac9ff2ea8cf4c3742020ea92e82ac8ac3
* Updated nixpkgs: github:NixOS/nixpkgs/ff96a0fa5635770390b184ae74debea75c3fd534 -> github:NixOS/nixpkgs/29b0d4d0b600f8f5dd0b86e3362a33d4181938f9
* Updated nixpkgs-unstable: github:NixOS/nixpkgs/07b0c7bc4104b87cb5223ec10e32b863d10768ad -> github:NixOS/nixpkgs/d02b1cc8ed29b6967119fd95267ee1a955015d59

Also, removed noexec from /tmp because it screws with build processes
that deploy/execute scripts to/out of /tmp, causing permission errors
while building.
2021-03-12 01:01:12 -05:00

71 lines
2.9 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ config, lib, ... }:
{
## System security tweaks
# sets hidepid=2 on /proc (make process info visible only to owning user)
# NOTE Was removed on nixpkgs-unstable because it doesn't do anything
# security.hideProcessInformation = true;
# Prevent replacing the running kernel w/o reboot
security.protectKernelImage = true;
# tmpfs = /tmp is mounted in ram. Doing so makes temp file management speedy
# on ssd systems, and volatile! Because it's wiped on reboot.
boot.tmpOnTmpfs = lib.mkDefault true;
# If not using tmpfs, which is naturally purged on reboot, we must clean it
# /tmp ourselves. /tmp should be volatile storage!
boot.cleanTmpDir = lib.mkDefault (!config.boot.tmpOnTmpfs);
# Fix a security hole in place for backwards compatibility. See desc in
# nixpkgs/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
boot.loader.systemd-boot.editor = false;
boot.kernel.sysctl = {
# The Magic SysRq key is a key combo that allows users connected to the
# system console of a Linux kernel to perform some low-level commands.
# Disable it, since we don't need it, and is a potential security concern.
"kernel.sysrq" = 0;
## TCP hardening
# Prevent bogus ICMP errors from filling up logs.
"net.ipv4.icmp_ignore_bogus_error_responses" = 1;
# Reverse path filtering causes the kernel to do source validation of
# packets received from all interfaces. This can mitigate IP spoofing.
"net.ipv4.conf.default.rp_filter" = 1;
"net.ipv4.conf.all.rp_filter" = 1;
# Do not accept IP source route packets (we're not a router)
"net.ipv4.conf.all.accept_source_route" = 0;
"net.ipv6.conf.all.accept_source_route" = 0;
# Don't send ICMP redirects (again, we're on a router)
"net.ipv4.conf.all.send_redirects" = 0;
"net.ipv4.conf.default.send_redirects" = 0;
# Refuse ICMP redirects (MITM mitigations)
"net.ipv4.conf.all.accept_redirects" = 0;
"net.ipv4.conf.default.accept_redirects" = 0;
"net.ipv4.conf.all.secure_redirects" = 0;
"net.ipv4.conf.default.secure_redirects" = 0;
"net.ipv6.conf.all.accept_redirects" = 0;
"net.ipv6.conf.default.accept_redirects" = 0;
# Protects against SYN flood attacks
"net.ipv4.tcp_syncookies" = 1;
# Incomplete protection again TIME-WAIT assassination
"net.ipv4.tcp_rfc1337" = 1;
## TCP optimization
# TCP Fast Open is a TCP extension that reduces network latency by packing
# data in the senders initial TCP SYN. Setting 3 = enable TCP Fast Open for
# both incoming and outgoing connections:
"net.ipv4.tcp_fastopen" = 3;
# Bufferbloat mitigations + slight improvement in throughput & latency
"net.ipv4.tcp_congestion_control" = "bbr";
"net.core.default_qdisc" = "cake";
};
boot.kernelModules = [ "tcp_bbr" ];
# Change me later!
user.initialPassword = "nixos";
users.users.root.initialPassword = "nixos";
# So we don't have to do this later...
security.acme.acceptTerms = true;
}