Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:grsec [2006/04/17 16:12]
a more
linux:grsec [2009/05/25 00:35] (current)
Line 16: Line 16:
 ==== Links ==== ==== Links ====
   * [[http://www.grsecurity.net/|GrSecurity homepage]]   * [[http://www.grsecurity.net/|GrSecurity homepage]]
 +  * [[http://www.securityfocus.com/infocus/1551|Great article about GrSec on SecurityFocus.com]] 
 +  * [[http://pax.grsecurity.net/|PAX Homepage]]
  
 ===== Instalation ===== ===== Instalation =====
Line 25: Line 26:
  
   server@/usr/src/linux# zcat ../grsecurity-2.XXX.patch.gz |patch -p1   server@/usr/src/linux# zcat ../grsecurity-2.XXX.patch.gz |patch -p1
 +
 +==== gradm install from source ====
 +
 +  # gradm-xxxx.tar.gz
 +  # cd gradm
 +  # ./configure
 +  # make && make install
 +  ...
 +  Setting up grsecurity ACL password
 +  Password:
 +  Re-enter Password:
 +  Password written to /etc/grsec/pw.
 +
  
 ==== kernel 2.4.x tips ==== ==== kernel 2.4.x tips ====
 +
 +
 ==== kernel 2.6.x tips ==== ==== kernel 2.6.x tips ====
 +
 +
 +=== What to include in 2.6 with GRSecurity (Safeway) ===
 +**taken from: [[http://lists.grok.org.uk/pipermail/full-disclosure/2003-August/008236.htm|here]]
 +**
 +
 +There are some problems with some applications with parts of the patch. For 
 +example, turning on the non-executeable stack will break anything that uses 
 +an executeable stack. ie: X, java, or wine, now you can use chpax and give 
 +each of these a non executable stack. There are also some problems with the 
 +way grsecurity gets a little to restrictive with things like restericting 
 +filesystems ect. All of these can be overcome, however, you need to do some 
 +magic to get some of these things to work, and frankly, some of it really 
 +isnt worth it. 
 +
 +There are several options inside the grsecurity patch that you can choose.
 +
 +What you can safely turn on in GRsecurity without breaking anything is:
 +   * **''Address Space Protection''**
 +   * **''Address Space Layout Randomization''**
 +      * **''Randomize kernel stack base''**
 +      * **''Randomize user stack base''**
 +      * **''Randomize mmap() base''**
 +
 +   * **Filesystem Protections**
 +      * //Everything under this option is safe to include//
 +
 +   * **''Kernel Auditing''**
 +      * //Everything under this option is safe to include//
 +
 +   * **''Executable Protections''**
 +      * //Everything under this option is safe to __incude except__:// ''Partially restrict non-root users''
 +
 +  * **''Network Protections''**
 +     * //Everything under this option is safe to include//
 +
 +  * **''Sysctl support''** //This is usefull to enable, but not necesary
 +//
 +
 +Compile everything staticly and you shold be fine. 
 +
 +I have tested this on production servers, and desktop boxes in mass and its 
 +come out fine for x86 and sparc. I havent tried it on ppc but for the most 
 +part it is safe, and it is also safe for production envoirnments.
 +
 +=== Using Pax and Grsecurity features ===
 +
 +First get a grsecurity patch kernel ready go in your **''menuconfig > Security > Pax Funnctions''**
 +
 +<code>
 +Enable various PaX features
 +
 +[*] Support soft mode
 +[*] Use legacy ELF header marking
 +[*] Use ELF program header marking
 +MAC system integration (direct)  —>
 +
 +Non-executable pages
 +
 +[*] Enforce non-executable pages
 +[*]   Paging based non-executable pages
 +[*]   Segmentation based non-executable pages
 +[*] Emulate trampolines
 +[*] Restrict mprotect()
 +[ ]   Disallow ELF text relocations
 +[*] Enforce non-executable kernel pages
 +
 +[*] Address Space Layout Randomization
 +[*]   Randomize kernel stack base
 +[*]   Randomize user stack base
 +[*]   Randomize mmap() base
 +</code>
 +And for Miscellaneous hardening features I advise not to select any.
 +
 +<note important>Once you got your pax and gr security kernel setup and have booted into it the first thing you will have to do is disable some pax functions on php binaries. **NOTICE: php will work with pax functions enabled but will nbot be able to load anything like zend optimizer**</note>
  
 ===== Configuration ===== ===== Configuration =====
Line 72: Line 163:
   kernel.pax.softmode = 1   kernel.pax.softmode = 1
   kernel.grsecurity.grsec_lock = 0   kernel.grsecurity.grsec_lock = 0
 +
  
 ==== PaX ==== ==== PaX ====
 +
 +  * [[http://pax.grsecurity.net/|PAX Homepage]]
 +
 +install pax utils:
 +   apt-get install chpax paxctl paxtest
 +
 +**Testing the PAX default settings** with ''paxtest''
 +
 +  PaXtest - Copyright(c) 2003,2004 by Peter Busser <peter@adamantix.org>
 +  Released under the GNU Public Licence version 2 or later
 +  
 +  Mode: kiddie|blackhat
 +  Linux xxxx
 +  
 +  Executable anonymous mapping             : Vulnerable
 +  Executable bss                           : Vulnerable
 +  Executable data                          : Vulnerable
 +  Executable heap                          : Vulnerable
 +  Executable stack                         : Vulnerable
 +  Executable anonymous mapping (mprotect)  : Vulnerable
 +  Executable bss (mprotect)                : Vulnerable
 +  Executable data (mprotect)               : Vulnerable
 +  Executable heap (mprotect)               : Vulnerable
 +  Executable shared library bss (mprotect) : Vulnerable
 +  Executable shared library data (mprotect): Vulnerable
 +  Executable stack (mprotect)              : Vulnerable
 +  Anonymous mapping randomisation test     : 9 bits (guessed)
 +  Heap randomisation test (ET_EXEC)        : 13 bits (guessed)
 +  Heap randomisation test (ET_DYN)         : 13 bits (guessed)
 +  Main executable randomisation (ET_EXEC)  : No randomisation
 +  Main executable randomisation (ET_DYN)   : No randomisation
 +  Shared library randomisation test        : 8 bits (guessed)
 +  Stack randomisation test (SEGMEXEC)      : 19 bits (guessed)
 +  Stack randomisation test (PAGEEXEC)      : 19 bits (guessed)
 +  Return to function (strcpy)              : Vulnerable
 +  Return to function (strcpy, RANDEXEC)    : Vulnerable
 +  Return to function (memcpy)              : Vulnerable
 +  Return to function (memcpy, RANDEXEC)    : Vulnerable
 +  Executable shared library bss            : Vulnerable
 +  Executable shared library data           : Vulnerable
 +  Writable text segments                   : Vulnerable
 +
 +==== Hardening Webservers ====
 +
 +For example
 +
 +   paxctl -c /usr/local/bin/php
 +
 +   paxctl -permxs /usr/local/bin/php
 +
 +You can even use wildcards like'' /usr/bin/php*''
 +
 +Also make sure you do the** ''sapi/cli/cgi''** module of your web server the same way. On some webservers like litespeed you will have to do the binaries on it as well. Do not disable binaries too freely, only try to do it if it is the only option to make it work.
 +
 ==== gdadm ==== ==== gdadm ====
-  TODO+ 
 +The **gradm** utility controls only grsecurity's [[wp>RBAC|RBAC]] system; it cannot alter the behavior of grsecurity' there features. In a grsecurity-enabled kernel, gradm installs with a simple make; make install. You can set an admin password for gradm, which is a good idea, as once RBAC is enabled, even root's power will be restricted, and to get it back, you need to assume the admin role. You also need a password to shut down [[wp>RBAC]]. Set the admin password with the command: 
 + 
 +   gradm -P admin 
 + 
 +Once you've set up a password, you can log into gradm as admin with the command: 
 + 
 +   gradm -a 
 + 
 +An innovative way to set up RBAC is to use grsecurity's learning mode. In learning mode, grsecurity watches for processes that run with root privileges, access the Internet, or write to key system files or directories. Grsecurity then generates an access control list (ACL) that instructs grsecurity to run these processes using the least privilege approach mentioned earlier. To enable learning mode, run: 
 + 
 +   gradm -F -L /etc/grsec/learning.log 
 + 
 +Let this mode run for a day or two to catch any time-sensitive processes. Avoid any administrative tasks during this time -- remember, the root account is no longer trusted. After grsecurity has had enough time to recognize normal system usage, shut down learning mode and log into gradm as admin. Shutting down learning mode is necessary because grsecurity hides its configuration files when RBAC is running, as it is during learning mode. This means that the system will display an error message about not being able to find learning.log. In fact, the directory /etc/grsec will not appear to exist, even to root. 
 + 
 +To write the ACL to disk, run the command: 
 + 
 +   gradm -F -L /etc/grsec/learning.log -O /etc/grsec/acl 
 + 
 +To start RBAC with your new ACL, run: 
 + 
 +  gradm -E 
 + 
 +You can now enjoy the security advantages of processes running with the least amount of privileges necessary. 
 + 
 +If you encounter any problems, disable RBAC by first logging in with the admin password and then running: 
 + 
 +   gradm -D  
  
 ==== grsec iptables patch ==== ==== grsec iptables patch ====
-  TODO+FIXME TODO 
 + 
 +===== Tips / troubleshooting ===== 
 + 
 +==== complaints of grsecurity-kernel about RLIMIT_CORE being 0 ==== 
 + 
 +If, while running program x, a segmentation fault occurs in program x and syslog outputs the following string: 
 +   Apr 17 11:55:06 yyy kernel: grsec: attempted resource overstep by requesting 4096 for RLIMIT_CORE against limit 0 by (x:z) UID(y) EUID(y), parent (y:y) UID(y) EUID(y)  
 +then kernel tried to write a core-file for the program x to disk, BUT the max size of the core file is set to 0. 
 +Growing the maximum size of a core file: 
 + 
 +  # ulimit -S -c 8192 
 + 
linux/grsec.1145283124.txt.gz · Last modified: 2009/05/25 00:34 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready