Benvenuto nella nostra community, registra un account gratuito ADESSO!
Oltre 7000 persone hanno già registrato il loro account. Chiedi aiuto, conversa con aziende ed esperti del settore webhosting italiano.
Iscriviti subito! In meno di 2 minuti!




Risultati da 1 a 4 di 4

Discussione: Kernel hardening

  1. #1
    Utente Moderatore L'avatar di Rebel
    Data Registrazione
    Feb 2006
    Località
    London
    Messaggi
    1,655

    Kernel hardening

    Usiamo Grsec per rendere un po' più sicura la nostra linux box debian/ubuntu:

    grsecurity is an innovative approach to security utilizing a multi-layered detection, prevention, and containment model. It is licensed under the GPL.
    It offers among many other features:
    • An intelligent and robust Role-Based Access Control (RBAC) system that can generate least privilege policies for your entire system with no configuration
    • Change root (chroot) hardening
    • /tmp race prevention
    • Extensive auditing
    • Prevention of arbitrary code execution, regardless of the technique used (stack smashing, heap corruption, etc)
    • Prevention of arbitrary code execution in the kernel
    • Randomization of the stack, library, and heap bases
    • Kernel stack base randomization
    • Protection against exploitable null-pointer dereference bugs in the kernel
    • Reduction of the risk of sensitive information being leaked by arbitrary-read kernel bugs
    • A restriction that allows a user to only view his/her processes
    • Security alerts and audits that contain the IP address of the person causing the alert
    Scarichiamo la giusta versione del kernel e patch:

    Codice:
    cd /usr/src
    wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.11.tar.gz
    wget http://www.grsecurity.net/grsecurity-2.1.9-2.6.17.11-200609031316.patch.gz
    Scompattiamo il tutto:

    Codice:
    tar xzvf linux-2.6.17.11.tar.gz
    gzip -d rsecurity-2.1.9-2.6.17.11-200609031316.patch.gz
    Applichiamo la patch:

    Codice:
    patch -p0 < ./grsecurity-2.1.9-2.6.17.11-200609031316.patch
    Installiamo i pacchetti .deb necessari per compilare il kernel:

    Codice:
    apt-get install debhelper modutils kernel-package libncurses5-dev
    Ora configuriamo e compiliamo il nuovo kernel:

    cd linux-2.6.17.11
    make-kpkg clean
    make menuconfig
    Ora si tratta di configurare il kernel. Io utilizzo queste opzioni per grsec:
    Codice:
    #
    # Security options
    #
    
    #
    # PaX
    #
    CONFIG_PAX=y
    
    #
    # PaX Control
    #
    CONFIG_PAX_SOFTMODE=y
    # CONFIG_PAX_EI_PAX is not set
    # CONFIG_PAX_PT_PAX_FLAGS is not set
    # CONFIG_PAX_NO_ACL_FLAGS is not set
    CONFIG_PAX_HAVE_ACL_FLAGS=y
    # CONFIG_PAX_HOOK_ACL_FLAGS is not set
    
    #
    # Non-executable pages
    #
    CONFIG_PAX_NOEXEC=y
    CONFIG_PAX_PAGEEXEC=y
    CONFIG_PAX_MPROTECT=y
    # CONFIG_PAX_NOELFRELOCS is not set
    
    #
    # Address Space Layout Randomization
    #
    CONFIG_PAX_ASLR=y
    # CONFIG_PAX_RANDUSTACK is not set
    # CONFIG_PAX_RANDMMAP is not set
    
    #
    # Miscellaneous hardening features
    #
    CONFIG_PAX_MEMORY_SANITIZE=y
    
    #
    # Grsecurity
    #
    CONFIG_GRKERNSEC=y
    # CONFIG_GRKERNSEC_LOW is not set
    # CONFIG_GRKERNSEC_MEDIUM is not set
    # CONFIG_GRKERNSEC_HIGH is not set
    CONFIG_GRKERNSEC_CUSTOM=y
    
    #
    # Address Space Protection
    #
    CONFIG_GRKERNSEC_KMEM=y
    CONFIG_GRKERNSEC_IO=y
    # CONFIG_GRKERNSEC_PROC_MEMMAP is not set
    CONFIG_GRKERNSEC_BRUTE=y
    CONFIG_GRKERNSEC_MODSTOP=y
    CONFIG_GRKERNSEC_HIDESYM=y
    
    #
    # Role Based Access Control Options
    #
    CONFIG_GRKERNSEC_ACL_HIDEKERN=y
    CONFIG_GRKERNSEC_ACL_MAXTRIES=3
    CONFIG_GRKERNSEC_ACL_TIMEOUT=30
    
    #
    # Filesystem Protections
    #
    CONFIG_GRKERNSEC_PROC=y
    CONFIG_GRKERNSEC_PROC_USER=y
    CONFIG_GRKERNSEC_PROC_ADD=y
    CONFIG_GRKERNSEC_LINK=y
    CONFIG_GRKERNSEC_FIFO=y
    CONFIG_GRKERNSEC_CHROOT=y
    CONFIG_GRKERNSEC_CHROOT_MOUNT=y
    CONFIG_GRKERNSEC_CHROOT_DOUBLE=y
    CONFIG_GRKERNSEC_CHROOT_PIVOT=y
    CONFIG_GRKERNSEC_CHROOT_CHDIR=y
    CONFIG_GRKERNSEC_CHROOT_CHMOD=y
    CONFIG_GRKERNSEC_CHROOT_FCHDIR=y
    CONFIG_GRKERNSEC_CHROOT_MKNOD=y
    CONFIG_GRKERNSEC_CHROOT_SHMAT=y
    CONFIG_GRKERNSEC_CHROOT_UNIX=y
    CONFIG_GRKERNSEC_CHROOT_FINDTASK=y
    CONFIG_GRKERNSEC_CHROOT_NICE=y
    CONFIG_GRKERNSEC_CHROOT_SYSCTL=y
    # CONFIG_GRKERNSEC_CHROOT_CAPS is not set
    
    #
    # Kernel Auditing
    #
    # CONFIG_GRKERNSEC_AUDIT_GROUP is not set
    # CONFIG_GRKERNSEC_EXECLOG is not set
    # CONFIG_GRKERNSEC_RESLOG is not set
    # CONFIG_GRKERNSEC_CHROOT_EXECLOG is not set
    # CONFIG_GRKERNSEC_AUDIT_CHDIR is not set
    # CONFIG_GRKERNSEC_AUDIT_MOUNT is not set
    # CONFIG_GRKERNSEC_AUDIT_IPC is not set
    # CONFIG_GRKERNSEC_SIGNAL is not set
    # CONFIG_GRKERNSEC_FORKFAIL is not set
    # CONFIG_GRKERNSEC_TIME is not set
    # CONFIG_GRKERNSEC_PROC_IPADDR is not set
    # CONFIG_GRKERNSEC_AUDIT_TEXTREL is not set
    
    #
    # Executable Protections
    #
    CONFIG_GRKERNSEC_EXECVE=y
    CONFIG_GRKERNSEC_SHM=y
    CONFIG_GRKERNSEC_DMESG=y
    CONFIG_GRKERNSEC_RANDPID=y
    # CONFIG_GRKERNSEC_TPE is not set
    
    #
    # Network Protections
    #
    CONFIG_GRKERNSEC_RANDNET=y
    # CONFIG_GRKERNSEC_SOCKET is not set
    
    #
    # Sysctl support
    #
    CONFIG_GRKERNSEC_SYSCTL=y
    CONFIG_GRKERNSEC_SYSCTL_ON=y
    
    #
    # Logging Options
    #
    CONFIG_GRKERNSEC_FLOODTIME=10
    CONFIG_GRKERNSEC_FLOODBURST=4
    CONFIG_KEYS=y
    # CONFIG_KEYS_DEBUG_PROC_KEYS is not set
    CONFIG_SECURITY=y
    CONFIG_SECURITY_NETWORK=y
    # CONFIG_SECURITY_NETWORK_XFRM is not set
    CONFIG_SECURITY_CAPABILITIES=m
    CONFIG_SECURITY_SECLVL=m
    CONFIG_SECURITY_SELINUX=y
    CONFIG_SECURITY_SELINUX_BOOTPARAM=y
    CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
    CONFIG_SECURITY_SELINUX_DISABLE=y
    CONFIG_SECURITY_SELINUX_DEVELOP=y
    CONFIG_SECURITY_SELINUX_AVC_STATS=y
    CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
    Ho lasciato perdere il loging per ora, dato che ne genera veramente un sacco e devo un attimo capire cosa è veramente utile.

    Salviamo il nostro bel .config, facendo attenzione ad aver selezionato i giusti moduli per il nostro hw, quindi compiliamo il tutto:

    Codice:
    make-kpkg --revision=1 kernel_image
    Una volta terminato installiamo il pacchetto:

    Codice:
    cd /usr/src
    dpkg -i kernel-image-2.6.17.11_1_amd64.deb
    Io utilizzo lilo quindi proseguo con quello.
    Editiamo lilo.conf

    Codice:
    vi /etc/lilo.conf
    ed aggiungiamo queste righe prima di quelle relative al nostro attuale kernel:

    Codice:
    image=/boot/vmlinuz-2.6.17.11
            label="Grsec"
            read-only
    Aggiorniamo il bootloader:

    Codice:
    lilo -v2
    Incrociamo le dita e riavviamo la macchina. :P

    Una volta riavviato logghiamoci come un utente X normale e proviamo a dare:

    Codice:
    ps aux
    dovremmo vedere solo i processi relativi a quell'utente e quindi grsec funziona correttamente.
    Le feature della patch sono moltissime quindi consiglio di leggersi bene le descrizioni relative quando si configura il kernel, e cercare di capire cosa ci va più a genio.








    FlareVM.it: Server Virtuali Xen Linux e Windows 512MB RAM partire da 8.49€!
    Piani cPanel Managed a partire da 29.99€. VPS ISPConfig3 e TurnKey pronte all'uso.
    Twitter: http://twitter.com/flarevm



  2. #2
    HTastinator
    Data Registrazione
    Mar 2006
    Località
    Senigallia (AN)
    Messaggi
    417

    Re: Kernel hardening

    Aggiungo che se si usa GRUB, quando il deb viene installato con dpkg -i viene automaticamente aggiornato il menu.lst, quindi non c'è bisogno di modificare il bootloader

    Inoltre se si abilita l'opzione per modificare alcune impostazioni via sysctl, è veramente facile e comodo gestire le opzioni.

    Esempio:

    Codice:
    kernel.grsecurity.chroot_deny_chroot = 1
    in questo caso abilita (1) l'opzione di grsecurity che impedisce un chroot dentro un chroot (che potrebbe servire per uscirci od altro..)

    Per il resto complimenti

  3. #3
    usu
    usu non è collegato
    Utente Moderatore L'avatar di usu
    Data Registrazione
    Apr 2006
    Località
    Milano
    Messaggi
    1,771

    Re: Kernel hardening

    Grazie mille, questa me la salvo, ne farò tesoro quando tirerò su un bel webserver

  4. #4
    Utente Moderatore L'avatar di Rebel
    Data Registrazione
    Feb 2006
    Località
    London
    Messaggi
    1,655

    Re: Kernel hardening

    Citazione Originariamente Scritto da niko Visualizza Messaggio
    Aggiungo che se si usa GRUB, quando il deb viene installato con dpkg -i viene automaticamente aggiornato il menu.lst, quindi non c'è bisogno di modificare il bootloader

    Inoltre se si abilita l'opzione per modificare alcune impostazioni via sysctl, è veramente facile e comodo gestire le opzioni.

    Esempio:

    Codice:
    kernel.grsecurity.chroot_deny_chroot = 1
    in questo caso abilita (1) l'opzione di grsecurity che impedisce un chroot dentro un chroot (che potrebbe servire per uscirci od altro..)

    Per il resto complimenti
    #
    # Sysctl support
    #
    CONFIG_GRKERNSEC_SYSCTL=y
    CONFIG_GRKERNSEC_SYSCTL_ON=y


    sono abilitate nel config che ho proposto.
    per grub grazie per la puntualizzazione. :P
    FlareVM.it: Server Virtuali Xen Linux e Windows 512MB RAM partire da 8.49€!
    Piani cPanel Managed a partire da 29.99€. VPS ISPConfig3 e TurnKey pronte all'uso.
    Twitter: http://twitter.com/flarevm

Discussioni Simili

  1. Hardening e ottimizzazione di server linux - Seconda parte
    Di Redazione HostingTalk nel forum Interviste & contenuti professionali
    Risposte: 0
    Ultimo Messaggio: 11-06-2010, 07:00
  2. Hardening e ottimizzazione di server linux - Prima parte
    Di Redazione HostingTalk nel forum Interviste & contenuti professionali
    Risposte: 0
    Ultimo Messaggio: 08-06-2010, 07:00
  3. Hardening e tuning iniziale del vostro server - Cecchi.biz
    Di Redazione HostingTalk nel forum Offerte Servizi Managed - Provider HostingTalk.it
    Risposte: 0
    Ultimo Messaggio: 31-05-2010, 17:20
  4. Hardening prima della messa in produzione di un sistema LAMP
    Di Redazione HostingTalk nel forum Interviste & contenuti professionali
    Risposte: 0
    Ultimo Messaggio: 20-02-2009, 07:14

Informazioni Discussione

Utenti che Stanno Visualizzando Questa Discussione

Ci sono attualmente 1 utenti che stanno visualizzando questa discussione. (0 utenti e 1 ospiti)

Tag per Questa Discussione

Segnalibri

Permessi di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  •