Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Re: Re: Re: exiting a chroot environment

by MarkM (Curate)
on Jul 09, 2003 at 01:41 UTC ( [id://272532]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: exiting a chroot environment
in thread exiting a chroot environment

Consider the issue with Linux. The reason '.' can be used to escape from a chroot() environment is because '.' is not special. '.' is a hard link to current directory. In operating systems that implement chroot() to be 'more secure', '.' must be special cased.

Specifically, '.' and '/..' must be special cased. In the simplest form, this may mean that '/.' and /..' need to be translated in place on reference to appear as if they both referred to '/'.

  • Comment on Re: Re: Re: Re: Re: exiting a chroot environment

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: exiting a chroot environment
by sauoq (Abbot) on Jul 09, 2003 at 01:55 UTC

    But if, after chroot()'ing, "." acts differently for root than it does for every other user, then isn't root being treated as a special case? Mustn't there be a check against the uid somewhere? That's the special case I'm talking about.

    It seems to me that you are saying, on Linux, in a chroot() environment, '.' is a special case for every user except root... I suppose you might look at it that way, but it seems a bit backward and I still don't understand where the reduction in code complexity comes from.

    Regarding '..', I don't understand why that would be any more of a special case than it usually is (that is '/..' being equivalent to '/').

    I'm sure I'll have to start digging through source code before I understand your point.

    -sauoq
    "My two cents aren't worth a dime.";
    

      I believe the conflict in our understanding is in each of our understanding on where the /.. = /. = / magic is implemented. My understanding of the file system structures tells me that /.. = /. = / is implemented at mkfs time, not at run time. The '..' and '.' entries in '/' both refer to the same inode as '/' refers to. There is no special magic in the kernel.

      It is possible that I am incorrect, however, I suggest to you that my understanding is the only understanding that explains why Linux allows users to escape a chroot() jail by referring to '.' and './..'.

      UPDATE:

      I think we are both wrong. I can't seem to escape the Linux chroot() jail in any of the ways listed above unless '.' was already outside the chroot() jail, which is the exploit that the man page refers to.

        explains why Linux allows users to escape a chroot() jail

        Ah, but Linux, AFAIK, doesn't allow just any user to escape the chroot() environment. It only allows the super-user to escape it.

        I think we might be referring to two different special cases.

        As for when /.. = /. = / is implemented, I wouldn't think it would happen during mkfs because mkfs would have no way of knowing whether the filesystem in question would be used as the root fs or not. (Might there be something going on when the root fs is mounted?) My understanding of this stuff is admittedly weak; I'd be happy to receive some enlightenment.

        -sauoq
        "My two cents aren't worth a dime.";
        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://272532]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found