Hardening LILO Against Unauthorized Access

June 24, 2002, 11:00 PM —  ITworld — 

Like most programs, the Linux kernel itself can take 'command line'
arguments. These arguments can be specified when you select your kernel
at boot time, for example:

lilo: linux single

The command above tells lilo to run the Linux kernel with the argument
'single', which means single user mode. In this situation, linux will
load and enter run state 1. (In fact, you could have said '1' instead of
'single'.) In single user mode, the root filesystem is mounted
read-only, the network isn't initialized, and no daemons are running.
It's the perfect situation for you to fix problems that are keeping your
machine from booting.

When you enter single user mode, you are automatically dropped into a
root shell, without typing a password. Unfortunately, anyone with
physical access can easily get a root shell his way.

This problem has two solutions:

1) Configure lilo to prevent folks from sending arguments to the
kernel at the lilo prompt.
You specify 'restricted' in the image specification and pick a
password. They can still choose to boot this image, but they cannot boot
send it command line options unless they know this password. Your image
definition will look something like this:

image=/boot/vmlinuz
label=linux
restricted
password=SuperSecretPassword
read-only
root=/dev/hda7

If you choose this method, make sure you:

# chmod 600 /etc/lilo.conf

This prevents users from reading the password. Then re-write your lilo
configuration with:

# lilo

2) Force root to type the root password, even when entering single
user mode.
This involves running sulogin when the machine enters run level
zero. Add the following to /etc/inittab:

~~:S:wait:/sbin/sulogin

This command tells init (the first process that starts when linux is
booted) to run the sulogin program automatically. sulogin prints the
following to your tty:

Give root password for system maintenance
(or type Control-D for normal startup):

If you know the root pw, you are dropped to a root shell. If not, then
sorry -- no root for you.

It's important to remember that this method handily prevents you from
entering your own system in single user mode if you forget the root
password! [1]

NOTES

[1] If sulogin determines that there is no usable root password in
/etc/shadow or /etc/passwd because the files have been horribly mangled,
then it will give you root access automatically because no valid
authentication is possible.

» posted by ITworld staff

ITworld

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Free stuff

Win an Amazon Kindle!
This month's giveaway gadget - Amazon's Kindle - will keep you entertained on the long trip home to visit family and friends over the holidays. Enter the drawing now!

Applied Security Visualization
By Raffael Marty
Published by Addison-Wesley Professional
Learn more!

 

IT Manager's Handbook
By Bill Holtsnider and Brian D. Jaffe
Published by Morgan Kaufmann
Learn more!

 

Windows Vista Resource Kit
By Mitch Tulloch, Tony Northrup, and Jerry Honeycutt
Published by Microsoft Press
Learn more!

Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

More Resources