linux_hardening_guide:sysctl
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux_hardening_guide:sysctl [2025/05/31 15:07] – peter | linux_hardening_guide:sysctl [2025/05/31 15:19] (current) – peter | ||
---|---|---|---|
Line 172: | Line 172: | ||
</ | </ | ||
- | This helps protect against SYN flood attacks, which are a form of denial-of-service attack, in which an attacker sends a large amount of bogus SYN requests in an attempt to consume enough resources to make the system unresponsive to legitimate traffic. | + | This helps protect against |
---- | ---- | ||
Line 180: | Line 180: | ||
</ | </ | ||
- | This protects against time-wait assassination by dropping RST packets for sockets in the time-wait state. | + | This protects against |
---- | ---- | ||
Line 189: | Line 189: | ||
</ | </ | ||
- | These enable source validation of packets received from all interfaces of the machine. This protects against IP spoofing, in which an attacker sends a packet with a fraudulent IP address. | + | These enable source validation of packets received from all interfaces of the machine. |
+ | |||
+ | * This protects against | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | 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 | ||
+ | net.ipv4.conf.all.send_redirects=0 | ||
+ | net.ipv4.conf.default.send_redirects=0 | ||
+ | </ | ||
+ | |||
+ | These disable ICMP redirect acceptance and sending to prevent [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | net.ipv4.icmp_echo_ignore_all=1 | ||
+ | </ | ||
+ | |||
+ | This setting makes your system ignore all ICMP requests to avoid Smurf attacks, make the device more difficult to enumerate on the network and prevent clock fingerprinting through ICMP timestamps. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | net.ipv4.conf.all.accept_source_route=0 | ||
+ | net.ipv4.conf.default.accept_source_route=0 | ||
+ | net.ipv6.conf.all.accept_source_route=0 | ||
+ | net.ipv6.conf.default.accept_source_route=0 | ||
+ | </ | ||
+ | |||
+ | Source routing is a mechanism that allows users to redirect network traffic. | ||
+ | |||
+ | * As this can be used to perform man-in-the-middle attacks in which the traffic is redirected for nefarious purposes, the above settings disable this functionality. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | net.ipv6.conf.all.accept_ra=0 | ||
+ | net.ipv6.conf.default.accept_ra=0 | ||
+ | </ | ||
+ | |||
+ | Malicious IPv6 router advertisements can result in a man-in-the-middle attack, so they should be disabled. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | net.ipv4.tcp_sack=0 | ||
+ | net.ipv4.tcp_dsack=0 | ||
+ | net.ipv4.tcp_fack=0 | ||
+ | </ | ||
+ | |||
+ | This disables TCP SACK. | ||
+ | |||
+ | * SACK is commonly exploited and unnecessary in many circumstances, | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Recommended sysctl settings to change for User Space ====== | ||
+ | |||
+ | <code bash> | ||
+ | kernel.yama.ptrace_scope=2 | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | * This restricts usage of ptrace to only processes with the CAP_SYS_PTRACE capability. | ||
+ | * Alternatively, | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | vm.mmap_rnd_bits=32 | ||
+ | vm.mmap_rnd_compat_bits=16 | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | The values of these sysctls must be set in relation to the CPU architecture. The above values are compatible with x86, but other architectures may differ. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | fs.protected_symlinks=1 | ||
+ | fs.protected_hardlinks=1 | ||
+ | </ | ||
+ | |||
+ | This only permits symlinks to be followed when outside of a world-writable sticky directory, when the owner of the symlink and follower match or when the directory owner matches the symlink' | ||
+ | |||
+ | * This also prevents hardlinks from being created by users that do not have read/write access to the source file. | ||
+ | * Both of these prevent many common [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | fs.protected_fifos=2 | ||
+ | fs.protected_regular=2 | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
---- | ---- |
linux_hardening_guide/sysctl.1748704068.txt.gz · Last modified: 2025/05/31 15:07 by peter