2021-01-12 09:17:13 +07:00
|
|
|
# Enhances miscellaneous security settings
|
2015-12-16 04:05:03 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Kernel hardening
|
2019-09-15 21:07:50 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
This section is inspired by the Kernel Self Protection Project (KSPP). It
|
2024-08-18 22:34:14 +07:00
|
|
|
attempts to implement all recommended Linux kernel settings by the KSPP and
|
|
|
|
many more sources.
|
2019-09-15 21:07:50 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- https://kspp.github.io/Recommended_Settings
|
2024-08-26 08:21:26 +07:00
|
|
|
- https://github.com/KSPP/kspp.github.io
|
2019-09-15 21:07:50 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
### sysctl
|
2016-11-22 00:42:55 +07:00
|
|
|
|
2024-07-13 19:41:40 +07:00
|
|
|
sysctl settings are configured via the `/usr/lib/sysctl.d/990-security-misc.conf`
|
2024-08-21 09:51:51 +07:00
|
|
|
configuration file and significant hardening is applied to a myriad of components.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-08-21 09:51:51 +07:00
|
|
|
Kernel space:
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Restrict access to kernel addresses through the use of kernel pointers regardless
|
|
|
|
of user privileges.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Restrict access to the kernel logs to `CAP_SYSLOG` as they often contain
|
|
|
|
sensitive information.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Prevent kernel information leaks in the console during boot.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-08-26 09:40:04 +07:00
|
|
|
- Restrict usage of `bpf()` to `CAP_BPF` to prevent the loading of BPF programs
|
|
|
|
by unprivileged users.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Restrict loading TTY line disciplines to `CAP_SYS_MODULE`.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Restrict the `userfaultfd()` syscall to `CAP_SYS_PTRACE`, which reduces the
|
|
|
|
likelihood of use-after-free exploits.
|
2019-06-24 02:51:53 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Disable `kexec` as it can be used to replace the running kernel.
|
2019-06-24 02:51:53 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Entirely disable the SysRq key so that the Secure Attention Key (SAK)
|
|
|
|
can no longer be utilized. See [documentation](https://www.kicksecure.com/wiki/SysRq).
|
2022-07-13 19:25:53 +07:00
|
|
|
|
2024-12-18 10:36:09 +07:00
|
|
|
- Optional - Disable all use of user namespaces.
|
|
|
|
|
2024-10-03 13:58:58 +07:00
|
|
|
- Optional - Restrict user namespaces to `CAP_SYS_ADMIN` as they can lead to substantial
|
|
|
|
privilege escalation.
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Restrict kernel profiling and the performance events system to `CAP_PERFMON`.
|
2023-12-25 20:37:23 +07:00
|
|
|
|
2024-08-28 22:57:32 +07:00
|
|
|
- Force the kernel to panic on both "oopses", which can potentially indicate and thwart
|
|
|
|
certain kernel exploitation attempts, and also kernel warnings in the `WARN()` path.
|
2024-11-29 04:20:57 +07:00
|
|
|
|
2024-10-14 09:57:31 +07:00
|
|
|
- Optional - Force immediate reboot on the occurrence of a single kernel panic and also
|
2024-08-28 22:57:32 +07:00
|
|
|
(when using Linux kernel >= 6.2) limit the number of allowed panics to one.
|
2024-07-25 07:26:23 +07:00
|
|
|
|
2024-08-05 12:06:34 +07:00
|
|
|
- Disable the use of legacy TIOCSTI operations which can be used to inject keypresses.
|
2024-08-02 21:25:49 +07:00
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Disable asynchronous I/O (when using Linux kernel >= 6.6) as `io_uring` has been
|
|
|
|
the source of numerous kernel exploits.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-08-21 09:51:51 +07:00
|
|
|
User space:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Restrict usage of `ptrace()` to only processes with `CAP_SYS_PTRACE` as it
|
2024-08-16 10:24:25 +07:00
|
|
|
enables programs to inspect and modify other active processes. Optional - Disable
|
|
|
|
usage of `ptrace()` by all processes.
|
2020-02-16 03:28:30 +07:00
|
|
|
|
2024-09-25 06:54:49 +07:00
|
|
|
- Maximize the bits of entropy used for mmap ASLR across all CPU architectures.
|
2024-08-09 10:39:25 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Prevent hardlink and symlink TOCTOU races in world-writable directories.
|
2023-11-04 21:33:35 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Disallow unintentional writes to files in world-writable directories unless
|
|
|
|
they are owned by the directory owner to mitigate some data spoofing attacks.
|
2023-11-04 21:33:35 +07:00
|
|
|
|
2024-08-16 10:39:11 +07:00
|
|
|
- Randomize the addresses (ASLR) for mmap base, stack, VDSO pages, and heap.
|
|
|
|
|
2024-08-19 08:32:20 +07:00
|
|
|
- Raise the minimum address a process can request for memory mapping to 64KB to
|
|
|
|
protect against kernel null pointer dereference vulnerabilities.
|
|
|
|
|
2024-09-26 20:10:36 +07:00
|
|
|
- Increase the maximum number of memory map areas a process is able to utilize to 1,048,576.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-08-28 17:49:50 +07:00
|
|
|
- Optional - Disallow registering interpreters for various (miscellaneous) binary formats based
|
2024-08-15 08:46:56 +07:00
|
|
|
on a magic number or their file extension to prevent unintended code execution.
|
2024-08-28 17:49:50 +07:00
|
|
|
See issue: https://github.com/Kicksecure/security-misc/issues/267
|
2024-07-25 07:11:33 +07:00
|
|
|
|
2024-08-21 09:51:51 +07:00
|
|
|
Core dumps:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Disable core dump files and prevent their creation. If core dump files are
|
|
|
|
enabled, they will be named based on `core.PID` instead of the default `core`.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-08-26 08:21:26 +07:00
|
|
|
Swap space:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Limit the copying of potentially sensitive content in memory to the swap device.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-08-21 09:51:51 +07:00
|
|
|
Networking:
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-08-26 09:40:04 +07:00
|
|
|
- Enable hardening of the BPF JIT compiler protect against JIT spraying.
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Enable TCP SYN cookie protection to assist against SYN flood attacks.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Protect against TCP time-wait assassination hazards.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Enable reverse path filtering (source validation) of packets received
|
|
|
|
from all interfaces to prevent IP spoofing.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-08-07 10:48:53 +07:00
|
|
|
- Disable ICMP redirect acceptance and redirect sending messages to prevent
|
|
|
|
man-in-the-middle attacks and minimize information disclosure.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-11-13 12:42:56 +07:00
|
|
|
- Optional - Deny sending and receiving shared media redirects to reduce
|
|
|
|
the risk of IP spoofing attacks.
|
|
|
|
|
2024-11-13 12:40:21 +07:00
|
|
|
- Optional - Enable ARP filtering to mitigate some ARP spoofing and ARP
|
|
|
|
cache poisoning attacks.
|
|
|
|
|
2024-11-13 12:41:25 +07:00
|
|
|
- Optional - Respond to ARP requests only if the target IP address is
|
|
|
|
on-link, preventing some IP spoofing attacks.
|
2024-11-13 12:42:56 +07:00
|
|
|
|
2024-11-13 12:38:03 +07:00
|
|
|
- Optional - Drop gratuitous ARP packets to prevent ARP cache poisoning
|
|
|
|
via man-in-the-middle and denial-of-service attacks.
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Ignore ICMP echo requests to prevent clock fingerprinting and Smurf attacks.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Ignore bogus ICMP error responses.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Disable source routing which allows users to redirect network traffic that
|
|
|
|
can result in man-in-the-middle attacks.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Do not accept IPv6 router advertisements and solicitations.
|
2024-07-13 19:41:40 +07:00
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Optional - Disable SACK and DSACK as they have historically been a known
|
|
|
|
vector for exploitation.
|
2024-07-14 14:05:49 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Disable TCP timestamps as they can allow detecting the system time.
|
2024-05-11 10:15:42 +07:00
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Optional - Log packets with impossible source or destination addresses to
|
|
|
|
enable further inspection and analysis.
|
2024-07-17 18:56:40 +07:00
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Optional - Enable IPv6 Privacy Extensions.
|
2024-05-11 10:15:42 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
### Boot parameters
|
2019-06-24 02:51:53 +07:00
|
|
|
|
2024-07-14 22:56:25 +07:00
|
|
|
Mitigations for known CPU vulnerabilities are enabled in their strictest form
|
2024-07-17 19:57:35 +07:00
|
|
|
and simultaneous multithreading (SMT) is disabled. See the
|
2024-07-14 22:56:25 +07:00
|
|
|
`/etc/default/grub.d/40_cpu_mitigations.cfg` configuration file.
|
2019-10-14 17:10:08 +07:00
|
|
|
|
2024-07-14 22:56:25 +07:00
|
|
|
Boot parameters relating to kernel hardening, DMA mitigations, and entropy
|
|
|
|
generation are outlined in the `/etc/default/grub.d/40_kernel_hardening.cfg`
|
|
|
|
configuration file.
|
|
|
|
|
2024-08-21 09:52:48 +07:00
|
|
|
Kernel space:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Disable merging of slabs with similar size, which reduces the risk of
|
|
|
|
triggering heap overflows and limits influencing slab cache layout.
|
2024-07-14 22:56:25 +07:00
|
|
|
|
2024-08-05 11:27:17 +07:00
|
|
|
- Enable sanity checks and red zoning via slab debugging. This will implicitly
|
|
|
|
disable kernel pointer hashing, leaking very sensitive information to root.
|
2024-08-03 11:49:48 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Enable memory zeroing at both allocation and free time, which mitigates some
|
|
|
|
use-after-free vulnerabilities by erasing sensitive information in memory.
|
2024-07-14 22:56:25 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Enable the kernel page allocator to randomize free lists to limit some data
|
|
|
|
exfiltration and ROP attacks, especially during the early boot process.
|
2024-07-14 22:56:25 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Enable kernel page table isolation to increase KASLR effectiveness and also
|
|
|
|
mitigate the Meltdown CPU vulnerability.
|
2019-06-24 02:51:53 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Enable randomization of the kernel stack offset on syscall entries to harden
|
|
|
|
against memory corruption attacks.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Disable vsyscalls as they are vulnerable to ROP attacks and have now been
|
|
|
|
replaced by vDSO.
|
2019-06-24 02:51:53 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Restrict access to debugfs by not registering the file system since it can
|
|
|
|
contain sensitive information.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Force kernel panics on "oopses" to potentially indicate and thwart certain
|
|
|
|
kernel exploitation attempts.
|
2019-06-24 02:51:53 +07:00
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Optional - Modify the machine check exception handler.
|
2019-06-24 02:51:53 +07:00
|
|
|
|
2024-08-16 10:12:07 +07:00
|
|
|
- Prevent sensitive kernel information leaks in the console during boot.
|
2024-08-09 10:39:25 +07:00
|
|
|
|
2024-08-05 12:07:56 +07:00
|
|
|
- Enable the kernel Electric-Fence sampling-based memory safety error detector
|
|
|
|
which can identify heap out-of-bounds access, use-after-free, and invalid-free errors.
|
2024-08-02 21:12:50 +07:00
|
|
|
|
2024-08-05 12:10:02 +07:00
|
|
|
- Disable 32-bit vDSO mappings as they are a legacy compatibility feature.
|
2024-08-02 21:13:38 +07:00
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Optional - Use kCFI as the default CFI implementation (when using Linux kernel >= 6.2)
|
|
|
|
since it may be slightly more resilient to attacks that are able to write
|
|
|
|
arbitrary executables in memory.
|
2024-07-22 14:26:00 +07:00
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Optional - Disable support for all x86 processes and syscalls (when using Linux kernel >= 6.7)
|
|
|
|
to reduce attack surface.
|
2020-01-30 13:22:06 +07:00
|
|
|
|
2024-08-21 09:52:48 +07:00
|
|
|
Direct memory access:
|
|
|
|
|
2024-08-16 09:41:36 +07:00
|
|
|
- Enable strict IOMMU translation to protect against some DMA attacks via the use
|
|
|
|
of both CPU manufacturer-specific drivers and kernel settings.
|
|
|
|
|
|
|
|
- Clear the busmaster bit on all PCI bridges during the EFI hand-off, which disables
|
|
|
|
DMA before the IOMMU is configured. May cause boot failure on certain hardware.
|
2019-07-15 20:03:30 +07:00
|
|
|
|
2024-08-21 09:52:48 +07:00
|
|
|
Entropy:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Do not credit the CPU or bootloader as entropy sources at boot in order to
|
|
|
|
maximize the absolute quantity of entropy in the combined pool.
|
2022-07-13 19:25:53 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Obtain more entropy at boot from RAM as the runtime memory allocator is
|
|
|
|
being initialized.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-08-21 09:52:48 +07:00
|
|
|
Networking:
|
|
|
|
|
2024-08-16 10:24:25 +07:00
|
|
|
- Optional - Disable the entire IPv6 stack to reduce attack surface.
|
2022-07-13 19:25:53 +07:00
|
|
|
|
2024-09-25 06:54:49 +07:00
|
|
|
### mmap ASLR
|
|
|
|
|
|
|
|
- The bits of entropy used for mmap ASLR for all CPU architectures are maxed
|
|
|
|
out via `/usr/libexec/security-misc/mmap-rnd-bits` (set to the values of
|
|
|
|
`CONFIG_ARCH_MMAP_RND_BITS_MAX` and `CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX`
|
|
|
|
that the kernel was built with), therefore improving its effectiveness.
|
2024-10-06 17:46:05 +07:00
|
|
|
|
2024-09-30 13:56:18 +07:00
|
|
|
### Kernel Self Protection Project (KSPP) compliance status
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
**Summary:**
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-10-14 10:01:15 +07:00
|
|
|
`security-misc` is in full compliance with KSPP recommendations wherever feasible. However,
|
|
|
|
there are a few cases of partial or non-compliance due to technical limitations.
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
* [KSPP Recommended Settings](https://kspp.github.io/Recommended_Settings)
|
2024-09-05 17:03:05 +07:00
|
|
|
|
|
|
|
**Full compliance:**
|
|
|
|
|
2024-10-14 10:01:15 +07:00
|
|
|
More than 30 kernel boot parameters and over 30 sysctl settings are fully aligned with
|
|
|
|
the KSPP's recommendations.
|
2024-09-05 17:03:05 +07:00
|
|
|
|
|
|
|
**Partial compliance:**
|
|
|
|
|
|
|
|
1. `sysctl kernel.yama.ptrace_scope=3`
|
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
Completely disables `ptrace()`. Can be enabled easily if needed.
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
* [security-misc pull request #242](https://github.com/Kicksecure/security-misc/pull/242)
|
2024-09-05 17:03:05 +07:00
|
|
|
|
|
|
|
2. `sysctl kernel.panic=-1`
|
|
|
|
|
2024-10-14 10:01:15 +07:00
|
|
|
Forces an immediate reboot on kernel panic. This can be enabled, but it may lead to unexpected
|
|
|
|
system crashes.
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
* [security-misc pull request #264](https://github.com/Kicksecure/security-misc/pull/264)
|
|
|
|
* [security-misc pull request #268](https://github.com/Kicksecure/security-misc/pull/268)
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-10-03 13:58:58 +07:00
|
|
|
**Non-compliance:**
|
|
|
|
|
2024-09-05 17:03:05 +07:00
|
|
|
3. `sysctl user.max_user_namespaces=0`
|
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
Disables user namespaces entirely. Not recommended due to the potential for widespread breakages.
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
* [security-misc pull request #263](https://github.com/Kicksecure/security-misc/pull/263)
|
2024-09-05 17:03:05 +07:00
|
|
|
|
|
|
|
4. `sysctl fs.binfmt_misc.status=0`
|
|
|
|
|
2024-10-14 10:01:15 +07:00
|
|
|
Disables the registration of interpreters for miscellaneous binary formats. Currently not
|
|
|
|
feasible due to compatibility issues with Firefox.
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2024-09-05 18:00:11 +07:00
|
|
|
* [security-misc pull request #249](https://github.com/Kicksecure/security-misc/pull/249)
|
|
|
|
* [security-misc issue #267](https://github.com/Kicksecure/security-misc/issues/267)
|
2024-09-05 17:03:05 +07:00
|
|
|
|
2023-11-04 01:53:40 +07:00
|
|
|
### Kernel Modules
|
2023-12-25 20:37:23 +07:00
|
|
|
|
2023-11-04 01:53:40 +07:00
|
|
|
#### Kernel Module Signature Verification
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
Not yet implemented due to issues:
|
2023-11-04 02:55:17 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- https://forums.whonix.org/t/enforce-kernel-module-software-signature-verification-module-signing-disallow-kernel-module-loading-by-default/7880/64
|
|
|
|
- https://github.com/dell/dkms/issues/359
|
2023-11-04 01:53:40 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- `/etc/default/grub.d/40_signed_modules.cfg`
|
2023-11-04 01:53:40 +07:00
|
|
|
|
2023-11-04 21:33:35 +07:00
|
|
|
#### Disables the loading of new modules to the kernel after the fact
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
Not yet implemented due to issues:
|
2023-11-06 08:54:43 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- https://github.com/Kicksecure/security-misc/pull/152
|
2023-11-06 08:54:43 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
A systemd service dynamically sets the kernel parameter `modules_disabled` to 1,
|
|
|
|
preventing new modules from being loaded. Since this isn't configured directly
|
|
|
|
within systemctl, it does not break the loading of legitimate and necessary
|
|
|
|
modules for the user, like drivers etc., given they are plugged in on startup.
|
2023-11-04 21:33:35 +07:00
|
|
|
|
2024-07-11 23:42:37 +07:00
|
|
|
#### Blacklist and disable kernel modules
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-13 20:32:01 +07:00
|
|
|
Conntrack: Deactivates Netfilter's connection tracking helper module which
|
|
|
|
increases kernel attack surface by enabling superfluous functionality such
|
|
|
|
as IRC parsing in the kernel. See `/etc/modprobe.d/30_security-misc_conntrack.conf`.
|
|
|
|
|
2024-07-12 13:22:10 +07:00
|
|
|
Certain kernel modules are blacklisted by default to reduce attack surface via
|
|
|
|
`/etc/modprobe.d/30_security-misc_blacklist.conf`. Blacklisting prevents kernel
|
|
|
|
modules from automatically starting.
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- CD-ROM/DVD: Blacklist modules required for CD-ROM/DVD devices.
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Miscellaneous: Blacklist an assortment of other modules to prevent them from
|
|
|
|
automatically loading.
|
2024-07-12 13:22:10 +07:00
|
|
|
|
|
|
|
Specific kernel modules are entirely disabled to reduce attack surface via
|
|
|
|
`/etc/modprobe.d/30_security-misc_disable.conf`. Disabling prohibits kernel
|
2024-07-17 21:43:16 +07:00
|
|
|
modules from starting. This approach should not be considered comprehensive;
|
|
|
|
rather, it is a form of badness enumeration. Any potential candidates for future
|
2024-07-13 20:30:55 +07:00
|
|
|
disabling should first be blacklisted for a suitable amount of time.
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-08-21 09:50:14 +07:00
|
|
|
Hardware modules:
|
2024-07-18 09:21:37 +07:00
|
|
|
|
2024-08-21 09:50:14 +07:00
|
|
|
- Optional - Bluetooth: Disabled to reduce attack surface.
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- FireWire (IEEE 1394): Disabled as they are often vulnerable to DMA attacks.
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- GPS: Disable GPS-related modules such as those required for Global Navigation
|
|
|
|
Satellite Systems (GNSS).
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-07-18 09:21:37 +07:00
|
|
|
- Optional - Intel Management Engine (ME): Provides some disabling of the interface
|
2024-08-07 11:01:49 +07:00
|
|
|
between the Intel ME and the OS. May lead to breakages in places such as firmware
|
|
|
|
updates, security, power management, display, and DRM. See discussion: https://github.com/Kicksecure/security-misc/issues/239
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-08-07 11:01:49 +07:00
|
|
|
- Intel Platform Monitoring Technology (PMT) Telemetry: Disable some functionality
|
2024-07-17 21:43:16 +07:00
|
|
|
of the Intel PMT components.
|
2024-07-17 20:07:31 +07:00
|
|
|
|
2024-08-21 09:50:14 +07:00
|
|
|
- Thunderbolt: Disabled as they are often vulnerable to DMA attacks.
|
|
|
|
|
|
|
|
File system modules:
|
|
|
|
|
|
|
|
- File Systems: Disable uncommon and legacy file systems.
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Network File Systems: Disable uncommon and legacy network file systems.
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-08-21 09:50:14 +07:00
|
|
|
Networking modules:
|
|
|
|
|
2024-07-18 09:21:37 +07:00
|
|
|
- Network Protocols: A wide array of uncommon and legacy network protocols and drivers
|
|
|
|
are disabled.
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-08-21 09:50:14 +07:00
|
|
|
Miscellaneous modules:
|
2024-07-12 13:22:10 +07:00
|
|
|
|
2024-08-21 09:50:14 +07:00
|
|
|
- Amateur Radios: Disabled to reduce attack surface.
|
|
|
|
|
|
|
|
- Optional - CPU MSRs: Disabled as can be abused to write to arbitrary memory.
|
|
|
|
|
|
|
|
- Floppy Disks: Disabled to reduce attack surface.
|
|
|
|
|
|
|
|
- Framebuffer (fbdev): Disabled as these drivers are well-known to be buggy, cause
|
|
|
|
kernel panics, and are generally only used by legacy devices.
|
|
|
|
|
|
|
|
- Replaced Modules: Disabled legacy drivers that have been entirely replaced and
|
|
|
|
superseded by newer drivers.
|
2023-11-06 02:41:01 +07:00
|
|
|
|
2024-07-18 09:21:37 +07:00
|
|
|
- Optional - USB Video Device Class: Disables the USB-based video streaming driver for
|
|
|
|
devices like some webcams and digital camcorders.
|
|
|
|
|
2024-08-21 09:50:14 +07:00
|
|
|
- Vivid: Disabled to reduce attack surface given previous vulnerabilities.
|
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
### Other
|
2019-12-23 15:57:36 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- A systemd service clears the System.map file on boot as these contain kernel
|
|
|
|
pointers. The file is completely overwritten with zeroes to ensure it cannot
|
|
|
|
be recovered. See:
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
`/etc/kernel/postinst.d/30_remove-system-map`
|
|
|
|
|
|
|
|
`/lib/systemd/system/remove-system-map.service`
|
|
|
|
|
2021-08-03 23:56:31 +07:00
|
|
|
`/usr/libexec/security-misc/remove-system.map`
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Coredumps are disabled as they may contain important information such as
|
|
|
|
encryption keys or passwords. See:
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
`/etc/security/limits.d/30_security-misc.conf`
|
|
|
|
|
|
|
|
`/etc/sysctl.d/30_security-misc.conf`
|
2019-12-23 15:57:36 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
`/lib/systemd/coredump.conf.d/30_security-misc.conf`
|
2020-01-12 03:17:06 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- An initramfs hook sets the sysctl values in `/etc/sysctl.conf` and
|
|
|
|
`/etc/sysctl.d` before init is executed so sysctl hardening is enabled as
|
|
|
|
early as possible. This is implemented for `initramfs-tools` only because
|
|
|
|
this is not needed for `dracut` as `dracut` does that by default, at
|
|
|
|
least on `systemd` enabled systems. Not researched for non-`systemd` systems
|
|
|
|
by the author of this part of the readme.
|
2020-01-15 22:08:57 +07:00
|
|
|
|
2023-11-06 02:41:01 +07:00
|
|
|
## Network hardening
|
2020-01-14 21:18:30 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
Not yet implemented due to issues:
|
2024-07-17 18:56:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- https://github.com/Kicksecure/security-misc/pull/145
|
2024-07-17 18:56:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- https://github.com/Kicksecure/security-misc/issues/184
|
2024-07-17 18:56:40 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Unlike version 4, IPv6 addresses can provide information not only about the
|
|
|
|
originating network but also the originating device. We prevent this from
|
|
|
|
happening by enabling the respective privacy extensions for IPv6.
|
2023-11-06 02:41:01 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- In addition, we deny the capability to track the originating device in the
|
|
|
|
network at all, by using randomized MAC addresses per connection by
|
|
|
|
default.
|
2023-11-04 21:33:35 +07:00
|
|
|
|
2023-11-06 02:54:05 +07:00
|
|
|
See:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- `/usr/lib/NetworkManager/conf.d/80_ipv6-privacy.conf`
|
|
|
|
- `/usr/lib/NetworkManager/conf.d/80_randomize-mac.conf`
|
|
|
|
- `/usr/lib/systemd/networkd.conf.d/80_ipv6-privacy-extensions.conf`
|
2023-11-06 02:54:05 +07:00
|
|
|
|
2023-12-25 21:10:31 +07:00
|
|
|
## Bluetooth Hardening
|
2023-11-06 02:54:05 +07:00
|
|
|
|
2023-12-25 21:10:31 +07:00
|
|
|
### Bluetooth Status: Enabled but Defaulted to Off
|
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **Default Behavior**: Although Bluetooth capability is 'enabled' in the kernel,
|
|
|
|
security-misc deviates from the usual behavior by starting with Bluetooth
|
|
|
|
turned off at system start. This setting remains until the user explicitly opts
|
|
|
|
to activate Bluetooth.
|
2023-12-25 21:10:31 +07:00
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **User Control**: Users have the freedom to easily switch Bluetooth on and off
|
|
|
|
in the usual way, exercising their own discretion. This can be done via the
|
|
|
|
Bluetooth toggle through the usual way, that is either through GUI settings
|
|
|
|
application or command line commands.
|
2023-12-25 21:10:31 +07:00
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **Enhanced Privacy Settings**: We enforce more private defaults for Bluetooth
|
|
|
|
connections. This includes the use of private addresses and strict timeout
|
|
|
|
settings for discoverability and visibility.
|
2023-12-25 21:10:31 +07:00
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **Security Considerations**: Despite these measures, it's important to note that
|
|
|
|
Bluetooth technology, by its nature, may still be prone to exploits due to its
|
|
|
|
history of security vulnerabilities. Thus, we recommend users to opt-out of
|
|
|
|
using Bluetooth when possible.
|
2023-12-25 21:10:31 +07:00
|
|
|
|
|
|
|
### Configuration Details
|
|
|
|
|
|
|
|
- See configuration: `/etc/bluetooth/30_security-misc.conf`
|
|
|
|
- For more information and discussion: [GitHub Pull Request](https://github.com/Kicksecure/security-misc/pull/145)
|
|
|
|
|
|
|
|
### Understanding Bluetooth Terms
|
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **Disabling Bluetooth**: This means the absence of the Bluetooth kernel module.
|
|
|
|
When disabled, Bluetooth is non-existent in the system - it cannot be seen, set,
|
|
|
|
configured, or interacted with in any way.
|
2023-12-25 21:10:31 +07:00
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **Turning Bluetooth On/Off**: This refers to a software toggle. Normally, on
|
|
|
|
Debian systems, Bluetooth is 'on' when the system boots up. It actively searches
|
|
|
|
for known devices to auto-connect and may be discoverable or visible under certain
|
|
|
|
conditions. Our default ensures that Bluetooth is off on startup. However, it
|
|
|
|
remains 'enabled' in the kernel, meaning the kernel can use the Bluetooth protocol
|
|
|
|
and has the necessary modules.
|
2023-12-25 21:10:31 +07:00
|
|
|
|
|
|
|
### Quick Toggle Guide
|
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **Turning Bluetooth On**: Simply click the Bluetooth button in the settings
|
|
|
|
application or on the tray, and switch the toggle. It's a straightforward action
|
|
|
|
that can be completed in less than a second.
|
2023-11-06 02:54:05 +07:00
|
|
|
|
2024-08-09 10:30:39 +07:00
|
|
|
- **Turning Bluetooth Off**: Follow the same procedure as turning it on but switch
|
|
|
|
the toggle to the off position.
|
2023-11-04 21:33:35 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Entropy collection improvements
|
2019-11-23 21:06:28 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- The `jitterentropy_rng` kernel module is loaded as early as possible during
|
|
|
|
boot to gather more entropy via the
|
|
|
|
`/usr/lib/modules-load.d/30_security-misc.conf` configuration file.
|
2019-11-23 21:06:28 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Distrusts the CPU for initial entropy at boot as it is not possible to
|
|
|
|
audit, may contain weaknesses or a backdoor. Similarly, do not credit the
|
|
|
|
bootloader seed for initial entropy. For references, see:
|
|
|
|
`/etc/default/grub.d/40_kernel_hardening.cfg`
|
2020-02-25 14:08:10 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Gathers more entropy during boot if using the linux-hardened kernel patch.
|
2019-12-06 21:30:05 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Restrictive mount options
|
2019-12-06 21:30:05 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
A systemd service is triggered on boot to remount all sensitive partitions and
|
|
|
|
directories with significantly more secure hardened mount options. Since this
|
|
|
|
would require manual tuning for a given specific system, we handle it by
|
|
|
|
creating a very solid configuration file for that very system on package
|
2024-07-17 21:43:16 +07:00
|
|
|
installation.
|
2023-11-04 21:33:35 +07:00
|
|
|
|
2021-01-12 15:24:11 +07:00
|
|
|
Not enabled by default yet. In development. Help welcome.
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- https://www.kicksecure.com/wiki/Dev/remount-secure
|
|
|
|
- https://github.com/Kicksecure/security-misc/issues/157
|
|
|
|
- https://forums.whonix.org/t/re-mount-home-and-other-with-noexec-and-nosuid-among-other-useful-mount-options-for-better-security/
|
2021-01-12 15:24:11 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Root access restrictions
|
2019-07-13 23:29:10 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- `su` is restricted to only users within the group `sudo` which prevents
|
|
|
|
users from using `su` to gain root access or to switch user accounts -
|
|
|
|
`/usr/share/pam-configs/wheel-security-misc` (which results in a change in
|
|
|
|
file `/etc/pam.d/common-auth`).
|
2019-07-31 22:15:30 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Add user `root` to group `sudo`. This is required due to the above
|
|
|
|
restriction so that logging in from a virtual console is still possible -
|
|
|
|
`debian/security-misc.postinst`
|
2019-07-31 22:15:30 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Abort login for users with locked passwords -
|
|
|
|
`/usr/libexec/security-misc/pam-abort-on-locked-password`.
|
2019-08-17 17:53:45 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- Logging into the root account from a virtual, serial, or other console is
|
|
|
|
prevented by shipping an existing and empty `/etc/securetty` file (deletion
|
|
|
|
of `/etc/securetty` has a different effect).
|
2019-08-15 22:08:48 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
This package does not yet automatically lock the root account password. It is
|
2024-07-17 21:43:16 +07:00
|
|
|
not clear if this would be sane in such a package, although it is recommended to
|
2023-12-25 20:37:23 +07:00
|
|
|
lock and expire the root account.
|
2019-08-15 22:08:48 +07:00
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
In new Kicksecure builds, the root account will be locked by package
|
2020-04-08 19:30:05 +07:00
|
|
|
dist-base-files.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-07-17 21:43:16 +07:00
|
|
|
- https://www.kicksecure.com/wiki/Root
|
|
|
|
- https://www.kicksecure.com/wiki/Dev/Permissions
|
|
|
|
- https://forums.whonix.org/t/restrict-root-access/7658
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2019-07-18 04:06:17 +07:00
|
|
|
However, a locked root password will break rescue and emergency shell.
|
2023-12-25 20:37:23 +07:00
|
|
|
Therefore, this package enables passwordless rescue and emergency shell. This is
|
2024-07-17 21:49:21 +07:00
|
|
|
the same solution that Debian will likely adopt for the Debian installer:
|
2023-12-25 20:37:23 +07:00
|
|
|
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=802211
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- `/etc/systemd/system/emergency.service.d/override.conf`
|
|
|
|
- `/etc/systemd/system/rescue.service.d/override.conf`
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2019-07-18 04:06:17 +07:00
|
|
|
Adverse security effects can be prevented by setting up BIOS password
|
2024-07-17 21:49:21 +07:00
|
|
|
protection, GRUB password protection, and/or full disk encryption.
|
2019-07-18 04:06:17 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Console lockdown
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
This uses pam_access to allow members of group `console` to use the console but
|
2021-01-12 09:17:13 +07:00
|
|
|
restrict everyone else (except members of group `console-unrestricted`) from
|
2024-07-17 21:49:21 +07:00
|
|
|
using the console with ancient, unpopular login methods such as `/bin/login` over
|
2023-12-25 20:37:23 +07:00
|
|
|
networks as this might be exploitable. (CVE-2001-0797)
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
This is not enabled by default in this package since this package does not know
|
2024-07-17 21:49:21 +07:00
|
|
|
which users should be added to group 'console' and thus, would break console access.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- `/usr/share/pam-configs/console-lockdown-security-misc`
|
|
|
|
- `/etc/security/access-security-misc.conf`
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
## Brute force attack protection
|
|
|
|
|
2021-08-11 02:11:01 +07:00
|
|
|
User accounts are locked after 50 failed login attempts using `pam_faillock`.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
Informational output during Linux PAM:
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- Show failed and remaining password attempts.
|
|
|
|
- Document unlock procedure if Linux user account got locked.
|
|
|
|
- Point out that there is no password feedback for `su`.
|
|
|
|
- Explain locked root account if locked.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- `/usr/share/pam-configs/tally2-security-misc`
|
|
|
|
- `/usr/libexec/security-misc/pam-info`
|
|
|
|
- `/usr/libexec/security-misc/pam-abort-on-locked-password`
|
2020-04-09 16:45:29 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Access rights restrictions
|
|
|
|
|
|
|
|
### Strong user account separation
|
|
|
|
|
2023-11-03 21:44:48 +07:00
|
|
|
#### Permission Lockdown
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
Read, write, and execute access for "others" are removed during package
|
|
|
|
installation, upgrade, or PAM `mkhomedir` for all users who have home folders in
|
2023-12-25 20:37:23 +07:00
|
|
|
`/home` by running, for example:
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
```
|
|
|
|
chmod o-rwx /home/user
|
|
|
|
```
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
This will be done only once per folder in `/home` so users who wish to relax
|
|
|
|
file permissions are free to do so. This is to protect files in a home folder
|
|
|
|
that were previously created with lax file permissions prior to the installation
|
|
|
|
of this package.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- `debian/security-misc.postinst`
|
|
|
|
- `/usr/libexec/security-misc/permission-lockdown`
|
|
|
|
- `/usr/share/pam-configs/mkhomedir-security-misc`
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2023-11-03 21:44:48 +07:00
|
|
|
#### umask
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
Default `umask` is set to `027` for files created by non-root users such as
|
2024-11-29 04:20:57 +07:00
|
|
|
user `user`.
|
2023-11-03 21:44:48 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
This is done using the PAM module `pam_mkhomedir.so umask=027`.
|
2023-11-03 21:44:48 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
This means files created by non-root users cannot be read by other non-root
|
2023-12-25 20:37:23 +07:00
|
|
|
users by default. While Permission Lockdown already protects the `/home` folder,
|
|
|
|
this protects other folders such as `/tmp`.
|
2023-11-03 21:44:48 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
`group` read permissions are not removed. This is unnecessary due to Debian's
|
|
|
|
use of User Private Groups (UPGs). See also:
|
|
|
|
https://wiki.debian.org/UserPrivateGroups
|
2023-11-03 21:44:48 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
Default `umask` is unchanged for root because then configuration files created
|
2023-12-25 20:37:23 +07:00
|
|
|
in `/etc` by the system administrator would be unreadable by "others" and break
|
2024-11-29 04:20:57 +07:00
|
|
|
applications. Examples include `/etc/firefox-esr` and `/etc/thunderbird`. The
|
|
|
|
`umask` is also set to 022 via `sudoers` configuration, so that files created
|
|
|
|
as root are world-readable even when using commands such as `sudo vi
|
|
|
|
/etc/file` or `sudo -i; touch /etc/file`.
|
|
|
|
|
|
|
|
`umask` is set to 022 rather than 027 when using `sudo`, so that commands such
|
|
|
|
as `sudo vi /etc/configfile` and `sudo -i; touch /etc/file`
|
2023-11-03 21:44:48 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- `/usr/share/pam-configs/umask-security-misc`
|
2023-11-03 21:44:48 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
### SUID / SGID removal and permission hardening
|
|
|
|
|
2023-11-04 21:33:35 +07:00
|
|
|
#### SUID / SGID removal
|
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
A systemd service removes SUID / SGID bits from non-essential binaries as these
|
|
|
|
are often used in privilege escalation attacks.
|
2023-11-04 21:33:35 +07:00
|
|
|
|
|
|
|
#### File permission hardening
|
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
Various file permissions are reset with more secure and hardened defaults. These
|
|
|
|
include but are not limited to:
|
2023-11-04 21:33:35 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- Limiting `/home` and `/root` to the root only.
|
|
|
|
- Limiting crontab to root as well as all the configuration files for cron.
|
|
|
|
- Limiting the configuration for cups and ssh.
|
|
|
|
- Protecting the information of sudoers from others.
|
|
|
|
- Protecting various system-relevant files and modules.
|
2023-11-06 02:41:01 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
##### permission-hardener
|
2023-12-25 21:04:10 +07:00
|
|
|
|
|
|
|
`permission-hardener` removes SUID / SGID bits from non-essential binaries as
|
2024-01-16 21:26:21 +07:00
|
|
|
these are often used in privilege escalation attacks. It is enabled by default
|
|
|
|
and applied at security-misc package installation and upgrade time.
|
2021-01-12 15:24:11 +07:00
|
|
|
|
2023-12-25 21:04:10 +07:00
|
|
|
There is also an optional systemd unit which does the same at boot time that
|
2024-01-02 19:34:29 +07:00
|
|
|
can be enabled by running `systemctl enable permission-hardener.service` as
|
2023-12-25 21:04:10 +07:00
|
|
|
root. The hardening at boot time is not the default because this slows down
|
2024-07-17 21:49:21 +07:00
|
|
|
the boot process too much.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
See:
|
|
|
|
|
2024-01-02 19:34:29 +07:00
|
|
|
* `/usr/bin/permission-hardener`
|
2023-12-25 21:04:10 +07:00
|
|
|
* `debian/security-misc.postinst`
|
2024-01-02 19:34:29 +07:00
|
|
|
* `/lib/systemd/system/permission-hardener.service`
|
|
|
|
* `/etc/permission-hardener.d`
|
2021-01-12 09:17:13 +07:00
|
|
|
* https://forums.whonix.org/t/disable-suid-binaries/7706
|
2022-05-20 04:25:58 +07:00
|
|
|
* https://www.kicksecure.com/wiki/SUID_Disabler_and_Permission_Hardener
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
### Access rights relaxations
|
|
|
|
|
2021-01-12 15:24:11 +07:00
|
|
|
This is not enabled yet because hidepid is not enabled by default.
|
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
Calls to `pkexec` are redirected to `lxqt-sudo` because `pkexec` is
|
|
|
|
incompatible with `hidepid=2`.
|
|
|
|
|
|
|
|
See:
|
|
|
|
|
|
|
|
* `/usr/bin/pkexec.security-misc`
|
|
|
|
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860040
|
|
|
|
* https://forums.whonix.org/t/cannot-use-pkexec/8129
|
2023-12-25 21:04:10 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Application-specific hardening
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- Enables "`apt-get --error-on=any`" which makes apt exit non-zero for
|
|
|
|
transient failures. - `/etc/apt/apt.conf.d/40error-on-any`.
|
|
|
|
- Enables APT seccomp-BPF sandboxing - `/etc/apt/apt.conf.d/40sandbox`.
|
|
|
|
- Deactivates previews in Dolphin.
|
|
|
|
- Deactivates previews in Nautilus -
|
|
|
|
`/usr/share/glib-2.0/schemas/30_security-misc.gschema.override`.
|
|
|
|
- Deactivates thumbnails in Thunar.
|
|
|
|
- Rationale: lower attack surface when using the file manager
|
|
|
|
- https://forums.whonix.org/t/disable-preview-in-file-manager-by-default/18904
|
|
|
|
- Thunderbird is hardened with the following options:
|
|
|
|
- Displays domain names in punycode to prevent IDN homograph attacks (a
|
|
|
|
form of phishing).
|
|
|
|
- Strips email client information from sent email headers.
|
|
|
|
- Strips user time information from sent email headers by replacing the
|
|
|
|
originating time zone with UTC and rounding the timestamp to the nearest
|
|
|
|
minute.
|
|
|
|
- Disables scripting when viewing PDF files.
|
|
|
|
- Disables implicit outgoing connections.
|
|
|
|
- Disables all and any kind of telemetry.
|
|
|
|
- Security and privacy enhancements for gnupg's config file
|
|
|
|
`/etc/skel/.gnupg/gpg.conf`. See also:
|
|
|
|
- https://raw.github.com/ioerror/torbirdy/master/gpg.conf
|
|
|
|
- https://github.com/ioerror/torbirdy/pull/11
|
|
|
|
|
|
|
|
### Project scope of application-specific hardening
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2023-12-04 22:58:16 +07:00
|
|
|
Added in December 2023.
|
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
Before sending pull requests to harden arbitrary applications, please note the
|
|
|
|
scope of security-misc is limited to default installed applications in
|
2024-07-17 21:49:21 +07:00
|
|
|
Kicksecure and Whonix. This includes:
|
2023-11-07 01:47:30 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- Thunderbird, VLC Media Player, KeePassXC
|
|
|
|
- Debian Specific System Components (APT, DPKG)
|
|
|
|
- System Services (NetworkManager IPv6 privacy options, MAC address
|
|
|
|
randomization)
|
|
|
|
- Actually used development utilities such as `git`.
|
2023-11-07 01:47:30 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
It will not be possible to review and merge "1500" settings profiles for
|
|
|
|
arbitrary applications outside of this context.
|
2023-11-07 01:47:30 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
The main objective of security-misc is to harden Kicksecure and its derivatives,
|
|
|
|
such as Whonix, by implementing robust security settings. It's designed to be
|
|
|
|
compatible with Debian, reflecting a commitment to clean implementation and
|
|
|
|
sound design principles. However, it's important to note that security-misc is a
|
|
|
|
component of Kicksecure, not a substitute for it. The intention isn't to
|
|
|
|
recreate Kicksecure within security-misc. Instead, specific security
|
2024-07-17 21:49:21 +07:00
|
|
|
enhancements, like recommending a curated list of security-focused
|
2023-12-25 20:37:23 +07:00
|
|
|
default packages (e.g., `libpam-tmpdir`), should be integrated directly into
|
2024-07-17 21:49:21 +07:00
|
|
|
those appropriate areas of Kicksecure (e.g. `kicksecure-meta-packages`).
|
2023-12-04 22:48:27 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
Discussion: https://github.com/Kicksecure/security-misc/issues/154
|
2019-09-15 21:07:50 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
### Development philosophy
|
2023-12-04 22:58:16 +07:00
|
|
|
|
|
|
|
Added in December 2023.
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
Maintainability is a key priority \[1\]. Before modifying settings in the
|
2023-12-25 20:37:23 +07:00
|
|
|
downstream security-misc, it's essential to first engage with upstream
|
|
|
|
developers to propose these changes as defaults. This step should only be
|
|
|
|
bypassed if there's a clear, prior indication from upstream that such changes
|
|
|
|
won't be accepted. Additionally, before implementing any workarounds, consulting
|
2024-07-17 21:49:21 +07:00
|
|
|
with upstream is necessary to avoid future unmaintainable complexity.
|
2023-12-04 22:58:16 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
If debugging features are disabled, pull requests won't be merged until there is
|
|
|
|
a corresponding pull request for the debug-misc package to re-enable these. This
|
2024-07-17 21:49:21 +07:00
|
|
|
is to avoid configuring the system into a corner where it can no longer be
|
2023-12-25 20:37:23 +07:00
|
|
|
debugged.
|
2023-12-04 22:58:16 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
\[1\] https://www.kicksecure.com/wiki/Dev/maintainability
|
2023-12-04 22:58:16 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Opt-in hardening
|
|
|
|
|
|
|
|
Some hardening is opt-in as it causes too much breakage to be enabled by
|
|
|
|
default.
|
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- An optional systemd service mounts `/proc` with `hidepid=2` at boot to
|
|
|
|
prevent users from seeing another user's processes. This is disabled by
|
|
|
|
default because it is incompatible with `pkexec`. It can be enabled by
|
|
|
|
executing `systemctl enable proc-hidepid.service` as root.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- A systemd service restricts `/proc/cpuinfo`, `/proc/bus`, `/proc/scsi`, and
|
|
|
|
`/sys` to the root user. This hides a lot of hardware identifiers from
|
|
|
|
unprivileged users and increases security as `/sys` exposes a lot of
|
|
|
|
information that shouldn't be accessible to unprivileged users. As this will
|
|
|
|
break many things, it is disabled by default and can optionally be enabled
|
|
|
|
by executing `systemctl enable hide-hardware-info.service` as root.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
## Miscellaneous
|
2021-08-18 02:23:49 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- Hardened malloc compatibility for haveged workaround
|
|
|
|
`/lib/systemd/system/haveged.service.d/30_security-misc.conf`
|
2021-08-18 02:23:49 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
- Set `dracut` `reproducible=yes` setting
|
2021-09-05 05:28:37 +07:00
|
|
|
|
2024-07-17 21:49:21 +07:00
|
|
|
## Legal
|
2023-12-04 23:38:49 +07:00
|
|
|
|
|
|
|
`/usr/lib/issue.d/20_security-misc.issue`
|
|
|
|
|
|
|
|
https://github.com/Kicksecure/security-misc/pull/167
|
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Related
|
2019-12-16 18:24:14 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
- Linux Kernel Runtime Guard (LKRG)
|
|
|
|
- tirdad - TCP ISN CPU Information Leak Protection.
|
|
|
|
- Kicksecure (TM) - a security-hardened Linux Distribution
|
|
|
|
- And more.
|
|
|
|
- https://www.kicksecure.com/wiki/Linux_Kernel_Runtime_Guard_LKRG
|
|
|
|
- https://github.com/Kicksecure/tirdad
|
|
|
|
- https://www.kicksecure.com
|
|
|
|
- https://github.com/Kicksecure
|
2019-12-16 18:24:14 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Discussion
|
2019-09-15 21:07:50 +07:00
|
|
|
|
2022-05-20 04:25:58 +07:00
|
|
|
Happening primarily in forums.
|
2021-01-12 09:17:13 +07:00
|
|
|
|
2019-09-15 21:07:50 +07:00
|
|
|
https://forums.whonix.org/t/kernel-hardening/7296
|
2021-01-12 09:17:13 +07:00
|
|
|
|
|
|
|
## How to install `security-misc`
|
2015-12-15 09:00:24 +07:00
|
|
|
|
2022-05-20 04:25:58 +07:00
|
|
|
See https://www.kicksecure.com/wiki/Security-misc#install
|
2015-12-15 09:00:24 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## How to Build deb Package from Source Code
|
2015-12-15 09:00:24 +07:00
|
|
|
|
2020-04-02 18:22:47 +07:00
|
|
|
Can be build using standard Debian package build tools such as:
|
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
dpkg-buildpackage -b
|
2020-04-02 18:22:47 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
See instructions. (Replace `generic-package` with the actual name of this
|
|
|
|
package `security-misc`.)
|
2020-04-16 01:05:37 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
- **A)**
|
|
|
|
[easy](https://www.kicksecure.com/wiki/Dev/Build_Documentation/generic-package/easy),
|
|
|
|
*OR*
|
|
|
|
- **B)** [including verifying software
|
|
|
|
signatures](https://www.kicksecure.com/wiki/Dev/Build_Documentation/generic-package)
|
2015-12-15 09:00:24 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Contact
|
2015-12-15 09:00:24 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
- [Free Forum Support](https://forums.kicksecure.com)
|
|
|
|
- [Professional Support](https://www.kicksecure.com/wiki/Professional_Support)
|
2015-12-15 09:00:24 +07:00
|
|
|
|
2021-01-12 09:17:13 +07:00
|
|
|
## Donate
|
2015-12-15 09:00:24 +07:00
|
|
|
|
2023-12-25 20:37:23 +07:00
|
|
|
`security-misc` requires [donations](https://www.kicksecure.com/wiki/Donate) to
|
|
|
|
stay alive!
|