![pen-test logo](/images/pen-test-logo.png)
Penetration Testing mailing list archives
Re: how an hacker can bypass a chrooted environement ?
From: Peter Kosinar <goober () ksp sk>
Date: Fri, 12 May 2006 20:45:27 +0200 (CEST)
Hello,
I was wondering how an attacker can bypass a chrooted environement. A (common) technique consist in finding a vulnerable program (in the chrooted environnement) and injecting it a shellcode (i.e ../../../../../../../bin/bash for ex.) by BoF. But normally, in the chrooted environement, you volontarily add only necessary tools (like ls, cat, less...), and vulnerable softwares are uncommon...
Well, without a vulnerable program, there is nothing to attack and thus no chroot environment to bypass :-) However, I'd guess you're considering the following scenario:
There is a vulnerable application running in chrooted environment, the directory it is chrooted in doesn't actually need to contain any files. The attacker manages to exploit a vulnerability in the program, i.e. (s)he is able to make it run whatever code (s)he wants. The real objective is, however, to be able to access to the files on the system. This is called "breaking out of the chroot".
One of the well-known techniques is the ../../../.., which is based on one (bad) property of chroot -- the chroot(2) system call does not change the current working directory.
Consider the following sequence of steps achieves: 1) mkdir("goo") 2) chroot("goo") 3) chdir("../../../../../..") 4) chroot(".")Steps 1 and 2 create a directory called "goo" and set the root directory of current process to that dir. However, the current WORKING directory is not changed -- it is OUTSIDE the root directory of the process. Step 3 then moves upwards in the hierarchy (the original chrooted directory tree might have been several directories deep in the tree), trying to reach the "true" root directory. The last step sets the new root to the current working directory (= true root), thus accomplishing the "break-out-of-chroot" mission.
That's why some security patches enforce chdir("/") immediately after chroot() call. Note that this is not the only method of breaking out of the chroot jail, it's just one of the more widely used ones.
Peter -- [Name] Peter Kosinar [Quote] 2B | ~2B = exp(i*PI) [ICQ] 134813278 ------------------------------------------------------------------------------ This List Sponsored by: CenzicConcerned about Web Application Security? Why not go with the #1 solution - Cenzic, the only one to win the Analyst's Choice Award from eWeek. As attacks through web applications continue to rise, you need to proactively protect your applications from hackers. Cenzic has the most comprehensive solutions to meet your application security penetration testing and vulnerability management needs. You have an option to go with a managed service (Cenzic ClickToSecure) or an enterprise software (Cenzic Hailstorm). Download FREE whitepaper on how a managed service can help you: http://www.cenzic.com/news_events/wpappsec.php And, now for a limited time we can do a FREE audit for you to confirm your results from other product. Contact us at request () cenzic com for details.
------------------------------------------------------------------------------
Current thread:
- how an hacker can bypass a chrooted environement ? Norbert François (May 12)
- Re: how an hacker can bypass a chrooted environement ? alan (May 12)
- Re: how an hacker can bypass a chrooted environement ? Justin Ferguson (May 12)
- Re: how an hacker can bypass a chrooted environement ? Peter Kosinar (May 12)
- Re: how an hacker can bypass a chrooted environement ? Rob (May 12)
- Re: how an hacker can bypass a chrooted environement ? Tonnerre Lombard (May 12)
- Re: how an hacker can bypass a chrooted environement ? Norbert François (May 14)
- <Possible follow-ups>
- Re: how an hacker can bypass a chrooted environement ? Marco Ivaldi (May 16)
- RE: how an hacker can bypass a chrooted environement ? David M. Zendzian (May 17)
- Re: how an hacker can bypass a chrooted environement ? Chris Byrd (May 18)
- Re: how an hacker can bypass a chrooted environement ? Marco Ivaldi (May 17)
- Re: RE: how an hacker can bypass a chrooted environement ? john . fellers (May 18)
- Re: how an hacker can bypass a chrooted environement ? alan (May 12)