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!"
Why bother? (Score:3, Insightful)
Re:Why bother? (Score:5, Insightful)
Re: (Score:1)
Re: (Score:2)
Did that sound good to you ? (Ironically, the word 'good' should really have been 'well' in the previous sentence)
Re: (Score:2)
Did it change the meaning to something other than what was intended? Because that's what ironic means.
Making the same mistake yourself while correcting someone else is not ironic. It's just humorously coincidental. Please watch this episode [wikipedia.org] of Futurama for further education.
Re:Why bother? (Score:4, Interesting)
Re: (Score:2)
The idea (Score:2)
Re:Why bother? (Score:5, Informative)
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: (Score:2)
Yep, 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!
/Mike
Re: (Score:2, Informative)
The (now defunct) commercial SSH has had this feature for almost 10 years.
Re: (Score:2)
/mike
Re:Why bother? (Score:5, Informative)
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.
Tell us more. (Score:2)
Re: (Score:3, Informative)
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)
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: (Score:2)
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.
That's pretty interesting! In practice, though, what would that get them? B would now have access to A's chroot (possibly - file permissions might be too restrictive anyway). If A trusts B that much, they could just share A's login.
Not saying this isn't serious, but I'm too tired to think of a useful attack vector at this moment. Am I missing something?
Re: (Score:3, Informative)
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
Re: (Score:2)
You know, I've had two "oh crap!" moments involving computer security. The first happened when I learned about SQL injection. The second occurred just now when I read your letter. Thanks for the followup!
Re:Why bother? (Score:5, Informative)
I imagine something similar would be forthcoming regarding OpenSSH specifically.
Re:Why bother? (Score:4, Informative)
For regular user accounts, a properly configured chroot jail is still a very useful security tool.
Re: (Score:2)
Only when you have full shell access. This patch is just about confining sftp file transfers via chroot(2) for some users without the burden of setting up a full chrooted environment. Sounds really sweet.
FTP servers have been doing this for years (Score:4, Informative)
It's only natural that this same chroot feature would be added to sftp.
Re: (Score:2)
The devs were correct that chroot alone was not designed for the purpose of security and can't be used alone to provide any.
Bad to the bone (Score:1, Funny)
(However, in this case you're correct in your usage.)
Re: (Score:2)
Oh thank god (Score:3, Interesting)
Now I can finally switch some customers from FTP to SFTP. Thanks for making this hugely useful change!
Anyone know if SFTP logging will be added any time soon? That's the last missing feature i always have to manually patch in.
Re: (Score:3, Insightful)
Re: (Score:2)
For real? My sarcasm meter is out of whack today so I can't tell.
Re: (Score:2)
Re: (Score:2)
OK, just checking. It's been a long day. :-)
Anyway, would something like Kerberos fill the bill for you? I use it to navigate around our network, and it's not that hard to do once you get over the initial learning curve. If you're stucking working with Windows, you can even auth against an Active Directory domain.
Re:Oh thank god - vsftpd v sftpd vs. vs ftpd. (Score:2)
This is a "Very Secure FTP Daemon" I would love for it to be configured exactly the same, but
the transport protocol would be Sech-file-xfer draft protocol (SFTP)
vssftpd ?
how about just a protocol option in the config of vsftpd...
Re: (Score:2)
I'm still hankering for tab completion in SFTP myself... maybe someday.
Re: (Score:3, Informative)
It will let you connect to sftp servers, and have a sane command line experience. It also has many nifty mirroring commands.
Why is this news? (Score:1)
Re: (Score:3, Informative)
Re: (Score:2)
This simply makes it much easier to do what many folks have been setting up manually for a long time. I'm hoping they'll follow it up with SCP support as well. Time to buy another CD set to support the project
Nothing New (Score:2, Informative)
Does This Mean (Score:3, Interesting)
all that for sftp? (Score:4, Interesting)
Re:all that for sftp? (Score:4, Insightful)
Why? No privilege separation. A MUCH bigger code base.
Not to mention fewer standalone programs.
Why not? The user security model is reliable and time tested. It does not require reinventing the "user". It does not depend on one program handling it's own system of virtual permissions correctly. It does not depend on the security of a large program that users directly interact with.
I can see ample reasons sftp is safer.
Re: (Score:2)
Re: (Score:1, Redundant)
So you are running Apache as root? Scary.
RSSH ? (Score:1)
Re: (Score:2)
Since SFTP stands for Secure File Transfer Protocol, it's not really designed to allow you to execute commands.