LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-08-2009, 09:00 PM   #1
shin2011
LQ Newbie
 
Registered: Dec 2008
Posts: 10

Rep: Reputation: 0
How can i escape from a 'chroot jail'?


I use 'chroot' command to run program which made by other guy.
First time, i can escape from 'chroot jail' by close terminal window.
But, i can't escape from chroot jail with samething before.

I am find a clue about this problem. I did follow it's explain.
But i cann't resolve that. Also, i cann't understand this meaning.
Clue is like below
" http://linux.die.net/man/2/chroot "
"This call does not change the current working directory, so that after the call '.' can be outside the tree rooted at '/'. In particular, the superuser can escape from a 'chroot jail' by doing 'mkdir foo; chroot foo; cd ..'."

Please let me know the clue about this problem.
And if possilbe, please explain above description from linux.die.net.

Thank you very much
Marcus shin.
 
Old 01-08-2009, 11:19 PM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Escaping from a chroot jail is more commonly known as "cracking". We won't support cracking on this site.
 
Old 01-09-2009, 12:18 AM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Although the fact that it's relatively simple to do also demonstrates that one shouldn't overly rely on chrooting for security.
 
Old 12-28-2011, 08:18 PM   #4
jazedal
LQ Newbie
 
Registered: Dec 2011
Posts: 2

Rep: Reputation: Disabled
One known method of escaping a chroot jail is to change the current working directory (CWD) to a directory outside the chroot jail using its file descriptor. This requires root privileges. I believe there is no way to break out of a chroot jail without root privilege. Chroot should not be used as a security measure unless it is well-configured and its vulnerabilities are well-understood.

Anyone who uses chroot for security should ensure it is well-tested against known attacks. I believe hiding information necessary to perform such tests is a parallel mindset to "security through obscurity". It aims to protect our information by attempting to keep our attackers ignorant, and ourselves as well as a side-effect. It is important that the security of our internet and information systems is based on knowledge and sound principle rather than self-imposed ignorance.
 
Old 12-28-2011, 10:51 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by jazedal View Post
I believe hiding information necessary to perform such tests is a parallel mindset to "security through obscurity". It aims to protect our information by attempting to keep our attackers ignorant, and ourselves as well as a side-effect. It is important that the security of our internet and information systems is based on knowledge and sound principle rather than self-imposed ignorance.
If you refer to the LQ rule about cracking with this, this has nothing to do with ignorance, it is because of legal issues.
 
Old 12-28-2011, 11:15 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by shin2011 View Post
Clue is like below
" http://linux.die.net/man/2/chroot "
"This call does not change the current working directory, so that after the call '.' can be outside the tree rooted at '/'. In particular, the superuser can escape from a 'chroot jail' by doing 'mkdir foo; chroot foo; cd ..'."
Note that this is in reference to the chroot system call (manual section 2), and not to the chroot command. While the chroot system call does not change the current working directory, the chroot command does do a chdir() into the jail, so the quoted method does not apply.
 
Old 12-29-2011, 05:13 AM   #7
jazedal
LQ Newbie
 
Registered: Dec 2011
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
Note that this is in reference to the chroot system call (manual section 2), and not to the chroot command. While the chroot system call does not change the current working directory, the chroot command does do a chdir() into the jail, so the quoted method does not apply.
Thanks for making that distinction; however, the exploit is viable even when the current working directory was changed as well, as demonstrated here. A variation of the exploit might also apply to the chroot command. All that is necessary is a file descriptor for a directory outside of the chroot jail.

FWIW, here is a quotation from a post by Anton Chuvakin, Ph.D.:
"... the number of ways that root user can break out of chroot is huge. Starting from simple use of a chroot() call with no chdir() [see code below] to esoteric methods as the creation of your own /dev/hda or /dev/kmem devices, injection code into the running kernel (http://www.big.net.au/~silvio/runtim...m-patching.txt), using open directory handles outside chroot or chroot-breaking buffer overflows."

Quote:
Originally Posted by TobiSGD View Post
If you refer to the LQ rule about cracking with this, this has nothing to do with ignorance, it is because of legal issues.
Are you sure it has nothing to do with ignorance? Regardless, whatever the motive and whoever the cause, the effect is a restriction on public and academic research in anti-security, which is more important to the field of security than to malicious hackers.
 
Old 12-29-2011, 07:43 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by jazedal View Post
Quote:
Originally Posted by TobiSGD View Post
If you refer to the LQ rule about cracking with this, this has nothing to do with ignorance, it is because of legal issues.
Are you sure it has nothing to do with ignorance? Regardless, whatever the motive and whoever the cause, the effect is a restriction on public and academic research in anti-security, which is more important to the field of security than to malicious hackers.
This may require a wee bit of explanation. Certain content becomes or may become a liability under the law so without having to test safe-harbor provisions LQ steers clear of certain topics. LQ for example does not condone circumvention of access restrictions as in digital rights management, network access or warez or those actively seeking for what we consider clear cases of "cracking": there are enough sites elsewhere on the 'net that do allow that kind of stuff.
To check if any posted content is in violation of the LQ Rules best use the report button on that post and ask moderators for a verdict.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Chroot jail Gimpy Linux - Software 10 05-07-2010 01:30 PM
Chroot jail pachanga Linux - General 12 09-26-2008 05:15 AM
Jail and chroot rogk Linux - Security 2 10-16-2005 02:20 AM
chroot jail etc. f1uke Linux - Security 5 08-24-2005 03:12 AM
chroot jail simon Linux - Security 3 08-05-2001 08:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration