This email address is being protected from spambots. You need JavaScript enabled to view it. , )This email address is being protected from spambots. You need JavaScript enabled to view it. )With increasing popularity of Linux on Internet, more and more security holes are found in the current GNU/Linux system. You may hear from the Internet that - There are bugs found in Linux, which will cause the system tobe easily compromised by a hacker.
Since Linux is an art of the open source community, security holes can befound easily and can also be patched quickly. But when the hole is disclosed to the public and the administrator is too lazy to patch the hole, it is very easy to break into the current system and it is worse than that, the hacker can get the root shell. With the current GNU/linux system, he can do whatever he wants. Now, you may ask, what is the problem and what can we do?
What's wrong with the current GNU/Linux system.
With the above description about Linux insecurity, how can we build a secure system? We must have a secure kernel and then build our secure system on top of it. This is what LIDS does.
The Linux Intrusion Detection System is a patch which enhances the kernel's security. When it is in installed, chosen files access, every system/network administration operations, any capability use, rawdevice, mem, and I/O access can be made impossible even for root. Ituses and extends the system capabilities bounding set to control the whole system and adds some network and filesystem security features in kernel to enhance the security. You can finely tune the security protections online, hide sensitive processes, receive security alerts through the network, and more.
In short, LIDS provides Protection, Detection and Response to the intrusion in the Linux kernel.
With the LIDS features, let's go and see how to build a security system with LIDS step by step.
You can download LIDS patch from LIDS Home and LIDS Ftp Home and other mirror of LIDS around the world, check LIDS Mirror for the nearby mirror site.
The patch name will be lids-x.xx-y.y.y.tar.gz, x.xx represents the lids version and the y.y.y represents the Linux kernel version.
You
should download the corresponding kernel version. For example, if you
download the lids-0.9pre4-2.2.14.tar.gz, you should download the linux
kernel 2.2.14 source code. You can download the kernel source from Kernel FTP Site or other mirror site of it.
1. uncompress the linux kernel source code tree.
# cd linux_install_path
# bzip2 -cd linux-2.2.14.tar.bz2 | tar -xvf -
2. uncompress the lids source code.
# cd lids_install_path
# tar -zxvf lids-0.9pre4-2.2.14.tar.gz
After downloading the kernel source and LIDS, uncompress the source and lids.For example, if you download the lids-0.9pre4-2.2.14.tar.gz and linux-2.2.14.tar.bz2, then,
# cd linux_install_path
# patch -p0 < /lids_install_path/lids-0.9pre4-2.2.14.patch
Turning these on will add a series of options for LIDS. Note: There are many kernel options for LIDS. Please check the lids-howto for detailed information about configuring these options.
Turn the following options on:
[x] Prompt for development and/or incomplete code/drivers
[x] Sysctl support
# cd linux
# make menuconfig or make xconfig
5. compile the Linux kernel
6. copy the bzImage to /boot/ and edit the /etc/lilo.conf
# cd linux
# make dep clean
# make bzImage
# make modules
# make modules_install
# /sbin/lilo
lidsadm in the administration utility for LIDS.
It is required to install this before rebooting your system with
your new kernel but it does not require the new kernel or patch to
compile. It will compile and install with your original kernel.
# cd lids_install_path/lidsadm-0.9pre4
# make or make VIEW=1 (use VIEW=1 to see exact LIDS state)
# make install
Read the README included in the LIDS package for details on
compiling and running lidsadm.
Now before you reboot, you must configure your LIDS system to meet your security needs. You can define protected files, protected process, etc.. In the next chapter, we will show you the details about this topic.
After your system is configured, reboot the system. When lilo appears, select the LIDS enable kernel to load. After then, you enter the wonderful world of LIDS.
After your system boots up, do not forget to seal the kernel with lidsadm. You can put the command in the last line of /etc/rc.local.
# /sbin/lidsadm -I -- -CAP_SYS_RAWIO -CAP_NET_ADMIN
You can check the LIDS-HOWTO for a detailed list of all the options for lidsadm.
After you seal the kernel, your system is now protected by LIDS. You can run some tests on it. If you want to change a configuration, such as modify the capability option, you can change your LIDS security level online by providing a password.
# /sbin/lidsadm -S -- -LIDS
In this chapter, we will show you how to configure LIDS.
First, you must determine which files you will protect. In most cases, you may protect the system binary files and system configuration files, such as /usr/, /sbin/, /etc/, /var/log/.
Second, you must decide the way to protect the files. LIDS provide 3 protection type:
USAGE:
lidsadm -A -r filename_to_protect
Example:
1. to protect the whole /sbin/ as read-only.
# /sbin/lidsadm -A -r /sbin/
2. to protect /etc/passwd as read-only
# /sbin/lidsadm -A -r /etc/passwd
USAGE:
lidsadm -A -a filename_to_protect
Example:
1. to protect the system log files
# /sbin/lidsadm -A -a /var/log/message
# /sbin/lidsadm -A -a /var/log/secure
2. to protect the apache httpd log files
# /sbin/lidsadm -A -a /etc/httpd/logs/
# /sbin/lidsadm -A -a /var/log/httpd/
Here is the example from LIDS-HOWTO by Philippe Biond,
lidsadm -Z
lidsadm -A -r /boot
lidsadm -A -r /vmlinuz
lidsadm -A -r /lib
lidsadm -A -r /root
lidsadm -A -r /etc
lidsadm -A -r /sbin
lidsadm -A -r /usr/sbin
lidsadm -A -r /bin
lidsadm -A -r /usr/bin
lidsadm -A -r /usr/lib
lidsadm -A -a /var/log
#DEFINE LIDS_CONF "/etc/lids.conf"
LIDS can protect the process whose parent is init(pid=1). You must seal the kernel with a specified option as below.
# lidsadm -I -- +INIT_CHILDREN_LOCK
Capabilities are like privileges you can give a process. A root process has all the capabilities. But there exists a capabilities bounding set. In a normal kernel, when you remove a capability from the bounding set, nobody can ever use it again, until next reboot. (see https://www.earthlink.net/internet/ for the normal use).
LIDS modifies this behavior to enable you to switch these on and off, whenever you want. An access to the /proc/sys/kernel/cap_bset is trapped and raise a security alert. lidsadm performs the whole job.
You can list all the capabilities in LIDS by running lidsadm, and you can see what the exact meaning of each capability is.
We here discuss two of them,
With this capability on, we can allow ioperm/iopl and /dev/port access, allow /dev/mem and /dev/kmem acess and allow raw block devices (/dev/[sh]d??) acess
When we disable this capability, we can deny all processes on the system rights to the raw device, such as running lilo.
But some processes may want this capability to run, such as XF86_SVGA. In this case, we can put the program in the exception list when we compile the kernel.
This capability has the following abilities,
For security reasons, we should disable this to disallow network configuration changes. When it's disallowed, the firewall rules will not allow any changes.
interface configuration
administration of IP firewall, masquerading and accounting
setting debug option on sockets
modification of routing tables
setting arbitrary process / process group ownership on sockets
binding to any address for transparent proxying
setting TOS (type of service)
setting promiscuous mode
clearing driver statistics
multicasting
read/write of device-specific registers
You should choose what capability you want to disallow when sealing the kernel. Here we give an example.
You may put it in a rc script (rc.local, /etc/init.d/lids, /etc/rc.d/init.d/lids, etc.) depending upon your distribution and the way you administrate your system. The command is, for example :
lidsadm -I -- -CAP_SYS_MODULE -CAP_SYS_RAWIO -CAP_SYS_ADMIN \
-CAP_SYS_PTRACE -CAP_NET_ADMIN \
+LOCK_INIT_CHILDREN
LIDS provides some network security enhancements.
With each capability, we can enhance the network security. Such as anti-snifferring, can not bind to the port lower than 1024 and can not change the firewall and routing rules.
So, what I suggest is to view each capability defenition carefully.
LIDS provide a scanner detector in kernel in order to detect who has scanned your system. The scanner can detect half-open scans, normal scans etc.. Using tools like nmap, satan can be detected by the detector.
It is useful when raw sockets are disabled. In this casoes not use any socket, it will be more secure than a user space detector.
If you want this feature, you should select it on when you compile the kernel.
When LIDS detects a violation in the defined rules, it can respond to the action by the following method.
When someone violates a rule, lids_security_log will log a message the klogd. The logging also has the ability to anti_logging_flood. You can set it when compiling the kernel.
Now, LIDS has a new feature to mail the message to your mail account. You can define the mail server IP, the out-coming mail address,etc, when compiling the kernel.
When a user violates a rule, the console will shutdown that user's console.
First of all, I want to thank my friend, Kate lee, who always encouraged me to write document like this. This document is dedicated to her.
I also want to thank Philippe Biond and Christophe Long who largely contributed to the project. Without them, the project could never have developed so well.
Many thanks must also go to all the LIDS users. Without their contributions and discussions, LIDS could not have had so many great ideas.