Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Security Software

Chroot in OpenSSH 62

bsdphx writes "OpenSSH developers Damien Miller and Markus Friedl have recently added a nifty feature to make life easier for admins. Now you can easily lock an SSH session into a chroot directory, restrict them to a built-in sftp server and apply these settings per user. And it's dead simple to do. If you need to allow semi-trusted people on your computers, then you want this bad!"
This discussion has been archived. No new comments can be posted.

Chroot in OpenSSH

Comments Filter:
  • Re:Why bother? (Score:5, Informative)

    by illegibledotorg ( 1123239 ) on Wednesday February 20, 2008 @03:06PM (#22491946)
    Giving someone a shell and putting them in a chroot crafted to look and function like a full system is one thing.

    Giving someone an SFTP session and chrooting them into a subdirectory is another thing.

    The feature added in this commit was arguably intended for the latter purpose given the additional changes to the SFTP subsystem that were included. There are countless tutorials and patches and scripts that are available to achieve chrooted SFTP-only access, but now it's been implemented in the core of OpenSSH. In my eyes, this solution is not only a "cleaner" solution to the problem, but it's probably more secure too.
  • Re:Why bother? (Score:5, Informative)

    by jandrese ( 485 ) <kensama@vt.edu> on Wednesday February 20, 2008 @03:07PM (#22491960) Homepage Journal
    They are probably better than giving semi-trusted users full filesystem access, even if they aren't perfect security. It's not even that chroot is inherently broken, it's just that people were using it incorrectly (setting it suid or letting the user become root inside of their jail). Most of the complaints seem to be "the user managed to get root and broke out of the jail", which is a problem with whatever allowed your user to become root in the first place, not the jail itself.

    Basically, to break out of a chroot you need to be root. If you're root, then you've already defeated the security on the box anyway. Don't let untrusted users become root.
  • Re:Why bother? (Score:5, Informative)

    by parcel ( 145162 ) on Wednesday February 20, 2008 @03:19PM (#22492130)

    Didn't we just read that chroot "jails" are not secure?
    You may want to take a look at http://www.openbsd.org/faq/faq10.html#httpdchroot [openbsd.org], especially the section titled "Should I use the chroot feature?".

    I imagine something similar would be forthcoming regarding OpenSSH specifically.
  • Re:Why bother? (Score:4, Informative)

    by jjohnson ( 62583 ) on Wednesday February 20, 2008 @03:21PM (#22492178) Homepage
    They're not secure for root users. That was the issue identified in the recent "read" you mention--someone was pointing out that root can break out in a particular way, and the kernel devs responded that 1) that was by design, and 2) locking that down left an infinite number of other ways to break out if you're root.

    For regular user accounts, a properly configured chroot jail is still a very useful security tool.
  • Re:Why is this news? (Score:3, Informative)

    by Doctor Crumb ( 737936 ) on Wednesday February 20, 2008 @03:49PM (#22492532) Homepage
    This is news because the chroot and sftp server are now built in to the openssh binaries, so you don't have to manually set up the chroot. While there's no GUI, it is in fact now easier to set up such a thing.
  • Nothing New (Score:2, Informative)

    by NYFreddie ( 84863 ) on Wednesday February 20, 2008 @03:49PM (#22492538)
    This isn't really anything new. This functionality has existed as a patch for a while. It's still nice to see that it's finally being integrated into the main tree, though.
  • by caseih ( 160668 ) on Wednesday February 20, 2008 @03:58PM (#22492632)
    The purpose of this feature doesn't seem to be to restrict what a shell user can do. Rather, if I read this correctly, it restricts what files a user can access via sftp. Without this feature, a user can sftp in, and then cd to / or any other folder that he has rights too. This chroot feature lets the admin limit the root to, say, his home directory, or some other folder such as a virtual web root or something.

    It's only natural that this same chroot feature would be added to sftp.
  • Re:Oh thank god (Score:3, Informative)

    by PylonHead ( 61401 ) on Wednesday February 20, 2008 @04:02PM (#22492680) Homepage Journal
    Use lftp

    It will let you connect to sftp servers, and have a sane command line experience. It also has many nifty mirroring commands.
  • Re:Tell us more. (Score:3, Informative)

    by jandrese ( 485 ) <kensama@vt.edu> on Wednesday February 20, 2008 @04:11PM (#22492844) Homepage Journal
    Yeah, every method I've seen starts with:

    Step 1: Become root

    Once you are root, there are dozens of ways to break out of a jail (all the way from modifying kernel memory structures directly to rewriting inodes to installing a kernel module that grants you access to whatever you need, etc...
  • Re:Tell us more. (Score:5, Informative)

    by sjames ( 1099 ) on Wednesday February 20, 2008 @10:08PM (#22497530) Homepage Journal

    In the right circumstances, 2 non-root users can conspire to break out of jail if one is chrooted below the other.

    Let's say A is chrooted to /home/sorta-trusted and B to /home/sorta-trusted/not-so-much.

    A diropens his / and creates a unix socket in /not-so-much. B opens the socket in his /. Now, A passes his fd to his / to B. B then does fdchdir on the fd and he's out of jail. Now B can break A out.

    The moral is, never use nested chroot jails!

  • Re:Why bother? (Score:2, Informative)

    by schon ( 31600 ) on Thursday February 21, 2008 @12:35AM (#22498662)

    that's precisely why my ears perked up upon hearing this, for hosting providers that want to provide secure remote file access, this is awesome
    My question is: what took so long?

    The (now defunct) commercial SSH has had this feature for almost 10 years.
  • Re:Tell us more. (Score:3, Informative)

    by sjames ( 1099 ) on Friday February 22, 2008 @01:00AM (#22511690) Homepage Journal

    It's far worse, at least in the Linux kernel (and quite probably other Unix as well but I haven't studied them). The linux kernel assumes that the PWD is at or below the chroot. When a system call parses a pathname, it substitutes the chroot for a leading /, and when walking through a .. in a pathname, it checks that the current directory in the walk isn't already the chroot before following .. up.

    So, once B gets to A's chroot (/home/sorta-trusted), it can access the real / as ../.. because now, the ..'s in the path won't pass through the stored chroot directory (/home/sorta-trusted/not-so-much. So, B diropens ../.. and passes that to A.

    So, interestingly, A can grant B access to something it doesn't have itself. B can then return the favor. Many argue that chroot isn't a security measure in the first place, so it's firmly WONT FIX.

    Personally, I say it IS a bug since right or wrong, it is used as a security measure all the time (and is quite a useful one but for the holes). I'm testing a patch that closes the escape even for root now (unless root hacks around in the kernel's memory of course but that can also be closed in a capabilities system).

Top Ten Things Overheard At The ANSI C Draft Committee Meetings: (5) All right, who's the wiseguy who stuck this trigraph stuff in here?

Working...