You are hereBlogs / Enrix's blog / Hardening:Linux Boot Loader

Hardening:Linux Boot Loader


By Enrix - Posted on 30 November 2010

This article will cover how to harden linux boot loader.The LILO loader will be used, but you can easily adapt this suggestion with GRUB as well.

Analyzing the various parts of this article and considering the strategies of attack and defense, you can be able to understand  the security level of this bootloader.

Defence

The first thing to do is to prevent the system booting from a device other than the hard disk. In order to do this you have to go into the BIOS , set the boot from hard disk and set a bios password such that nobody else can change the  setting. Make sure that the chassis is locked so that no one can reset the bios or mount the hard drive on a different machine.

Attack

The most common way how to reset the bios password  is to physically remove the computer from the power  by disconnecting the power plug and then removing the battery from the motherboard for 10 minutes.

Defence

Second step will be prevent the possibility to insert kernel parameter in the boot-phase.

Edit lilo.conf and insert inside  it the parameter “restricted” with “ password=” ”.

After that we can save all with lilo -v -p, and a new password will be required .

The option -p will ensure that the  password will be store cripted not inside lilo.conf ma in /etc/lilo.conf.crc.

If you're paranoid, then you can always make lilo.conf immutable:

# chattr +i /etc/lilo.conf

this works just on ext2/ext3 file systems.

Attack

To obtain a root shell during the boot system is enough write this commands in boot-phase:  

#linux init=/bin/bash #mount -o remount,rw /

after that, change the password:

#passwd

If lilo.conf is protect by a password we can start the system from a cdrom, we can use this trick: (you will need to mount the root filesystem somewhere within the livecd)  

#mkdir /mnt/root

#mount -t [linux-fs] /dev/[root-partition] /mnt/root

Now we want to use the chroot command to put us into our 'root' filesystem and then we can change the password:

# chroot /mnt/root /bin/bash

#passwd

Have fun!    

Tags

Translate in: