About nixCraft

Topics

Ultimate Lighttpd webserver security

Posted by Vivek Gite [Last updated: December 27, 2007]

Lighttpd logo

So far, I have deployed over 35+ dedicated and VPS servers running lighttpd web server under Debian Linux, RHEL and Fedora Core Linux. It is a very common scenario where you read that xyz blog or site hacked (read as cracked). How you are going to prevent such problems? The ultimate solution or answer is use chroot() security feature - it allows you to build hard to crack web server. Put your lighttpd into chrooted jail. But, what is chroot on Linux?

A chroot on Linux or Unix OS is an operation that changes the root directory. It affects only the current process and its children. If your default Document Root is /home/lighttpd normal user can access files in /etc, /sbin or /bin directory. This allows an attacker to install programs / backdoor via your web server in /tmp. Almost all-cracking web based attacks/attempts requires a shell access - /bin/sh or /bin/bash and compiler collection etc.

Lighttpd security tips

Today I am going to write about the biggest security feature offers by Lighttpd - chroot() jail.

Running your lighttpd web server in chrooted jail has its own advantages and disadvantages.

With chrooting you use a special part of file system (also called as jail). Once the chroot called the application, no one access anything outside the jail. For example, consider following setup:

/
/bin
/usr
/home
/etc/
/webroot
   |-/tmp
   |-/usr
   |-/home/lighttpd
/tmp
/lib
...
...

When you start lighttpd web server, directory /weboot becomes the / (root) directory for lighttpd. Only the root user can escape the jail:
=> You
=> Your web server users
=> An attacker cannot access real file system and all other binaries.

The idea is quite simple if an attacker manages to get in via the lighttpd web server he will not have access to anything because he will be in jail. He cannot escape to real server (file system).


Index

Article so far in this series...

Tell us how we're doing: Please answer a few questions about your experience to help us improve nixCraft.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Colin Says:

    I have sudo enabled on a webserver I maintain; maybe it is not such a good idea. But the intruder would first have to be able to log into my account, no? I am the only user enabled in sudoers.

  2. nixcraft Says:

    Colin ,

    sudo removes the need of sharing root password. Another thing is login as root is not good idea (just imagine accidental rm -rf /). So it is a good idea to run sudo.

    Appreciate your post.

  3. reader87634576 Says:

    How is this a guide?
    Can you give more detail please? Maybe include some steps, how the root.document setting fits in, and how you chroot with cgi scripts etc. Thanks a bunch

    P.S. Anyone else have a good lighttpd chroot guide?

  4. nixcraft Says:

    reader87634576,

    It is here

  5. Arul Says:

    Can you give me information about security measures?

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.