Home page logo
/

pen-test logo 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: Cenzic

Concerned 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.
------------------------------------------------------------------------------


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]