Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible let chroot jails share directories(read-only) outside the jail?

I have muliple chroot jails, I want them to share some directories, currently I have to copy these directories into jails which I think is not elegant. The directories are read-only, like '/usr/bin'.

like image 939
freestyler Avatar asked Dec 09 '11 03:12

freestyler


People also ask

How does chroot jail work?

It allows you to run a program with a root directory other than / . The program cannot see or access files outside the designated directory tree. Such an artificial root directory is called a chroot jail, and its purpose is to limit the directory access of a potential attacker.

When setting up a chroot jail the new root directory is typically Which directory?

Using chroot utility 2. The new_root directory becomes the artificial root directory. chroot changes to new_root and runs the optional command. Without specifying a command as an argument, chroot changes to new_root and runs the value of the SHELL environment variable or /bin/sh if SHELL is not set.

Can Super user break out of chroot jail?

Solution. In a chroot environment, if a program is running with root privileges, the program might be able to perform a second chroot and can break out of the chrooted environment.

How is a chroot jail used to improve application security?

A correctly configured chroot jail will have only the files and libraries needed to run the service, all of which would be set to minimum privileges. This will effectively prevent the attacker from exploring the file system outside of the jailed directory or from executing binaries that are not stored within the jail.


1 Answers

You can use the new bind mounts support to make identical directory structures available through multiple paths.

mount --bind /usr/bin /path/to/chroot/jail/usr/bin
mount -o remount,ro /path/to/chroot/jail/usr/bin

For more details, see mount(8).

You can get really clever with mounting on Linux systems these days; for more details, see the Linux kernel source file Documentation/filesystems/sharedsubtree.txt.

like image 95
sarnold Avatar answered Nov 02 '22 03:11

sarnold