Grsecurity Presentation
Grsecurity Presentation
Grsecurity Presentation
KERNEL SECURITY
WITH GRSECURITY AND PAX
FEATURES
GrSecurity has a lot of features which are organized into categories based on
their intrusiveness.
LOW
Linking restrictions
Following symlinks in +t directories (e.g. temp) disabled
No hardlinks to files you don't own
Enforcing RLMIT_NPROC on execve()
Restrict dmesg to root
Disable module loading utilities
Enforce chdir("/") on chroot
mkdir foo
chroot foo
cd ..
MEDIUM
Log failed forks, time changes and signals
No mounts inside chroot
No sysctl and mknod in chroot
mknod can create a device entry pointing to a harddrive or console,
allowing an attacker to write to it
No access to AF_UNIX sockets outside chroot
No writing to kmem, mem and port (even as root)
Restrict /proc
Non-root users can only access their own processes
Keep normal users from viewing any device information and slabinfo
ASLR (I'll come back to this later)
ABUSING MKNOD
# Find out mknod params
/ ~ cd /dev
/dev ~ ls hda1 -l
brw-r-----1 root root 3,
# Access hda in chroot
mknod hdacpy b 3 0
# Access console in chroot
mknod console c 5 1 # linux
mknod console c 0 0 # os x
HIGH
No signals, priority, fchdir, ptrache or access to processes outside of a chroot
Remove all addresses from smaps, maps and stat
Randomize every task's kernel stack (may break stuff)
Log mounts
Restrict sysfs / debugsfs
Hint: chmod 0700 /mpath
Active exploit responses
Those are triggered on consequent `illegal operation` errors
Root? Panic the system!
User? Lock the account and save all relevant information
PAX
PAX marks memory as non-executable, making buffer overflows impossible
This can be enforced system-wide (recommended) or individually per
application
Emulation of executable pages in sandbox-like environments is available for
individual processes (e.g xorg)
Restricts mprotect, makes it smart
Can also enforce non-executable kernel pages, mitigates code executing
kernel exploits (but the same goes for driver BLOBS)
AUDITING
Execv, Ressources, Signals, Chdir's, fork's
Append remote-ip to the kernel task struct and log it
RBAC
Role Based Access Control is an approach to selectively limit users by restricting
access to certain resources (such as sockets) on a case by case basis
RBAC rules apply to root, so gaining root-access does not necessarily
compromise a system (Remember the kernel panic?)
RBAC - LIMITATION
Limited responsiveness to new software
Fully compromised system = fully compromised rbac
MISC
Sanitize all free memory
Prevent invalid userland pointer dereferences
NEW PROCESSES?
// edit /etc/grsec/learn_config
[command] [path]
inherit-learn - inherit rules from called binaries / libraries
no-learn - use your own rule definition
high-reduce-path - try to restrict as much as possible
dont-reduce-path - do the opposite (pre configured)
protected-path - give own learning subject to path
high-protected-path - same and hide path
// train
gradm -L /etc/grsec/learning.logs -E
// do stuff, then apply rules
gradm -D
gradm -L /etc/grsec/learning.logs -O /etc/grsec/policy
RBAC RULES
role admin sA # role mode
subject / rvka # subject mode
/ rwcdmlxi
role default G # role mode
role_transitions admin # role attribute
subject / #subject mode
/
r #object mode
/opt
rx
/home
rwxcd
/mnt
rw
/dev
/dev/grsec
h
RBAC MODES
#
u
l
N
#
b
d
h
K
o
k
subject = process
- enable process accounting
- protect all memory access (even from root)
- hidden
- kill upon alert
- protect
- can kill protected processes
# object = file
r/w/a/c/x - read / write / append / create / exec
i - inherit rules from path
l - allow hardlinks
h - hide
CVS ROLE
role cvs u
subject /
/
h
-CAP_ALL
connect
bind
disabled
disabled
subject /usr/bin/cvs
/
/etc/fstab
r
/etc/mtab
r
/etc/passwd
r
/proc/meminfo
r
/dev/urandom
r
/dev/log
rw
/dev/null
rw
/home/cvs
r
/home/cvs/CVSROOT/val-tags
/home/cvs/CVSROOT/history
/tmp
rwcd
/var/lock/cvs
rwcd
rw
ra
PAX
paxctl -c /usr/bin/vi
file /usr/bin/vi had a PT_GNU_STACK program header, converted
paxctl -v /usr/bin/vi
PaX control v0.5
Copyright 2004,2005,2006,2007 PaX Team [pageexec@freemail.hu]
- PaX flags: -------x-e-- [/usr/bin/vi]
RANDEXEC is disabled
EMUTRAMP is disabled
THE END
QUESTIONS?