Slashdot Mirror


Using OpenBSD's chrooted Apache

BSD Forums writes "OpenBSD recently changed the mode of operation for the Apache webserver from the normal non-chrooted operation to chrooted operation. This enhances the security of the server on which Apache is run but it imposes a few challenges to the system administrator. In this article Marc Balmer discusses selected aspects of running a chrooted HTTP daemon and present strategies on how to set up a chrooted environment for more complex applications like database access or using CGI-scripts."

101 comments

  1. slashdotted by mAIsE · · Score: 1, Insightful

    does this PDF have a mirror, or an HTML link ?

  2. Challenges? by Anonymous Coward · · Score: 0, Flamebait

    Challenges for the system administrator? Look, each day, billions of people are starving to death worldwide, and Slashdot has an article about the challenge of chrooting a web server or something. Way to go.

    All those dead children have you to blame, Taco.

    1. Re:Challenges? by Anonymous Coward · · Score: 0

      Yeah, we should just sit back and do nothing and die, just to feel sorry for those others, right?

    2. Re:Challenges? by Pholostan · · Score: 1

      No, you should offer your body to be eaten by them. You die, but they live.

      Just kidding. It is interesting though, that people die very day who most really wants to live, but are unable to do anything to survive. All those people willing to live, while I have practically everything but can't get out of bed in the morning, mutch less summon any will to live. Ironic.

      --

      Everybody knows that we are the evil boys, making noise with deadly toys.
  3. Slashdotness... by st0rmcold · · Score: 1


    My peave with pdf's is the size, slashdotted in 15secs instead of 45secs.

    Dramatic in the slashdot community.

    --
    Posting useless rant since 2003.
  4. recently? by jdew · · Score: 1

    this was done with the introduction of 3.2. 3.3 will be out shortly. As in May 1st. ._.

  5. Security v. ease of use by unterderbrucke · · Score: 3, Insightful

    Security should always win, but it never does.

    Just my .02 cents.

    1. Re:Security v. ease of use by Anonymous Coward · · Score: 0

      Above post moderated as troll? Come on, guys..

      Anyways, I agree with your statement, but enhancing security is always a good thingie. I doubt that the OpenBSD crew claims that this apache patch is the ultimate security solution, but I'm pretty sure they think it's more secure than what's default.

      The guys behind OpenBSD are SERIOUSLY GOOD programmers who really know what they're doing!

    2. Re:Security v. ease of use by mivok · · Score: 1

      Now I'd have thought that in this case, it is security that is winning out over the ease of use of having older httpd.conf files work.

    3. Re:Security v. ease of use by baywulf · · Score: 1

      "Security should always win, but it never does."

      If that were really true then why don't you shut down you computer? It would certainly make it much more secure at the expense of ease of use?!

    4. Re:Security v. ease of use by Anonymous Coward · · Score: 0

      "The guys behind OpenBSD are SERIOUSLY GOOD programmers who really know what they're doing!"

      Yea with regards to security. At the same time the rest of the distro suffers with zero effort put into ease of use.

      Who cares if its the most secure thing going if it takes a genius to operate it? Most people would be better off using Red Hat and selecting "High Security".

      Until one/any of the BSD's actually makes an effort to cater to someone else besides the snobbish elite users it caters to now, it will continue to miss out will linux will continue to dominate it.

      You bsd users are always saying how much better bsd it compared to linux, but do nothing to try to compete. Maybe its the fear that if you make easier to use someone will just steal your work and redistribute it?

      There is more to modern computing then just being secure or stable.

    5. Re:Security v. ease of use by Marillion · · Score: 1

      I agree with that right up to the point where the difficulty in use prevents an administrator from doing the right thing.
      Security should be easy to implement and difficult to circumvent.

      --
      This is a boring sig
    6. Re:Security v. ease of use by ClayDowling · · Score: 1

      Security is important and all, but the choice between security and usability isn't an absolute. The greatest security for my web site would be to burn it onto a CD and chroot the server to that CD. That's not practical though when I'm using the website to demonstrate and sell content management systems. So I need to compromise my security a bit to allow the server and the CGI programs that it spawns to write to certain files or directories. It's less secure than my burned-on-a-cd option, but fits my needs better.

    7. Re:Security v. ease of use by 0ptix · · Score: 1

      just migrating from linux -> openbsd and all i have to say is: cd /usr/ports/bla/foo make install or maybe just pkg_add foo.tgz i dont know. doesnt get much easier then that. i think its just a matter of what one is familier with. about the only complaint i have with (open)bsd so far is the instalation (mainly the formating of the HD was not intuitive). that really is kinda crude, but apart from that.... not so evil really. but please correct me if i am wrong. lets have examples mind you... not just vague complaints or comments... after all i do wanna learn! :-) (actualy i am just trying to decided between a grsecurity enhanced linux box and an openbsd box for a secure firewall, gateway and webserver... so this is pretty relevant. the point is it should be maintainable by a nonexpert as well once setup properly...)

    8. Re:Security v. ease of use by Anonymous Coward · · Score: 0

      http://www.openbsd.org/goals.html

      There is nothing on there about ease of use or competing with Linux or replacing any other system.

      "Maybe its the fear that if you make easier to use someone will just steal your work and redistribute it?"

      There is no need to steal it. That is one of the great parts of FREE software.

    9. Re:Security v. ease of use by Ruzty · · Score: 2, Insightful

      Competing is the not the goal. The goal is a highly secure OS capable of doing everything the development team and core user base want it to do. Having others able and desiring to use OpenBSD is a secondary concern driven by a need for funding to continue development.

      OpenBSD does not cater to "Joe User" nor does it claim to. You are correct, Joe User should be using something that gives more direction and simplifies their experience such as RedHat.
      -Rusty

      --
      The Master (Angelo Rossitto) in Mad Max Beyond Thunderdome, "Not shit, energy!"
    10. Re:Security v. ease of use by Anonymous Coward · · Score: 0
      If that were really true then why don't you shut down you computer? It would certainly make it much more secure at the expense of ease of use?!

      You're confusing "ease of use" with "use".

      For any given project, you need strict goals to guide your decision making process. "we will have apache in tree, it will be capable of doing cgi, virtualhosts, etc. We will have strong security.". Implement that but it gets more confusing to admin correctly, other OS's might say "ok, forget security", OpenBSD says "ok, forget admins unwilling to Work and Learn".

    11. Re:Security v. ease of use by chrisseaton · · Score: 1

      "Just my .02 cents."

      That's not a lot of cents. I really love it when people go as far as to put

      "Just my USD $0.02"

      Wankers.

  6. site is /.'ed by rf0 · · Score: 2, Informative

    So as I can't comment on the article itself I thought that it might be mentioning that chroots are good but no infalliable. If someone can get root permission inside a chroot you can break out

    Rus

    1. Re:site is /.'ed by jolan · · Score: 5, Informative

      Yes, if someone gets root, then they can most likely break out of chroot.

      Thankfully, under OpenBSD even the apache parent process does not run as root:

      www 2376 0.0 0.3 1120 1440 ?? Ss Wed08PM 0:05.56 httpd: parent [chroot /var/www] (httpd)
      www 12097 0.0 0.2 1196 1008 ?? I Wed08PM 0:00.02 httpd: child (httpd)

      This means "remote root exploit" in Apache becomes "remote www-user-in-chroot exploit" for OpenBSD.

      It's a very nice feature. I wrote a document on how to get CVSWeb running within the Apache chroot environment recently. I'm guessing Marc's paper is somewhat similar in nature.

      http://marc.theaimsgroup.com/?l=openbsd-misc&m=1 04 900672827459

    2. Re:site is /.'ed by Anonymous Coward · · Score: 0

      What do you have to do to get Apache's parent to drop root if you're not fortunate enough to be running OpenBSD? I always wondered what it's doing with those permissions once it's already started up and bound the privileged port.

    3. Re:site is /.'ed by tdemark · · Score: 1

      Set the 'User' config param to a non-root user:

      User apache
      Group apache

      Apache will bind as root and then drop privs to the named user.

    4. Re:site is /.'ed by Anonymous Coward · · Score: 3, Informative

      Apache will bind as root and then drop privs to the named user.

      No, it won't. Build it from source, put that in the config, start it as root, and look again. The parent is still running as root.

      root 1040 0.0 0.2 2644 156 ? S 2002 0:00 /usr/local/apache/bin/httpd

      It needs to bind port 80. OK, so bind the port and then drop privs. It needs to control the logs so that the evil children don't touch it. OK, so change to a different user (other than the network-listeners). Anything but root!

      I realize there are other uses for root in Apache. Maybe you want to play games with running CGI programs as different users. That's all well and good, but that's still no reason to default to running as root.

      Don't think Apache's priv-sep situation is perfectly sound, either. There was an odd little hole last year that let the unprivileged children whack arbitrary processes with SIGUSR1 through their privileged parent. No root = fewer worries.

    5. Re:site is /.'ed by tzanger · · Score: 1

      If someone can get root permission inside a chroot you can break out [bpfh.net]

      Sure, but then again who in their right mind runs a web browser, ftp server, cvs site, news server, name server or practically any server as root anymore?

    6. Re:site is /.'ed by Ded+Bob · · Score: 1

      The site reports that the code to break out works on Solaris and Linux. No mention is made of OpenBSD. It does say that FreeBSD is not vulnerable to the attack.

  7. Hey - you guys broke my httpd.conf file! by dragonfly_blue · · Score: 5, Interesting
    I admittedly hadn't been paying much attention to the changes, but this one crept up and bit me on the ass last week while I was setting some new web servers for our ISP.

    It seems the chrooted Apache configuration in 3.2 is turned on by default, and it prevents cgi mappings from working properly under VirtualHosts directives. I was kind of aggravated; it took a while to figure out what was wrong.

    It's documented in the OpenBSD FAQ, but I couldn't pinpoint the problem to OpenBSD specifically (and the error log was mysteriously unhelpful at diagnosing the problem), so I spent quite a while reading up on Apache directives before I figured it out.

    It was frustrating, but I know Apache considerably better now, so I guess it was worth it. I agree that security is very admirable, which is why I use OpenBSD in the first place, but I think certain options should be turned off by default, especially if they break common services like VirtualHosts cgi ScriptAliases.

    Realistically, are most web servers going to be set up just to host one web site? Or am I the only one who uses VirtualHosts on most of my servers?

    --
    Free music from Jack Merlot.
    1. Re:Hey - you guys broke my httpd.conf file! by rf0 · · Score: 1

      I use virtualhosts a lot. Due to the relativtly scarce number of IP addresses left people like Arin and RIPE aren't that happy about issues a unique IP address for each site. The only time you really need it is if you are using SSL

      Rus

    2. Re:Hey - you guys broke my httpd.conf file! by ostiguy · · Score: 4, Informative

      Honestly, this is one of the most touted changes to OpenBSD 3.2 - it was absolutely everywhere on the misc@ list, it is in the FAQ, it is the #3 bullet point under the "What's New" page for the 3.2 release. There is really no excuse for not knowing it was coming, and thus knowing it would be a likely reason for old configs to not work

      ostiguy

    3. Re:Hey - you guys broke my httpd.conf file! by jdew · · Score: 1

      in /etc/rc.conf: httpd_flags="-u"

    4. Re:Hey - you guys broke my httpd.conf file! by greenalbatros · · Score: 2, Insightful


      the relativtly scarce number of IP addresses left


      roll on ipv6

      --
      this sig steers like a cow. and i can prove it
    5. Re:Hey - you guys broke my httpd.conf file! by pkplex · · Score: 1

      I installed my first public OpenBSD server yesterday :) Never gave thought to the VirtualHosts side of it, I would imagine its straight forward to impliment though.. a bit of re-partitioning and re-mountage I guess.

      What I really wanted to say though, Is that I like OpenBSD very muchly :) Anyone interested in a quality, clean, correct, warm and fuzzy OS should try OpenBSD. It kicks ass.

    6. Re:Hey - you guys broke my httpd.conf file! by psxndc · · Score: 2, Funny
      but I think certain options should be turned off by default

      If you want a web server that has security features disabled by default, there are other options.

      ;-P

      psxndc

      --

      The emacs religion: to be saved, control excess.

    7. Re:Hey - you guys broke my httpd.conf file! by Anonymous Coward · · Score: 0

      I think certain options should be turned off by default

      It takes two characters to turn it off.

      Defaults should be set for the majority of users. If the majority of users don't use VirtualHosts (probably), why should their security be lowered by default for the few of you that do?

    8. Re:Hey - you guys broke my httpd.conf file! by dolmant_php · · Score: 1

      There's also a fairly obvious comment in rc.conf:
      # use -u to disable chroot, see httpd(8)
      httpd_flags=NO # for normal use: "" (or "-DSSL" after reading ssl(8))

  8. Marc's Bro by Anonymous Coward · · Score: 3, Funny

    Marc must be such a disappointment to his big brother Steve...

  9. I would have liked to read the document... by HogGeek · · Score: 1
    But due to the really slow down load, and then then file being corrupt (according to my pdf reader).

    I'm not trying again...

  10. Recently ? by dnaumov · · Score: 4, Informative

    This isn't exactly a recent change, I believe this happened over 6 months ago...

  11. Or kid by Anonymous Coward · · Score: 0

    I was thinking maybe that was Steve's rebellious teenage son, trying to spite his old man like so many kids do.

  12. Apache 2 by zmcgrew · · Score: 1

    I kept the chrooted Apache availible, I just don't ever start it or use it.
    Instead, I installed Apache 2.
    But considering I'm not doing any mission critical stuff -- I'm really not too worried.
    Perhaps all I have to worry about now is getting the speed of my CGI scripts up... But maybe that's just because they're running on a Pentium 100. =)

    Rock on OpenBSD!

    --
    Location: Mt. Xinu
  13. OpenBSD in the news by ch-chuck · · Score: 1

    Spotted this on the list: U.S. Military helps fund Calgary Hacker

    --
    try { do() || do_not(); } catch (JediException err) { yoda(err); }
  14. Performance hit? by mnmn · · Score: 2, Interesting


    I wonder if this inflicts a performance hit, or more memory is required as a result. I know more disk space is needed, but with the smallest IDEs these days being 40GB, I'm not worried there.

    If theres really no performance hit, I wonder if all daemons can be run in seperate chroots, indeed could an inetd be developed that chroots all its daemons. Necessary readonly stuff like libc might be hard-linked rather than copied to save space, unless that would be too much of a security breach.

    My very-lazily setup FreeBSD server never gave me problems, and I wouldnt be implementing this in my production server yet, but its nice to HAVE DONE stuff like this to:
    (1) boast
    (2) print on resume
    (3) profit!

    --
    "Give orange me give eat orange me eat orange give me eat orange give me you." -Nim Chimpsky
    1. Re:Performance hit? by QuMa · · Score: 3, Informative

      This is where linux bind mounts come in handy, you can bind mount your /lib and /usr/lib into all your chroots (just make sure they don't contain suids or anything :) ), that way all libraries will only go into memory once, even when used from multiple chroots. (of course you can olso have all your fake roots on the same filesystem and hardlink, but this is a lot nicer)

    2. Re:Performance hit? by stab · · Score: 1

      The OpenBSD Apache chroot()s after its been run, so it loads all the libraries and modules as normal; no need for fancy mounts or copying libraries into the chroot.

    3. Re:Performance hit? by Skapare · · Score: 2, Informative

      Even bind mounts are not secure. They can be remounted read/write, assuming they were read-only to begin with. One way to be sure that can't happen is to have the filesystem so mounted be a loopback to a file which resides on a filesystem which is mounted read/only. That underlying filesystem cannot be changed from inside the chroot (because there is no mount point therein to reference it), so even if the loopback mounted filesystem is made read/write, write attempts should ultimately fail (but even this could be exposed by a bug I don't know about, if one exists).

      Modular programming (and dynamically loaded libraries are a form of modularity) just doesn't mix well with security.

      --
      now we need to go OSS in diesel cars
    4. Re:Performance hit? by QuMa · · Score: 1

      If the attacker has root you're dead anyway,
      mkdir foo; chroot foo; cd ..

  15. Running it chrooted isnt allways a useful option. by geesus · · Score: 2

    At home I run the chrooted version under 3.2, and it would be good for doing a standalone, non cgi single site delio. when you start to add more vhosts and what not, you have to make sure that they are in the chroot as well. this isnt allways desireable, especially from an ISP point of view for customers sites, most ISP's I know keep thier customers sites in ~/public_html/ . But it just goes to show that openbsd's whole secure by default persona is in effect.

    --
    Gnome wasnt built in a day.
  16. Broken chroot implementation? by Anonymous Coward · · Score: 0

    Hi guys.

    Just wondering, it seems the OBSD chroot implementation can be broken out of.

    I first noticed it here.

    And the concept code, which is pretty standard, is here.

    Please explain!

    1. Re:Broken chroot implementation? by Anonymous Coward · · Score: 0

      what a [i][b]secure[/b][/i] os!

    2. Re:Broken chroot implementation? by Skapare · · Score: 1

      There are certain things that have to work inside chroot for it to remain usable for the things it was originally designed for, which includes building new systems. Those things that are designed to fail (e.g. pass the test) in grsecurity's system, which fail the test (e.g. the code still works) on the others, are needed for many use that chroot is used for. For example you can't make a new system without being able to use mknod and use the device made in that run. And that's a capability which can be abused.

      The problem is people are trying to take something that seems like it might have been intended for security (chroot), which never was, and trying to impose on it a more complete set of semantics that would force it to be usable for security, breaking the original purpose. Instead, what should be done is create an entirely new tool. FreeBSD has the jail feature which is a sort of "chroot on steroids". And Linux has "User Mode Linux" which allows running a whole kernel in user process space.

      My point is, chroot was never intended to be secure. Shame on those who ever expected it to be so.

      --
      now we need to go OSS in diesel cars
  17. Why BSD? by Anonymous Coward · · Score: 2, Insightful

    (No this isn't a lame BSD troll). Chrooted Apache might be the default on OpenBSD, but this is still information everybody can use. However, judging by the number of posts, as soon you label it 'BSD' it seems most of the (probably Linux-centric) Slashdot readers eyes glaze over, and they never read it (or they post several copies of the 'BSD is dying troll..)

    Yes, it is their loss -- but generally applicable topics that just happen to be demonstrated on a BSD really should not be tagged 'BSD' in the Slashdot topic heading IMHO. They should be tagged according to the topic (Say, Apache, in this case).

    1. Re:Why BSD? by Nickus · · Score: 2, Informative

      AFAIK this is not information everybody can use since this feature only exists on OpenBSD. Apache is patched to chroot() to it's own folder. The -u flag does not exist on standard Apache.

  18. Does anyone have a bittorrent of the pdf? by Idimmu+Xul · · Score: 2, Insightful

    Doing something like this in future as standard could conciderably reduce the /. effect!

    --
    The problem with slashdot is that most of its users were bullied and stuffed into lockers as kids!
    1. Re:Does anyone have a bittorrent of the pdf? by CTho9305 · · Score: 1

      That is a REALLY good idea.

  19. openBSD features by pzilla · · Score: 2, Funny

    Neat! I hope FreeBSD and NetBSD use this feature when they all merge.

    Looking forward to it. ;)

    --

    --
    Karma is overrated, whoring is ok.
  20. Re:*BSD is dying by usotsuki · · Score: 1, Insightful

    Opinion: BSD is dying

    Let's put it this way, BSD will not die as long as MacOS X exists. Plus note, it's not about the market share if you can grok the source code!

    -uso.
    BSD r0x0r!

    (Yeah, I know, I'm -1 Offtopic.)

    --
    Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
  21. Why don't the various Linux Dists... by Greyfox · · Score: 4, Interesting

    I've always wondered why the various linux dists don't contain -chroot packages of the various servers that support the chroot environment. Running that way would at least make it a bit more difficult to compromise your system when those inevitable remote exploits are found. If you package them separately, the administrator could choose which ones to run (Though that's not always a good thing.)

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    1. Re:Why don't the various Linux Dists... by jdew · · Score: 1

      Same deal with propolice really..

      from what im told:
      gentoo comes with propolice, but its turned off by default "because some things break"

      in openbsd 3.3, propolice is turned on by default "because some things break"

      =D

    2. Re:Why don't the various Linux Dists... by Dausha · · Score: 1

      Sounds like we need to create a distribution called 'OpenLinux' . . .

      --
      What those who want activist courts fear is rule by the people.
    3. Re:Why don't the various Linux Dists... by the-dude-man · · Score: 1

      Well alot of the various linux distros really blow hard.

      The only one that dosnt, is gentoo. Its actually on a pretty level playingfield as freeBSD.

      Gentoo uses the ports collection, so you can get your chrooted packages off of there. But alot of times they dont run chrooted by default. This is changing at a good rate (in gentoo at least). When i do an overnight emerge, when i merge in etc-update i am finding that my chroot config directives are getting overwritten by the new config data more and more now.

      But then agian, if you install a service avialable to the world, and just go with the default configureation without at least checking to make sure its good.....you deserve what you get :)

    4. Re:Why don't the various Linux Dists... by Anonymous Coward · · Score: 0
      I've always wondered why the various linux dists don't contain -chroot packages of the various servers that support the chroot environment.



      Linux distributions aren't designed to be secure by default. Most Linux distributions are focused on being easy to use (a mistake, IMNHSO).

  22. huh huh huh by Anonymous Coward · · Score: 0

    you said... root

  23. Mirror by SonCorn · · Score: 2, Informative
    --
    What good is a used up world, and how could it be worth having? --Sting
  24. Mirror by rf0 · · Score: 2, Informative

    I've put up a mirror here

    Rus

  25. Breaking a Chroot by elemur · · Score: 3, Informative

    I couldn't say if it protects against the exact source code listed on that site, but there is a set of kernel security modules which *greatly* protects against these sorts of attacks. The modules are at http://www.grsecurity.org/, and are a wonderful addition to any linux server.

    It protects against raw devices, special chroot attacks, UID escalation attacks, many buffer overflows, and other problems. In addition, it adds a whole ACL (Access Control List) system for protecting applications and the overall environment. For a full list of features go to http://www.grsecurity.org/features.php.

    I've used this on many different servers with no problems at all. It certainly make you feel better on those servers directly connected to the net.

  26. Why is there an "Apache" user? by mcrbids · · Score: 3, Interesting

    The basic problem isn't that Apache runs as "userX" or "userY" or even "root", it's that it ONLY runs as user "apache"!

    If I have 100 clients using a web server, there's no way for me to protect their stuff from each other. NONE.

    It doesn't matter what permissions I apply. I can run PHP in "safe" mode, and apply bandaids to the problem to mitigate this weakness, but it's still there.

    Maybe make apache run under xinet.d. (Gee, there goes the "must run as root" problem!) Maybe just have a connection process that connects to an actual daemon for performance reasons.

    But Apache should run as the user that owns the site being accessed!

    Imagine this in your httpd.conf:

    <VirtualHost *>
    ServerName www.clientsite.com
    ServerAlias clientsite.com
    DocumentRoot ~client/html
    RunAsUser client ... logging, etc.
    </VirtualHost>

    If done right, you should be able to chroot user "client" and have the DocumentRoot be relative within the chrooted file system!

    This is a feature of 2.x that is the *only* feature I'm looking forward to. And yet, for some reason, it's on the back burner. It's "unstable", or "in progress". In short, it still sucks.

    So we continue to run in an inherently lame-brained environment with security leaks all over the place, with this "unpriveledged user" (typically "nobody") that has more permissions than any other user save root.

    Ugh.

    --
    I have no problem with your religion until you decide it's reason to deprive others of the truth.
    1. Re:Why is there an "Apache" user? by larien · · Score: 1
      Yes, it would be very nice but very difficult to implement given Apache's model and how that runs under Unix.

      Essentially, by the time you've figured out which vhost the client is requesting, you're bound to a specific httpd process which normally runs as www/nobody or whatever you've configured it as. As those users cannot setuid to the RunAsUser, you can't modify the uid/euid at that stage, only root can do that and you don't want root handling that part of the negotiation!

      The alternative is to run with different config files binding to different IPs or ports and run multiple versions of Apache at the same time, but that loses you some advantages of load balancing between virtual hosts.

      Something like a proper trusted base allowing a user (www) to setuid to other users (vhost1, vhost1 etc) but that requires a version of Unix that supports it; dunno if Trusted Solaris, OpenBSD or SELinux supply that functionality or not.

    2. Re:Why is there an "Apache" user? by Skapare · · Score: 1

      I've always set up Apache so CGI runs as the user who owns the site. The problem is, that requires retaining the permission to switch to that user somewhere, even if just within the "suexec" file (is suid root).

      The problem with Apache is that it is so large, and so much code would run as root, that it is unsafe to allow that. So the usual course is to run Apache non-root, and let "suexec" do the permission switch. Supposedly it can verify if it is being run correctly from the Apache process (as opposed to from any other) by means of a passed random number it can read from a file only Apache could write. But I never have really verified how that works, and shame on me for not doing so.

      At some point we just have to trust some code to do the right thing with the permissions granted to it. I for one can't grant that trust without being able to read and understand the code. And Apache is just too much for that.

      Perhaps the whole model of a multi-user shared daemon is all wrong. Maybe users should have to each run their own instance of Apache on separate IP addresses (they have to if they want to run an HTTPS secured web site, anyway).

      --
      now we need to go OSS in diesel cars
    3. Re:Why is there an "Apache" user? by cras · · Score: 3, Informative
      Essentially, by the time you've figured out which vhost the client is requesting, you're bound to a specific httpd process which normally runs as www/nobody or whatever you've configured it as. As those users cannot setuid to the RunAsUser, you can't modify the uid/euid at that stage, only root can do that and you don't want root handling that part of the negotiation!

      You use multiple processes then. You can pass the socket file descriptor to another process via UNIX sockets. Or you could just keep proxying the connection to another process if you want portability.

      For example you could have a few "connection broker" processes which would parse the initial request. That process would figure out who exactly should be handling the request. Once that's done, it sends very simple request to very small master process which runs as root, consisting of wanted url handler (file, directory, whatever). The root running process verifies the handler is valid, and then either returns error or forwards the connection to the actual handler process (either exec + setuid(), or reuse existing process).

      Something like a proper trusted base allowing a user (www) to setuid to other users (vhost1, vhost1 etc) but that requires a version of Unix that supports it; dunno if Trusted Solaris, OpenBSD or SELinux supply that functionality or not.

      There's at least kchuid which could do that.

    4. Re:Why is there an "Apache" user? by thx2001r · · Score: 1

      Maybe users should have to each run their own instance of Apache on separate IP addresses (they have to if they want to run an HTTPS secured web site, anyway).

      Of course, this negates the whole point of IPv4 address conservation that name-based virtual hosts afford.

      What if you could do name-based virtual hosting with each user running their own instance of Apache (using a single IP for Port 80 virtual hosts (machine-wide), which is probably most of what is on the server anyhow)? Port 443 virtual hosts will need their own IPs anyhow.

      Anyone know if that's doable, and if so, how?

      Of course, the other option is to run all web sites as "users" (http://yoursite.net/~username/) instead of virtual hosts. Then you can force users to run cgis through a cgi-wrapper like CGIWrap. Needless to say, this is not suitable for an ISP environment and for people / organizations that own their own domain names.

      --

      -Joe
      If we're all god's children, what's so special about Jesus? - Jimmy Carr

    5. Re:Why is there an "Apache" user? by Skapare · · Score: 1

      Sure, it is doable to have a single IP working HTTP requests by name and have each site or group of sites (same user) have a dedicated server. I don't know how easy it could be retrofitted into Apache, but certainly one way to do this is to have a front end like a proxy that checks the host of the request and routes the request accordingly. Maybe that could be routed to a different port number according to a configured map. But I would be more inclined to route the requests to a named pipe in the filesystem.

      --
      now we need to go OSS in diesel cars
    6. Re:Why is there an "Apache" user? by mcrbids · · Score: 1

      I see a number of comments in this thread.

      Anybody who says "it can't be done" is simply wrong. It can obviously be done, in a number of ways, with minimal repurcussions.

      I'd almost give a left nut for something like this that actually worked.

      So why hasn't it been done?

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    7. Re:Why is there an "Apache" user? by cras · · Score: 1
      So why hasn't it been done?

      Want to pay for it? ;) I've thought a few times that this would be interesting to do, but I already have other projects and I don't actually need it.


    8. Re:Why is there an "Apache" user? by Anonymous Coward · · Score: 0

      I'd almost give a left nut for something like this that actually worked

      Depending on your definition of "work", it's exactly what IIS does.

  27. KNOWN OUTWAR POSTER! MOD PARENT DOWN!! by Anonymous Coward · · Score: 0


  28. Re:*BSD is dying by Daimaou · · Score: 1

    That good and all, but who can trust a liar? :)

  29. Re:*BSD is dying by usotsuki · · Score: 1

    I see you translated my name. *g*

    -uso.

    --
    Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
  30. It's nice but.... by Lagos · · Score: 2, Insightful

    I've been setting up an OpenBSD web server for the past few days now, and had some time to finagle with chroot Apache. I've found it to be a wonderful idea that I've had to disable.

    Why? No fault of OpenBSD, really. Simply that in order to do anything really interesting, I had to disable the chroot of httpd. Take perl scripts, for example: If a CGI script is supposed to be interpreted by /usr/bin/perl (as indicated with #!) it will fail unless you've placed a copy of the perl interpreter in the chroot environment. You can get around this with mod_perl to embed a perl interpreter directly into Apache, but one still will have to preload any shared libraries mod_perl uses (see section four of the paper).

    As another example, PHP's mail() function [which is fairly important, I feel] relies on the presence of sendmail. Sendmail then, must be accessible from the chroot directory in order to work.

    Someone above has commented that you can mount /usr in the chroot environment to solve most of these problems. But of course, as the paper says, the more binaries in the environment, the lower the security, so one must make sure there is no setuid binary available.

    Ultimately, the paper does describe ways around this, basically preloading any shared library your Apache modules might need and populating the chroot jail with any binaries you want for CGI and their shared libraries. This mirroring however requires a good deal of maintenance and waste of space (following OpenBSD partitioning recommendations, /var and /usr will be on seperate partitions so hardlinks won't work. Symlinks can't break out of chroot). At this point, I think a lot of us will be unwilling to sacrifice simplicity (read: stability, maintainability) for this measure of security. The argument that this only affects those who CGI scripts is very correct, but ultimately a trivial point: To do anything interesting (like Slashdot) requires CGI.

    The situation will get better, though, and they'll find a simple elegant maintenance system, as OpenBSD always has. Some things have to change: For example /etc/rc.conf is currently insufficient for preloading libraries. It should have an additional directive called httpd_preload for shared libraries. Also, apachectl may need to be modified or supplemented on OpenBSD.

  31. Nice for some by the-dude-man · · Score: 2, Interesting

    I kind of like this idea. It moves more towards having a seperate enviornment from the operating system enviornment. Wich i like because i like to keep my http users as far away from the system as possible.

    Using grsecurity kernel patch, i can use trusted path execution and take execution privlages away from the apache group, and set its gid = 1005 (or whatever you specified under trusted path execution for the untrusted group in the grsecurity options) and then only give apache execute rights on specific things...(ie pearl, java...etc). Howrever, this way, i only need to give apache execute rights on basically just apache, and run everything else from within the chroot. It makes my life much simplier. Not having to go and find all the intpretures that it needs access to, or the vms, giving them those rights, and then playing around with the directory structure to make sure apache cant just freely roam the system.

    It does take more space, but i think its worth it. When i set up a webserver for a client, my biggest worrys are not known exploits, i can write a script to go and patch that for me. Hell in gentoo i write a line of bash and put it in my crontab and i never worry about known exploits agian. What i am more worried about is someone hitting me with a exploit that is not known. So if some sort of bufer overflow happens. At worst, i will lose the http service. But i can have a replication service running if its really a concern. So thats not much of an issue. However, what is an issue is people getting outside of the http service with buffer overflows. the grsecurity kernel patch, enforcing non executable pages and stacks, is nice, and does a good job at stopping buffer overflows, however, this chroot thing i find intergrates nicely into the extra levels of security i put in.

  32. The myth of chroot security by Python · · Score: 1
    Aside from all the very valid reasons everyone else has pointed out as to why various distributions do not chroot more services, there is one more: chroots, on many OSes (OpenBSD, Solaris, FreeBSD and default Linux kernels) are actually not that hard to escape from. With this in mind, some may consider chroots to have marginal value at best and at worst, they can create a false sense of security.

    For instance, there are several ways to get out of a chrooted environment that have been known for years. Futhermore, the means to correct many of these problems has also been known and available in patch form for years. Yet, all of the afore mentioned UNIXes have failed to make these fixes part of their vanilla kernel trees. Thankfully, there are external patches that fix these problems for some OSes (Linux for instance), but they are not fixed in the default kernels of many distributions, including OpenBSD 3.2, Solaris, FreeBSD and Linux. Here is just a partial list of the known ways of escaping or circumventing a chroot:

    double chroot
    fchdir
    Attaching to shared memory outside of the chroot, that can be fun.
    mknod (Oh boy! Make whatever you want inside the chroot!)
    And of course, Raw I/O. Nothing stops you from doing that in a chrooted environment.

    So, before you assume that chrooting something will add X amount of security to your system, understand that most kernels (Solaris, BSD and Linux) allow for many widely known ways of escaping a chrooted environment and even making the chroot environment irrelevant by still affording an attacker too much control over the box.

    Its still admirable to see more services being configured to run in a chrooted environment, but until more kernels are modified to make chroots stronger and to close these holes, the security they create can just be an illusion at best. I'm not advocating that services not be chrooted, but rather that OSes fix many of these issues and that users understand the limitations of chroots as a security tool until that happens.

    --

    Python

    1. Re:The myth of chroot security by Ed+Avis · · Score: 1

      It sounds like the mknod problem could be solved with something like devfs. If devices always live in /dev/ and new device nodes cannot be created from userspace, then a chrooted environment really does restrict what devices you can access.

      I'm not familar with raw I/O - does this need a device file to open() first or do you specify the major and minor device numbers as part of the system call in some evil way?

      --
      -- Ed Avis ed@membled.com
  33. WRT running as root, solution is easy by leonbrooks · · Score: 1

    Bind Apache to (say) port 8765 and NAT the incoming connections from port 80 to there.

    And for an encore?

    Change your user skeleton so public_html becomes a link to /var/www/users/$USERNAME (which useradd or whatever makes), add a group called ap_$USERNAME with each new user, add Apache to the group and chown said directory to $USERNAME:ap_$USERNAME and chmod it g+rx and make it sticky. Don't give Apache write access to anything. You still have a few issues left (if ap_$USERNAME isn't the users' default group, for example), but most of your problems are pushing up daisies. A bit cumbersome for a squillion users, but bearable for up to a few hundred.

    --
    Got time? Spend some of it coding or testing
  34. Breaking in by leonbrooks · · Score: 1
    Symlinks can't break out of chroot

    True, but they can `break in'. Move the real files to /var but outside the jail(s), put symlinks in their places, and hardlink yourself silly. Of course, I habitually mount /var as nosuid,nodev, so I don't expect much joy from suidperl, for instance. (-:

    --
    Got time? Spend some of it coding or testing
  35. They do by leonbrooks · · Score: 1
    I've always wondered why the various linux dists don't contain -chroot packages of the various servers that support the chroot environment.

    Mandrake have begun to.

    --
    Got time? Spend some of it coding or testing
  36. Re:*BSD is dying by Daimaou · · Score: 1

    Can you translate mine (it's not true by the way)?

  37. Emergency Closing by Anonymous Coward · · Score: 1, Funny

    Did you mean:

    To the University of Maryland Community:
    The University of Maryland will shut down in its entirety for Friday, April 11th.

    As the deadline for the submission of University's final budget to the state has approached, it has become clear that we are suffering from a large budget shortfall. Because of this, we are forced to shut down the entire campus for a full day. We apologize for the short notice of this cancellation.

    Dining services will still be running so that students may eat, and the student union will remain open. However, all classes are cancelled and most professors will not be on campus. A reduced number of shuttles will still be running.

    Students may be curious as to why this shortfall has occurred. On March 15th, the Maryland House Appropriations Committee proposed a further $37 million cut to the university system for the 2004 budget year, on top of a $67 million reduction in the current budget. Unfortunately, this proposal was approved, which left us with a drastically reduced budget for 2004. In order to have enough money to continue operations in full in 2004, we must shut do

    Thanks to everyone for your patience. Your understanding is appreciated. To the residents of Maryland, be sure to pay careful attention to the candidates you vote for in the upcoming elections, so that we can avoid this situation in the future.

    Colonel Cathcart
    Director, University Relations
    University of Maryland, College Park

    ********************
    This note was authorized for distribution to University of Maryland Community by: Colonel Cathcart, Director University Relations