V8.00.000.2025.06.17

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-07-17 16:36:50 +02:00
parent bb4b256e72
commit f7b142704d
4 changed files with 53 additions and 42 deletions

View File

@@ -10,8 +10,8 @@
# SPDX-PackageName: CISS.debian.installer
# SPDX-Security-Contact: security@coresecret.eu
### Options in "VAR_GRUB_CMDLINE_LINUX" are always effective.
### Options in "VAR_GRUB_CMDLINE_LINUX_DEFAULT" are effective ONLY during normal boot (NOT during recovery mode).
### Options in "GRUB_CMDLINE_LINUX" are always effective.
### Options in "GRUB_CMDLINE_LINUX_DEFAULT" are effective ONLY during normal boot (NOT during recovery mode).
guard_sourcing
@@ -28,13 +28,13 @@ guard_sourcing
#######################################
grub_extract_current_string() {
# shellcheck disable=SC2155
declare -gx VAR_ORIG_GRUB_CMDLINE_LINUX=$(grep -E 'VAR_GRUB_CMDLINE_LINUX=' "${TARGET}/etc/default/grub")
declare -gx VAR_ORIG_GRUB_CMDLINE_LINUX=$(grep -E 'GRUB_CMDLINE_LINUX=' "${TARGET}/etc/default/grub")
# shellcheck disable=SC2155
declare -gx VAR_ORIG_GRUB_CMDLINE_LINUX_DEFAULT=$(grep -E 'VAR_GRUB_CMDLINE_LINUX_DEFAULT=' "${TARGET}/etc/default/grub")
declare -gx VAR_ORIG_GRUB_CMDLINE_LINUX_DEFAULT=$(grep -E 'GRUB_CMDLINE_LINUX_DEFAULT=' "${TARGET}/etc/default/grub")
# shellcheck disable=SC2155
declare -gx VAR_GRUB_CMDLINE_LINUX=$(grep -E 'VAR_GRUB_CMDLINE_LINUX=' "${TARGET}/etc/default/grub" | sed 's/.$//')
declare -gx VAR_GRUB_CMDLINE_LINUX=$(grep -E 'GRUB_CMDLINE_LINUX=' "${TARGET}/etc/default/grub" | sed 's/.$//')
# shellcheck disable=SC2155
declare -gx VAR_GRUB_CMDLINE_LINUX_DEFAULT=$(grep -E 'VAR_GRUB_CMDLINE_LINUX_DEFAULT=' "${TARGET}/etc/default/grub" | sed 's/.$//')
declare -gx VAR_GRUB_CMDLINE_LINUX_DEFAULT=$(grep -E 'GRUB_CMDLINE_LINUX_DEFAULT=' "${TARGET}/etc/default/grub" | sed 's/.$//')
}
#######################################

View File

@@ -147,6 +147,7 @@ partition_encryption() {
var_uuid=$(blkid -s UUID -o value "/dev/mapper/${var_encryption_label}")
# shellcheck disable=SC2155
[[ "${var_mount_path}" == "/" ]] && declare -grx VAR_CRYPT_ROOT="${var_uuid}"
[[ "${var_mount_path}" == "/recovery" ]] && declare -grx VAR_CRYPT_RECOVERY="${var_uuid}"
HMP_PATH_LUKSUUID["UUID_${var_mount_path}"]="${var_uuid}"
HMP_PATH_ENCLABEL["LABEL_${var_mount_path}"]="${var_encryption_label}"

View File

@@ -10,6 +10,9 @@
# SPDX-PackageName: CISS.debian.installer
# SPDX-Security-Contact: security@coresecret.eu
### Options in "GRUB_CMDLINE_LINUX" are always effective.
### Options in "GRUB_CMDLINE_LINUX_DEFAULT" are effective ONLY during normal boot (NOT during recovery mode).
guard_sourcing
#######################################
@@ -46,7 +49,7 @@ EOF
# the backlog will hold 64 records. If more than 64 records are created during boot, #
# auditd records will be lost and potential malicious activity could go undetected #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} audit=1 audit_backlog_limit=8192"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} audit=1 audit_backlog_limit=8192"
###########################################################################################
# Distrusts CPU bootloader for initial entropy at boot. #
@@ -59,13 +62,13 @@ EOF
# https://forums.whonix.org/t/entropy-config-random-trust-cpu-yes-or-no-rng-core-default-quality/8566
# https://lkml.org/lkml/2022/6/5/271 #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} random.trust_cpu=off"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} random.trust_cpu=off"
###########################################################################################
# Distrusts the bootloader for initial entropy at boot. #
# https://lkml.org/lkml/2022/6/5/271 #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} random.trust_bootloader=off"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} random.trust_bootloader=off"
###########################################################################################
# ASLR (Address Space Layout Randomization) causes central areas of memory to be assigned #
@@ -78,7 +81,7 @@ EOF
# 1: Partial ASLR Heap, mmap are randomized, stack only partially randomized. #
# 2: Full ASLR (default) Stack, mmap, heap, VDSO, shared libraries all randomized. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} randomize_va_space=2"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} randomize_va_space=2"
###########################################################################################
# Enables IOMMU to prevent DMA attacks. #
@@ -88,7 +91,7 @@ EOF
# to disable it. It activates the basic DMA remapping function. However, it does not say #
# anything about how restrictive the mapping strategy is, passthrough, strict, see below #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} iommu=force"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} iommu=force"
###########################################################################################
# Enables strict enforcement of IOMMU TLB invalidation, so devices will never be able to #
@@ -108,7 +111,7 @@ EOF
# https://github.com/torvalds/linux/blob/master/drivers/iommu/Kconfig#L97 #
# Page 11 of https://lenovopress.lenovo.com/lp1467.pdf #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} iommu.passthrough=0 iommu.strict=1"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} iommu.passthrough=0 iommu.strict=1"
###########################################################################################
# Disable the busmaster bit on all PCI bridges during very early boot to avoid holes in #
@@ -116,24 +119,24 @@ EOF
# https://mjg59.dreamwidth.org/54433.html #
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4444f8541dad16fefd9b8807ad1451e806ef1d94
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} efi=disable_early_pci_dma"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} efi=disable_early_pci_dma"
###########################################################################################
# Disables the merging of slabs of similar sizes. #
# Sometimes a slab can be used vulnerably, which an attacker can exploit. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} slab_nomerge"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} slab_nomerge"
###########################################################################################
# Zero memory at allocation and free time. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} init_on_alloc=1 init_on_free=1"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} init_on_alloc=1 init_on_free=1"
###########################################################################################
# This option randomizes page allocator freelists, improving security by making page #
# allocations less predictable. This also improves performance. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} page_alloc.shuffle=1"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} page_alloc.shuffle=1"
###########################################################################################
# When releasing (i.e., free_pages()), all bytes with a marker value (e.g., 0xAA) are #
@@ -141,17 +144,17 @@ EOF
# most likely crash or produce recognizable artifacts. Only supported if the kernel was #
# built with CONFIG_PAGE_POISONING=y (default on Debian: enabled since Bookworm). #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} page_poison=1"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} page_poison=1"
###########################################################################################
# Enables Kernel Page Table Isolation, which mitigates Meltdown, improves KASLR. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} pti=on"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} pti=on"
###########################################################################################
# The setting 'vsyscall' is obsolete, are at fixed addresses and are a target for ROP. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} vsyscall=none"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} vsyscall=none"
###########################################################################################
# The kernel adds a small random padding offset to the stack pointer with every system #
@@ -159,14 +162,14 @@ EOF
# within the stack with every call. This makes ROP chains (return-oriented programming) #
# or stack pivoting attacks significantly more difficult. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} randomize_kstack_offset=on"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} randomize_kstack_offset=on"
###########################################################################################
# Prevents the debugfsfile system from being made available at boot time. This is a #
# useful hardening measure because debugfs reveals a lot of potentially security-relevant #
# kernel information by default, which can be misused by normal users (and by exploits). #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} debugfs=off"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} debugfs=off"
###########################################################################################
# Force the kernel to panic on "oopses" (which may be due to false positives). #
@@ -174,7 +177,7 @@ EOF
# panic=0 No automatic action (System remains stuck in panic state). #
# panic=-1 Also explicitly prevents any automatic reboot. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} oops=panic panic=-1"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} oops=panic panic=-1"
###########################################################################################
# Enable a subset of known mitigations for CPU vulnerabilities and disable SMT. #
@@ -189,7 +192,7 @@ EOF
# Future-proof: Even new kernel features (e.g., bhi=flush or srbds) are automatically #
# activated without having to know about them. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} mitigations=auto,nosmt"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} mitigations=auto,nosmt"
###########################################################################################
# If mitigations=auto,nosmt is set, see before, then these flags should not be set #
@@ -197,7 +200,7 @@ EOF
# (indirect branch speculation) and Intel branch history injection (BHI) vulnerabilities. #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/spectre.html #
###########################################################################################
# VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} spectre_v2=on spectre_v2_user=on spectre_bhi=on"
# VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} spectre_v2=on spectre_v2_user=on spectre_bhi=on"
###########################################################################################
# If mitigations=auto,nosmt is set, see before, then these flags should not be set #
@@ -205,7 +208,7 @@ EOF
# Disable Speculative Store Bypass (Spectre Variant 4). #
# https://www.suse.com/support/kb/doc/?id=000019189 #
###########################################################################################
# VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} spec_store_bypass_disable=on nospec_store_bypass_disable=off"
# VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} spec_store_bypass_disable=on nospec_store_bypass_disable=off"
###########################################################################################
# If mitigations=auto,nosmt is set, see before, then these flags should not be set #
@@ -214,7 +217,7 @@ EOF
# runtime control. #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1tf.html #
###########################################################################################
# VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} l1tf=full,force"
# VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} l1tf=full,force"
###########################################################################################
# If mitigations=auto,nosmt is set, see before, then these flags should not be set #
@@ -223,7 +226,7 @@ EOF
# and disabling SMT. #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html #
###########################################################################################
# VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} mds=full,nosmt"
# VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} mds=full,nosmt"
###########################################################################################
# If mitigations=auto,nosmt is set, see before, then these flags should not be set #
@@ -232,26 +235,26 @@ EOF
# Abort along with disabling SMT. #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html #
###########################################################################################
# VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} tsx=off tsx_async_abort=full,nosmt"
# VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} tsx=off tsx_async_abort=full,nosmt"
###########################################################################################
# Mark all huge pages in the EPT as non-executable to mitigate iTLB multihit. #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/multihit.html #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} kvm.nx_huge_pages=force"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} kvm.nx_huge_pages=force"
###########################################################################################
# Force disable SMT as it has caused numerous CPU vulnerabilities. #
# The only full mitigation of cross-HT attacks is to disable SMT. #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/core-scheduling.html #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} nosmt=force"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} nosmt=force"
###########################################################################################
# Enables the prctl interface to prevent leaks from L1D on context switches. #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1d_flush.html #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} l1d_flush=on"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} l1d_flush=on"
###########################################################################################
# Mitigates numerous MMIO Stale Data vulnerabilities and disables SMT. #
@@ -263,7 +266,7 @@ EOF
# affected #
# https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/processor_mmio_stale_data.html
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} mmio_stale_data=full,force"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} mmio_stale_data=full,force"
###########################################################################################
# Enable mitigations for RETBleed (Arbitrary Speculative Code Execution with #
@@ -275,7 +278,7 @@ EOF
# set 'retbleed=auto,nosmt' otherwise, 'mitigations=auto,nosmt' is sufficient. #
# https://www.suse.com/support/kb/doc/?id=000020693 #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} retbleed=auto"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} retbleed=auto"
###########################################################################################
# Enables kernel lockdown mode with a focus on confidentiality. The kernel is #
@@ -288,7 +291,7 @@ EOF
# https://blog.cloudflare.com/de-de/linux-kernel-hardening/ #
# https://www.linux-magazine.com/Issues/2020/239/Lockdown-Mode #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} lockdown=confidentiality"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} lockdown=confidentiality"
###########################################################################################
# Enables 'Read-Only Data Protection', which implements read-only memory areas #
@@ -296,7 +299,7 @@ EOF
# (e.g., buffer overflows). 'on': Forces the corresponding areas to remain read-only. #
# https://www.kernel.org/doc/html/v6.10/admin-guide/kernel-parameters.html #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} rodata=on"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} rodata=on"
###########################################################################################
# Kernel Electric-Fence (KFENCE) is a low-overhead sampling-based memory safety #
@@ -309,7 +312,7 @@ EOF
# deployed across a large fleet of machines. #
# https://docs.kernel.org/dev-tools/kfence.html #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} kfence.sample_interval=100"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} kfence.sample_interval=100"
###########################################################################################
# CFI Ensures that only controlled, predefined transitions are possible in the #
@@ -319,14 +322,14 @@ EOF
# checks and instrumentation into the kernel code. #
# https://kspp.github.io/Recommended_Settings#kernel-command-line-options #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} cfi=kcfi"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} cfi=kcfi"
###########################################################################################
# Remove additional (32-bit) attack surface, unless you really need them. #
# https://www.kernel.org/doc/html/v6.10/admin-guide/kernel-parameters.html #
# https://kspp.github.io/Recommended_Settings#kernel-command-line-options #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} ia32_emulation=0"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} ia32_emulation=0"
###########################################################################################
# Removes mapping for 32-bit VDSO (for ia32binaries). On 32-bit processes that rely on #
@@ -334,7 +337,7 @@ EOF
# without CONFIG_IA32_EMULATION or with ia32_emulation=0, vdso32=0 is effective but #
# redundant. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} vdso32=0"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} vdso32=0"
###########################################################################################
# Checks every copy_to_user() / copy_from_user()operation. Prevents kernels from #
@@ -343,18 +346,18 @@ EOF
# heap/SLOB abuse, overwrites. Leads to BUG() & stack trace if suspicious access is #
# detected. #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} hardened_usercopy=1"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} hardened_usercopy=1"
###########################################################################################
# Sets the minimum log output of the kernel at boot time to level 0 (= KERN_EMERG). #
###########################################################################################
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} loglevel=0"
VAR_GRUB_CMDLINE_LINUX_DEFAULT="${VAR_GRUB_CMDLINE_LINUX_DEFAULT} loglevel=0"
grub_finalize_string
do_in_target "${TARGET}" update-grub
do_log "info" "true" "Setting GRUB kernel parameters: ${VAR_GRUB_CMDLINE_LINUX}"
do_log "info" "true" "Setting GRUB kernel parameters: ${VAR_GRUB_CMDLINE_LINUX_DEFAULT}"
return 0
}

View File

@@ -73,6 +73,13 @@ setup_dropbear() {
write_dropbear_conf
### Options in "GRUB_CMDLINE_LINUX" are always effective.
### Options in "GRUB_CMDLINE_LINUX_DEFAULT" are effective ONLY during normal boot (NOT during recovery mode).
grub_extract_current_string
declare var_label="${HMP_PATH_ENCLABEL["LABEL_/"]}"
VAR_GRUB_CMDLINE_LINUX="${VAR_GRUB_CMDLINE_LINUX} cryptdevice=${VAR_CRYPT_ROOT}:cryptroot root=/dev/mapper/${var_label}"
grub_finalize_string
return 0
}