Addresses C-01, C-03, C-04, M-03, M-06, L-01, L-05, L-07. Changes: - luks-kdf-configure.sh: Auto-attempt Argon2id conversion during installation instead of just creating a manual helper (C-01) - run.sh: Replace --privileged with fine-grained capabilities (SYS_ADMIN, MKNOD, NET_ADMIN, SYS_CHROOT, SETFCAP) (C-03) - run.sh: Restrict SB key directory to mode 700 and key files to mode 600 (C-04) - security-hardening.sh: Add PAM enforcement via common-password with enforce_for_root (M-03) - security-hardening.sh: Initialize AIDE database and create daily cron job for integrity checks (M-06) - sudo-hardening.sh: Use atomic install -m 600 instead of touch+chmod to avoid race condition (L-07) - preseed.cfg: Disable direct root login (L-01) - run.sh: Comment explaining KNEL_BUILD_MODE cannot be env-spoofed since it's set from command argument (L-05) All tests pass. Zero shellcheck warnings. STATUS.md updated with 22/28 findings resolved. 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush <crush@charm.land>
60 lines
1.9 KiB
Bash
Executable File
60 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Sudo hardening - PRD FR-007 Access Control Layer
|
|
# Reference: CIS Benchmark 5.4, NIST SP 800-53 AC-6
|
|
set -euo pipefail
|
|
|
|
echo "Configuring sudo access controls..."
|
|
|
|
# Create sudoers configuration for restricted access
|
|
mkdir -p /etc/sudoers.d
|
|
chmod 750 /etc/sudoers.d
|
|
|
|
# Default sudoers hardening
|
|
cat >/etc/sudoers.d/99-knel-hardening <<'EOF'
|
|
# KNEL-Football Sudo Configuration
|
|
# Reference: PRD FR-007, CIS Benchmark 5.4, NIST SP 800-53 AC-6
|
|
|
|
# Lecture user on first sudo use
|
|
Defaults lecture = always
|
|
Defaults lecture_file = /etc/sudo.lecture
|
|
|
|
# Logging and timeout
|
|
Defaults logfile = "/var/log/sudo.log"
|
|
Defaults log_input
|
|
Defaults log_output
|
|
Defaults timestamp_timeout = 15
|
|
|
|
# Restrict which environment variables are preserved
|
|
Defaults env_reset
|
|
Defaults env_delete += "HOME"
|
|
Defaults secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
# football user can run specific admin commands
|
|
football ALL=(root) /usr/local/bin/apply-vpn-config.sh, /usr/local/bin/convert-luks-kdf.sh, /usr/bin/systemctl restart nftables, /usr/bin/systemctl restart wg-quick@wg0, /usr/local/bin/check-encryption.sh
|
|
|
|
# Root can run anything (standard)
|
|
root ALL=(ALL:ALL) ALL
|
|
EOF
|
|
|
|
chmod 440 /etc/sudoers.d/99-knel-hardening
|
|
|
|
# Create sudo lecture file
|
|
cat >/etc/sudo.lecture <<'EOF'
|
|
====================================================================
|
|
KNEL-Football Secure OS - Privileged Access Warning
|
|
====================================================================
|
|
|
|
You are about to execute a command with elevated privileges.
|
|
|
|
All sudo commands are logged and audited.
|
|
Unauthorized use of privileged access is a security violation.
|
|
|
|
If you did not intend to run a privileged command, press Ctrl+C now.
|
|
====================================================================
|
|
EOF
|
|
|
|
# Ensure sudo.log exists with correct permissions (atomic create)
|
|
install -m 600 /dev/null /var/log/sudo.log 2>/dev/null || true
|
|
|
|
echo "Sudo hardening completed."
|