Get the LinuxSecurity news you want faster with RSS
Powered By
Master's Student: A Quick and Dirty Guide To Kernel Hardening with GrSecurity
Source: www.8ciphers.com - Posted by Ryan Berens
Our resident Master's student Gian Spicuzza chimes in this month with a great feature HowTo on Kernel Hardening! There are a number of ways to lock down a system, and RBAC (role based access control) is one of them. Read on to learn more about what makes RBAC so useful, and to read one of the best overviews on Low/Medium/High Security...
The combination of the Linux kernel and GNU packages has always been regarded as a secure operating system, but can it be more secure? Kernel hardening is the answer to tightening up the Linux backbone. GrSecurity, a kernel patch for Linux, is one of the more popular approaches...
One of the most significant feature is the addition of a role-based access control system (RBAC) that monitors what each user can execute based on their role and denies execution if they overstep their pre-defined rules.
A Quick and Dirty Guide To Kernel Hardening with GrSecurity
By: Gian G. Spicuzza ; www.8ciphers.com
The combination of the Linux kernel and GNU packages has always been regarded as a secure operating system, but can it be more secure? Kernel hardening is the answer to tightening up the Linux backbone. GrSecurity, a kernel patch for Linux, is one of the more popular approaches. After applying this patch and compiling a fresh kernel, your system will have a plethora of new security features.
The most significant feature is the addition of a role-based access control system (RBAC) that monitors what each user can execute based on their role and denies execution if they overstep their pre-defined rules. Other useful features include ip-based rules, extensive chroot restrictions, address space modification restrictions (PaX), auditing/logging features and /proc and dmesg anti-leak features. A full feature list can be found at the Grsecurity homepage.
Installing Grsecurity:
First we need to download the Linux kernel and Grsec patch.
Move the kernel and patch into the /usr/src directory.
$ su -c “cp linux-2.6* /usr/src; cp grsec* /usr/src”
Extract the kernel and patch (you need to be in root since you're working in /usr/src).
$ su
# tar zxvf linux-2.6.19.2.tar.gz
# gunzip grsecurity-2.1.10-2.6.19.2-200701222307.patch.gz
# patch -p0 < grsecurity-2.1.10-2.6.19.2-200701222307.patch
Start with the kernel configuration.
# make clean
# make mrproper
# make menuconfig
Choose all of the options that are required for your hardware, or use “make oldconfig” and se an old configuration file. When you arrive at the “GRSECURITY” section, enable it by hitting the spacebar. You are now prompted with an array of security features. Building a custom scheme is as easy as selecting a few features, or select a pre-defined security level based on your needs. Taylor Merry created a fantastic list that shows what each level of security provides. His table is listed below:
Low Security:
linking restrictions
fifo restrictions
random pids
enforcing nproc on execve()
restricted dmesg
random ip ids
enforced chdir("/") on chroot< /li>
Medium Security (includes all of the Low Security options):
random tcp source ports
altered ping ids
failed fork logging
time change logging
signal logging
deny mounts in chroot
deny double chrooting
deny sysctl writes in chroot
deny mknod in chroot
deny access to abstract AF_UNIX sockets out of chroot
deny pivot_root in chroot
denied writes of /dev/kmem, /dev/mem, and /dev/port• /proc restrictions with special gid set to 10 (usually wheel)
address space layout randomization
High Security (includes all of the Low and Medium Security options):
additional /proc restrictions
chmod restrictions in chroot
no signals, ptrace, or viewing processes outside of chroot
capability restrictions in chroot
deny fchdir out of chroot
priority restrictions in chroot
segmentation-based implementation of PaX
mprotect restrictions
removal of /proc//[maps|mem]
kernel stack randomization
mount/unmount/remount logging
kernel symbol hiding(18)
Outside of the options in these categories are a few additional options that can be
enabled manually:
PaX: PAGEEXEC
PaX: EMUTRAMP
PaX: EMUSIGRT
PaX: Disallow ELF text relocations (DANGEROUS)
Disable privileged I/O (should not use with XFree86)
Hide kernel processes
Allow a user group access to /proc
Auditing options
Set up a single group that is the only one audited
Exec logging
Log execs within chroot
Chdir logging
IPC logging
Trusted path execution
Socket restrictions
Sysctl support
Netfilter Configuration: stealth match support(18) *1
For personal computers, I select “Low security” and enable all of the logging and auditing features. For servers and mission critical machines, I start with “Medium security” and add additional elements based on my own discretion.
After you have selected all of the necessary options, lets compile the kernel.
# make modules modules_install bzImage
Finally, copy the new kernel into your /boot directory and adjust your bootloader to load the new kernel. Your new kernel will be located in "usr/src/linux/arch/i386/boot/."
At this point, you now have a Linux kernel with copious amounts of added security and protection.
Check back soon because our next article will show you how to use the role based access control system and how to compile programs to take advantage of the PaX address space modification restrictions!