Editing
Msg05232.html
From Linix VServer
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
----- [<nowiki/>[[msg05231.html|Date Prev]]][<nowiki/>[[msg05233.html|Date Next]]][<nowiki/>[[msg05224.html|Thread Prev]]][<nowiki/>[[msg05234.html|Thread Next]]][<nowiki/>[[index.html#05232|Date Index]]][<nowiki/>[[threads.html#05232|Thread Index]]] <span id="vserver-chrootsafe-issues"></span> = [Vserver] chroot(safe) issues = ----- * '''From:''' Enrico Scholz * '''Date:''' Wed, 26 Nov 2003 01:56:48 +0000 (GMT) ----- <pre>Hello, on IRC two days ago we had a discussion about secure chroot() implementation. To make it short: it does not exist a such one. The details: the problem of current chroot(2) is that this syscall is not stackable -- on every new chroot(2) invocation the dead zone will be set to a new value and the old one dropped. This fact allows to bypass the chroot by moving into an "free" directory with 'fchdir(fd)' and go from there with subsequent 'chdir("..")' to the real root. A vserver kernel-patch introduced a new chrootsafe() syscall which tries to prevent the 'fchdir()' part by forbidding open directories as chrootsafe() time. So, the 'fchdir(fd)' can not be executed. Sounds really good and secure on first glance, but kloo_ brought in the idea to transfer filedescriptors via SCM_RIGHTS -- and it works; see http://www.tu-chemnitz.de/~ensc/chrootescape.c (replace vc_chrootsafe() with your own implementation; the actual program uses an experimental syscall which was written by Herbert Poetzl to demonstrate the issue). In attack-mode, this program forks into two processes. The first one calls vc_chrootsafe() to move the dead zone. The second process opens a directory-filedescriptor and transmits it to the first process through SCM_RIGHTS. Now, this process can continue with conventional chroot() methods to come to the real /. Assuming stackable chroots (every chroot() puts the new dead zone into a list which gets processed in vfs_permissions()), the SCM_RIGHTS method can bypass these chroot() also. All you need are two processes within independent chroots which are sharing a filesystem (e.g. /home). The first process moves into the environment of the second one with the already mentioned fchdir() method. Now, it can be moved freely to '..' since the dead zone does not exist there. Another method to escape chrootsafe(), would be the movement of the current directory: one process calls chrootsafe() to move the dead zone, and goes into a directory within the new jail. Now, a second process (started within the old dead zone) moves this directory to a place which is outside of the new dead zone. The cwd-fd of the new process stays in this dir, and on the path to the real '/', the new dead zone will never be reached. Under some circumstances (two processes in independent chroot environments which are sharing a filesystem), this attack works for ordinary users also. Please not that the current 'chmod 000' hack is not affected by this attacks since it is a fixed barrier which can not be bypassed. Therefore, it will not make sense to hope on a magic chrootsafe() syscall for vservers. Alternative approaches like CLONE_NEWNS in combination with pivot_root() or 'mount --rbind <vdir> /' (suggested by Rik van Riel) must be investigated to find better methods. Enrico _______________________________________________ Vserver mailing list Vserver@xxxxxxxxxxxxxxxxxxxxxx http://list.linux-vserver.org/mailman/listinfo/vserver </pre> ----- * '''Follow-Ups''': ** '''[[msg05268.html|re: [Vserver] chroot(safe) issues]]''' *** ''From:'' Jacques Gelinas ** '''[[msg05234.html|Re: [Vserver] chroot(safe) issues]]''' *** ''From:'' Alex Lyashkov * Prev by Date: '''[[msg05231.html|RE: RE: [Vserver] Rpms for vserver 0.27 (got it)]]''' * Next by Date: '''[[msg05233.html|[Vserver] Combine linux-vserver with UML?]]''' * Previous by thread: '''[[msg05224.html|[Vserver] 2 IP-numbers for one vserver]]''' * Next by thread: '''[[msg05234.html|Re: [Vserver] chroot(safe) issues]]''' * Index(es): ** [[index.html#05232|'''Date''']] ** [[threads.html#05232|'''Thread''']]
Summary:
Please note that all contributions to Linix VServer may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linix VServer:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
About
Overview
Paper
News
Developers
Donations
Search
Getting Started
Downloads
FAQs
Documentation
Support
Participate
How to participate
Report a Bug
Communicate
Teams/Projects
Hall of Fame
Resources
Archives
Recent Wiki Changes
Pastebin
Related Projects
VServer Hosting
Happy VServer Users
Tools
What links here
Related changes
Special pages
Page information