Getting Started with the Linux Intrusion Detection System
This article assumes that you have installed LIDS and its associated administration tools.
We will set up a system with tight security settings, and the services that will be allowed to run are MySQL, Apache and Bind.
The sample commands below assume that the Apache installation resides in /usr/local/apache, with a log directory of /var/log/httpd, and also assumes your Apache configuration directory is /etc/httpd. MySQL is assumed to be installed in /usr/local/mysql. Obviously, you'll want to change the commands to suit your installation if it differs.
It is beyond the scope of this article to cover everything necessary to secure your system completely. However, these examples of how access control is administered in LIDS should get you started.
After you restart LIDS, you can begin adding access controls to various system binaries and libraries. The following sets the /sbin, /bin, /usr/bin and /lib to read-only:
lidsconf -A -o /sbin -j READONLY lidsconf -A -o /bin -j READONLY lidsconf -A -o /usr/bin -j READONLY lidsconf -A -o /lib -j READONLY
Next, we define some additional access controls for /opt, /etc and /usr/local/etc, which should be read-only, and we deny all access to /etc/shadow and the boot manager file:
lidsconf -A -o /etc -j READONLY lidsconf -A -o /usr/local/etc -j READONLY lidsconf -A -o /etc/shadow -j DENY lidsconf -A -o /etc/lilo.conf -j DENY
Because we have denied all access to /etc/shadow, the system will not be able to authenticate logins, thus we need to allow login and vlock to have read-only access to the file. Additionally, su also should have read-only access to the /etc/shadow file:
lidsconf -A -s /bin/login -o /etc/shadow -j READONLY lidsconf -A -s /usr/bin/vlock -o /etc/shadow -j READONLY lidsconf -A -s /bin/su -o /etc/shadow -j READONLY
We need to set some other access controls for su, in order for it to work with UIDs and GIDs, and access the /etc/shadow file:
lidsconf -A -s /bin/su -o CAP_SETUID -j GRANT lidsconf -A -s /bin/su -o CAP_SETGID -j GRANT lidsconf -A -s /bin/su -o /etc/shadow -j READONLY
Now, we need to allow init, login and associated applications to have write access to log files:
lidsconf -A -o /var/log -j APPEND lidsconf -A -s /bin/login -o /var/log/wtmp -j WRITE lidsconf -A -s /bin/login -o /var/log/lastlog -j WRITE lidsconf -A -s /sbin/init -o /var/log/wtmp -j WRITE lidsconf -A -s /sbin/init -o /var/log/lastlog -j WRITE lidsconf -A -s /sbin/halt -o /var/log/wtmp -j WRITE lidsconf -A -s /sbin/halt -o /var/log/lastlog -j WRITE lidsconf -A -s /etc/rc.d/rc.sysinit -o /var/log/wtmp -i 1 -j WRITE lidsconf -A -s /etc/rc.d/rc.sysinit -o /var/log/lastlog -i 1 -j WRITE
Now, we set up access control for root's home folder. We allow only the bash history file to be appended:
f -A -o /root -j READONLY lidsconf -A -s /bin/bash -o /root/.bash_history -j APPEND
Finally, we allow the init program to kill processes on shutdown:
lidsconf -A -s /sbin/init -o CAP_INIT_KILL -j GRANT lidsconf -A -s /sbin/init -o CAP_KILL -j GRANT
Now, we allow fstab and init scripts to mount filesystems, kill processes and unmount filesystems:
lidsconf -A -s/etc/fstab -o CAP_SYS_ADMIN -j 1 -j GRANT lidsconf -A -s /etc/rc.d/init.d/halt -o CAP_INIT_KILL -i 1 -j GRANT lidsconf -A -s /etc/rc.d/init.d/halt -o CAP_KILL -i 1 -j GRANT lidsconf -A -s /etc/rc.d/init.d/halt -o CAP_NET_ADMIN -i 1 -j GRANT lidsconf -A -s /etc/rc.d/init.d/halt -o CAP_SYS_ADMIN -i 1 -j GRANT
Apache needs to have setuid and setgid capabilities. We also need to allow Apache to access log files and deny other applications from accessing the httpd binary:
lidsconf -A -s /usr/local/apache/bin/httpd -o CAP_SETUID -j GRANT lidsconf -A -s /usr/local/apache/bin/httpd -o CAP_SETGID -j GRANT lidsconf -A -o /etc/httpd -j DENY lidsconf -A -s /usr/local/apache/bin/httpd -o /etc/httpd -j READONLY lidsconf -A -o /usr/local/apache -j DENY lidsconf -A -s /usr/local/apache/bin/httpd -o /usr/local/apache -j READONLY lidsconf -A -o /var/log/httpd -j DENY lidsconf -A -s /usr/local/apache/bin/httpd -o /var/log/httpd -j APPEND lidsconf -A -s /usr/local/apache/bin/httpd -o /usr/local/apache/logs -j WRITE
|Designing Electronics with Linux||May 22, 2013|
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
- Linux Systems Administrator
- New Products
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Have you tried Boxen? It's a
4 hours 29 min ago
- seo services in india
9 hours 52 sec ago
- For KDE install kio-mtp
9 hours 1 min ago
- Evernote is much more...
11 hours 1 min ago
- Reply to comment | Linux Journal
19 hours 47 min ago
- Dynamic DNS
20 hours 21 min ago
- Reply to comment | Linux Journal
21 hours 19 min ago
- Reply to comment | Linux Journal
22 hours 9 min ago
- Not free anymore
1 day 2 hours ago
1 day 5 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?