• Stars
    star
    473
  • Rank 89,537 (Top 2 %)
  • Language
    Shell
  • License
    Other
  • Created over 8 years ago
  • Updated 27 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kernel Hardening; Protect Linux User Accounts against Brute Force Attacks; Improve Entropy Collection; Strong Linux User Account Separation; Enhances Misc Security Settings - https://www.kicksecure.com/wiki/Security-misc

Enhances miscellaneous security settings

Kernel hardening

This section is inspired by the Kernel Self Protection Project (KSPP). It implements all recommended Linux kernel settings by the KSPP and many more.

sysctl

sysctl settings are configured via the /etc/sysctl.d/30_security-misc.conf configuration file.

  • A kernel pointer points to a specific location in kernel memory. These can be very useful in exploiting the kernel so they are restricted to CAP_SYSLOG.

  • The kernel logs are restricted to CAP_SYSLOG as they can often leak sensitive information such as kernel pointers.

  • The ptrace() system call is restricted to CAP_SYS_PTRACE.

  • eBPF is restricted to CAP_BPF (CAP_SYS_ADMIN on kernel versions prior to 5.8) and JIT hardening techniques such as constant blinding are enabled.

  • Restricts performance events to CAP_PERFMON (CAP_SYS_ADMIN on kernel versions prior to 5.8).

  • Restricts loading line disciplines to CAP_SYS_MODULE to prevent unprivileged attackers from loading vulnerable line disciplines with the TIOCSETD ioctl which has been abused in a number of exploits before.

  • Restricts the userfaultfd() syscall to CAP_SYS_PTRACE as userfaultfd() is often abused to exploit use-after-free flaws.

  • Kexec is disabled as it can be used to load a malicious kernel and gain arbitrary code execution in kernel mode.

  • Randomises the addresses for mmap base, heap, stack, and VDSO pages.

  • Prevents unintentional writes to attacker-controlled files.

  • Prevents common symlink and hardlink TOCTOU races.

  • Restricts the SysRq key so it can only be used for shutdowns and the Secure Attention Key.

  • The kernel is only allowed to swap if it is absolutely necessary. This prevents writing potentially sensitive contents of memory to disk.

  • TCP timestamps are disabled as it can allow detecting the system time.

mmap ASLR

  • The bits of entropy used for mmap ASLR 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.

Boot parameters

Boot parameters are outlined in configuration files located in the etc/default/grub.d/ directory.

  • Slab merging is disabled which significantly increases the difficulty of heap exploitation by preventing overwriting objects from merged caches and by making it harder to influence slab cache layout.

  • Memory zeroing at allocation and free time is enabled to mitigate some use-after-free vulnerabilities and erase sensitive information in memory.

  • Page allocator freelist randomization is enabled.

  • Kernel Page Table Isolation is enabled to mitigate Meltdown and increase KASLR effectiveness.

  • vsyscalls are disabled as they are obsolete, are at fixed addresses and thus, are a potential target for ROP.

  • The kernel panics on oopses to thwart certain kernel exploits.

  • Enables randomisation of the kernel stack offset on syscall entries.

  • All mitigations for known CPU vulnerabilities are enabled and SMT is disabled.

  • IOMMU is enabled to prevent DMA attacks along with strict enforcement of IOMMU TLB invalidation so devices will never be able to access stale data contents.

  • Distrust the 'randomly' generated CPU and bootloader seeds.

Disables and blacklists kernel modules

Certain kernel modules are disabled and blacklisted by default to reduce attack surface via the /etc/modprobe.d/30_security-misc.conf configuration file.

  • Deactivates Netfilter's connection tracking helper - this module increases kernel attack surface by enabling superfluous functionality such as IRC parsing in the kernel. Hence, this feature is disabled.

  • Bluetooth is disabled to reduce attack surface. Bluetooth has a lengthy history of security concerns.

  • Thunderbolt and numerous FireWire kernel modules are also disabled as they are often vulnerable to DMA attacks.

  • The MSR kernel module is disabled to prevent CPU MSRs from being abused to write to arbitrary memory.

  • Uncommon network protocols are blacklisted. This includes:

DCCP - Datagram Congestion Control Protocol

SCTP - Stream Control Transmission Protocol

RDS - Reliable Datagram Sockets

TIPC - Transparent Inter-process Communication

HDLC - High-Level Data Link Control

AX25 - Amateur X.25

NetRom

X25

ROSE

DECnet

Econet

af_802154 - IEEE 802.15.4

IPX - Internetwork Packet Exchange

AppleTalk

PSNAP - Subnetwork Access Protocol

p8023 - Novell raw IEEE 802.3

p8022 - IEEE 802.2

CAN - Controller Area Network

ATM

  • Disables a large array of uncommon file systems and network file systems that reduces the attack surface especially against legacy approaches.

  • The vivid kernel module is only required for testing and has been the cause of multiple vulnerabilities so it is disabled.

  • Provides some disabling of the interface between the Intel Management Engine (ME) and the OS.

  • Incorporates much of Ubuntu's default blacklist of modules to be blocked from automatically loading. However, they are still permitted to load.

  • Blocks automatic loading of the modules needed to use of CD-ROM devices by default. Not completely disabled yet.

Other

  • 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:

/etc/kernel/postinst.d/30_remove-system-map

/lib/systemd/system/remove-system-map.service

/usr/libexec/security-misc/remove-system.map

  • Coredumps are disabled as they may contain important information such as encryption keys or passwords. See:

/etc/security/limits.d/30_security-misc.conf

/etc/sysctl.d/30_security-misc.conf

/lib/systemd/coredump.conf.d/30_security-misc.conf

  • 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 because 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.

Network hardening

  • TCP syncookies are enabled to prevent SYN flood attacks.

  • ICMP redirect acceptance, ICMP redirect sending, source routing and IPv6 router advertisements are disabled to prevent man-in-the-middle attacks.

  • The kernel is configured to 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.

  • RFC1337 is enabled to protect against time-wait assassination attacks by dropping RST packets for sockets in the time-wait state.

  • Reverse path filtering is enabled to prevent IP spoofing and mitigate vulnerabilities such as CVE-2019-14899.

Entropy collection improvements

  • 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.

  • Distrusts the CPU for initial entropy at boot as it is not possible to audit, may contain weaknesses or a backdoor. For references, see: /etc/default/grub.d/40_distrust_cpu.cfg

  • Gathers more entropy during boot if using the linux-hardened kernel patch.

Restrictive mount options

Not enabled by default yet. In development. Help welcome.

https://forums.whonix.org/t/re-mount-home-and-other-with-noexec-and-nosuid-among-other-useful-mount-options-for-better-security/

/home, /tmp, /dev/shm and /run are remounted with the nosuid and nodev mount options to prevent execution of setuid or setgid binaries and creation of devices on those filesystems.

Optionally, they can also be mounted with noexec to prevent execution of any binary. To opt-in to applying noexec, execute touch /etc/noexec as root and reboot.

To disable this, execute touch /etc/remount-disable as root.

Alternatively, file /usr/local/etc/remount-disable or /usr/local/etc/noexec could be used.

Root access restrictions

  • 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).

  • 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

  • Abort login for users with locked passwords - /usr/libexec/security-misc/pam-abort-on-locked-password.

  • Logging into the root account from a virtual, serial, whatnot console is prevented by shipping an existing and empty /etc/securetty file (deletion of /etc/securetty has a different effect).

This package does not yet automatically lock the root account password. It is not clear if this would be sane in such a package although, it is recommended to lock and expire the root account.

In new Kicksecure builds, root account will be locked by package dist-base-files.

See:

However, a locked root password will break rescue and emergency shell. Therefore, this package enables passwordless rescue and emergency shell. This is the same solution that Debian will likely adapt for Debian installer: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=802211

See:

  • /etc/systemd/system/emergency.service.d/override.conf
  • /etc/systemd/system/rescue.service.d/override.conf

Adverse security effects can be prevented by setting up BIOS password protection, GRUB password protection and/or full disk encryption.

Console lockdown

This uses pam_access to allow members of group console to use console but restrict everyone else (except members of group console-unrestricted) from using console with ancient, unpopular login methods such as /bin/login over networks as this might be exploitable. (CVE-2001-0797)

This is not enabled by default in this package since this package does not know which users shall be added to group 'console' and thus, would break console.

See:

  • /usr/share/pam-configs/console-lockdown-security-misc
  • /etc/security/access-security-misc.conf

Brute force attack protection

User accounts are locked after 50 failed login attempts using pam_faillock.

Informational output during Linux PAM:

  • 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.

See:

  • /usr/share/pam-configs/tally2-security-misc
  • /usr/libexec/security-misc/pam-info
  • /usr/libexec/security-misc/pam-abort-on-locked-password

Access rights restrictions

Strong user account separation

Read, write and execute access for "others" are removed during package installation, upgrade or PAM mkhomedir for all users who have home folders in /home by running, for example:

chmod o-rwx /home/user

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.

See:

  • debian/security-misc.postinst
  • /usr/libexec/security-misc/permission-lockdown
  • /usr/share/pam-configs/mkhomedir-security-misc

SUID / SGID removal and permission hardening

Not enabled by default yet.

A systemd service removes SUID / SGID bits from non-essential binaries as these are often used in privilege escalation attacks. It is disabled by default for now during testing and can optionally be enabled by running systemctl enable permission-hardening.service as root.

See:

Access rights relaxations

This is not enabled yet because hidepid is not enabled by default.

Calls to pkexec are redirected to lxqt-sudo because pkexec is incompatible with hidepid=2.

See:

Application-specific hardening

  • 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.
  • Displays domain names in punycode (network.IDN_show_punycode) in Thunderbird to prevent IDN homograph attacks (a form of phishing).
  • 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

ioerror/torbirdy#11

Opt-in hardening

Some hardening is opt-in as it causes too much breakage to be enabled by default.

  • 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.

  • 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.

miscellaneous

  • hardened malloc compatibility for haveged workaround /lib/systemd/system/haveged.service.d/30_security-misc.conf

  • set dracut reproducible=yes setting

Related

Discussion

Happening primarily in forums.

https://forums.whonix.org/t/kernel-hardening/7296

How to install security-misc

See https://www.kicksecure.com/wiki/Security-misc#install

How to Build deb Package from Source Code

Can be build using standard Debian package build tools such as:

dpkg-buildpackage -b

See instructions. (Replace generic-package with the actual name of this package security-misc.)

Contact

Donate

security-misc requires donations to stay alive!

More Repositories

1

apparmor-profile-everything

deprecated - maybe replaced by: `apparmor.d`
Shell
88
star
2

sdwdate

Secure Distributed Web Date; privacy, anonymity and Tor friendly; console time fetcher and daemon; optional graphical user interface etc. Website: https://www.kicksecure.com/wiki/sdwdate
Python
51
star
3

hardened-kernel

Hardened kernel configuration optimized for virtual machines. - https://www.kicksecure.com/wiki/Hardened-kernel
Shell
38
star
4

apparmor-profile-torbrowser

AppArmor profile for The Tor Browser Bundle (TBB) - https://www.whonix.org/wiki/AppArmor - for better security (hardening).
16
star
5

tb-updater

Tor Browser Downloader - Automates download and verification of Tor Browser from The Tor Project's website. This package is produced independently of, and carries no guarantee from, The Tor Project.
Shell
15
star
6

gpg-bash-lib

gpg file verification bash library, addresses comprehensive threat model, that covers file name tampering, indefinite freeze, rollback, endless data attacks, etc.
Shell
13
star
7

tor-control-panel

Tor controller
Python
13
star
8

tb-starter

Tor Browser Starter. Open Link Confirmation; Qubes integration; Command line --new-tab, --new-window; start menu entry; This package is produced independently of, and carries no guarantee from, The Tor Project.
Shell
11
star
9

bootclockrandomization

Randomizes clock when systems boots by adding a few seconds and nanoseconds to enforce the design goal, that the host clock and Gateway/Workstation clock should always slightly differ (even before secure timesync succeeded!) to prevent time based fingerprinting / linkablity issues. For better anonymity and privacy. - https://www.kicksecure.com/wiki/Boot_Clock_Randomization
Shell
10
star
10

dist-base-files

base files for distributions - several important miscellaneous files, such as /etc/hostname, /etc/hosts, /var/lib/dbus/machine-id and more
Shell
9
star
11

helper-scripts

Helper scripts useful for Linux Distributions
Shell
9
star
12

swap-file-creator

Adds encrypted swap file to the system - for better protection of locally stored data and to aid environments with low RAM. https://www.kicksecure.com/wiki/swap-file-creator
Shell
9
star
13

libvirt-dist

Libvirt XML Files for Derivative Linux Distributions KVM - https:/www.kicksecure.com/wiki/KVM / https://www.whonix.org/wiki/KVM
Shell
8
star
14

ram-wipe

Wipe RAM on shutdown and reboot - Cold Boot Attack Defense
Shell
7
star
15

anon-apt-sources-list

/etc/apt/sources.list.d/debian.list for Security-Focused Linux Distributions
6
star
16

developer-meta-files

Scripts for managing derivative official repositor; debug scripts; developer documentation
Shell
5
star
17

anon-connection-wizard

Python
5
star
18

kicksecure-base-files

Kicksecure Base Files
Shell
5
star
19

monero-gui

Archived -> MOVED to GitLAB: https://gitlab.com/whonix/monero-gui - Old description: Monero GUI and CLI Debian Package. Can be installed using APT. Upstream / origin is https://github.com/monero-project/monero-gui.
Shell
5
star
20

usability-misc

Misc usability improvements
Shell
4
star
21

open-link-confirmation

Asks for confirmation before opening links - For better security. - Asks before a link is (accidentally) opened in a browser to avoid linking activities.
Shell
3
star
22

genmkfile

Simplifies Debian Packaging and Maintenance
Shell
3
star
23

apparmor-profile-thunderbird

AppArmor profile for Thunderbird - https://www.kicksecure.com/wiki/AppArmor - for better security (hardening).
3
star
24

apparmor-profile-hexchat

AppArmor profile for HexChat IRC - https://www.kicksecure.com/wiki/AppArmor - for better security (hardening).
3
star
25

initializer-dist

for better security. Makes finding backdoors easier.
Shell
3
star
26

apparmor-profile-dist

AppArmor profile for Derivative Linux Distributions - https://www.kicksecure.com/wiki/AppArmor - for better security (hardening).
Shell
2
star
27

msgcollector

GUI / CLI Toolkit Library - collects messages send to it by applications (API) and dispatches them when instructed to do so by the application
Shell
2
star
28

canary

https://www.kicksecure.com/wiki/Trust#Whonix_Warrant_Canary
Standard ML
2
star
29

live-config-dist

Shell
2
star
30

timesanitycheck

Checks if the system clock is sane between build timestamp and expiration date - useful in context of secure network time synchronization.
Shell
2
star
31

systemcheck

https://www.kicksecure.com/wiki/systemcheck
Shell
2
star
32

vm-config-dist

usability enhancements for Debian guest operating systems running inside virtual machines (VMs)
Shell
2
star
33

binaries-freedom

https://forums.whonix.org/t/policy-for-inclusion-of-compiled-software/6635
Shell
2
star
34

serial-console-enable

Allows login through command line interface (CLI) by enabling serial console for example for use with `virsh console vm-name` - https://www.kicksecure.com/wiki/Serial_Console
Shell
1
star
35

anon-shared-build-apt-sources-tpo

Adds The Tor Projects's (TPO) APT repository to Derivative Linux Distributions during build. - Useful, because TPO's repository sometimes contains better/more recent versions of Tor, obfsproxy, torsocks, etc. This package is produced independently of, and carries no guarantee from, The Tor Project.
1
star
36

legacy-dist

Prepare older Build Versions of Whonix for Upgrade
Shell
1
star
37

damngpl

Extract source package info from Debian status files - http://www.finnie.org/software/damngpl/damngpl
Perl
1
star
38

icon-pack-dist

Icon Pack for Derivative Distributions - Contains icons, that are used by other derivative distribution specific packages. Others are welcome to use these icons according to their Free licenses as well.
1
star
39

rads

RAM Adjusted Desktop Starter - Starts [no] desktop environment based on available RAM. Automagically boots into graphical desktop environment, when there is enough RAM. Or into terminal-only, when there is too little RAM. Useful inside virtual machines. - For better usability. - https://www.kicksecure.com/wiki/RAM_Adjusted_Desktop_Starter
Shell
1
star
40

tb-default-browser

Configures system to use /usr/bin/torbrowser as default browser
Shell
1
star
41

setup-dist

Shell
1
star
42

repository-dist

Shell
1
star
43

kicksecure-network-conf

1
star
44

desktop-config-dist

Shell
1
star