Papillon - A Solaris Security Module
(c) 2000-2002 Konrad Rieck (kr@roqe.org)
Contents1 Introduction1.1 Overview 1.2 What it does 1.3 Release Notes 2 Installation and Configuration 2.1 Getting Papillon 2.2 Requirements 2.3 Compilation 2.3.1 Configuration src/Makefile 2.3.2 Configuration src/papillon.h 2.3.3 Configuration src/papillon.c 2.3.4 Compilation 2.3.5 Testing the module 2.3.6 Installation 3 Runtime Configuration 3.1 papctl Options 3.2 Examples 3.3 Known problems 4 Papillon's functionality 4.1 Features 4.1.1 Restricted Proc 4.1.2 Pseudo Promiscuous Flag 4.1.3 Module Hiding 4.1.4 Secure STDIO File Descriptors 4.2 Protections 4.2.1 Symbolic Link Protection 4.2.2 Hard Link Protection 4.2.3 FIFO Protection 4.2.4 Chroot Protection 5 Closing 5.1 Bug Reports 5.2 Thanks
1 Introduction
1.1 OverviewWelcome to the mysterious world of Papillon. This documentation covers all information regarding the functionality, the usage and the installation of the Papillon module. You should read this documentation carefully since only a properly installed and configured module will provide the security mechanisms introduced in this document.Papillon is a security module designed for the Solaris Operating Environment (Solaris OE) 8 [SOE]. It has been tested against the Intel and the Sparc Edition of the Solaris OE 8. Papillon tries to be as compatible with Sun Microsystems DDI/DDK as possible, and should also work on the Solaris OE 9 beta and following.
1.2 What it doesPapillon improves the security of a system by adding new functionality to the kernel. The added security mechanisms have been inspired by Solar Designer's Openwall Linux Kernel Patch [OW] and the HAP Linux Kernel Patch [HAP] which fixes common Unix security problems that are also present in the Solaris OE. Papillon is designed to prevent attacks driven by system users. It doesn't include any restriction to the super-user. It can be an addition to already exisiting security mechanisms such as the BSM (Solaris' Basic Security Module) and the non-executable stack on Solaris Sparc Edition. The module is automatically loaded at boot time when entering multiuser level (init 2) and installs two kinds of new functionality in the kernel: so called features and protections. Features Features add completely new functionality to the kernel, they can be switched on or off either at compilation time or even at runtime using the provided control tool papctl. Features included in Papillon currently are:
Protections Protections restrict access to resources if specific conditions occur. A protection has a behaviour that can be none (for doing nothing), warn (for warning only) or deny (for warning and denying access to the resource). Protections included in Papillon currently are:
See the section about features and protections for detailed information about how they work and what they do.
1.3 Release Notes2
2 Installation and Configuration
2.1 Getting PapillonPapillon is available from the Roqefellaz website [RQ] You can directly access the Papillon page [PAP] at http://www.roqe.org/papillon. After receiving the source package of Papillon papillon-0.4.3 .tar.gz, extract the sources and enter the source directory.
# zcat papillon-0.4.3
.tar.gz | tar -xvf -
You should always download the latest version of Papillon. Kernel development is very critical, small bugs can cause real damage. See the section about bug reports for more information.
2.2 RequirementsIn order to compile Papillon you need some general development environment.
2.3 CompilationPrecompilation configuration is done in three files of the source tree: src/Makefile, src/papillon.h and src/papillon.c. The first is designed for common configurations while the latters are designed for advanced configurations.
2.3.1 Configuration src/MakefileYou need to decide which features and protections to compile into the module. By default all features and protections are included. Edit the file src/Makefile and change the following variables if necessary.
You can also modify other variables in the file src/Makefile but in general everything should work on a default Solaris OE installation.
2.3.2 Configuration src/papillon.hIf you are an advanced user and have some experience with kernel modules, you can also edit other files inside the src directory. The following changes can be done in src/papillon.h
2.3.3 Configuration src/papillon.c
2.3.4 CompilationCompilation is rather simple and straight-forward
# cd src
2.3.5 Testing the moduleBefore you permanently install Papillon, it is wise to run some tests. Load the module into the kernel by executing the following command.
# modload ./src/papillon
Run the control tool papctl to check if the module has been loaded successfully and the configuration gets correctly exported.
# ./src/papctl -g
Now compile the test suite that is part of the Papillon source package.
# cd test
Stay in the test directory. Execute the test.sh shell script. Make sure no one is on your system. Follow the instructions printed by test.sh.
# ./test.sh
Make the module visible and unload it. Use modinfo to determin the module id of Papillon and replace ID in the last line with this number.
# cd ..
If during the process described above the system panics or any other major problems occur, send a bug report to kr@roqe.org and describe in detail your system, your configuration and the problem that occured. See the section bug reports for more information.
2.3.6 InstallationFrom the src directory you are able to install the module.
# cd src
These commands will create the following files on your system. (If you have modified some of the path variables in the file src/Makefile , paths may differ)
You can use the following sequence to uninstall the installed files.
# cd src
Note: Papillon adds a script to the init directory so that the module is loaded at boot time. If you have volume management enabled problems concerning setting the configuration using papctl may occur. Disable the volume management by moving the /etc/rc2.d/S92volmgt script to a save place. If you don't want to disable volume management, read the part about how to cope with the problems in the runtime configuration section. If all of these files have been installed on your system, you can activate the module by running
# /etc/init.d/papillon start
If you reboot your system, Papillon will automatically be loaded when switching to multiuser level.
3 Runtime ConfigurationIf Papillon is loaded, you can use the control tool papctl to toggle features and protections. Below is a list of the commandline and some examples.
Note: If Papillon is loaded and hidden, you are not able to view it on the list of loaded modules generated by modinfo. The control tool papctl is the only way to test if the module is loaded or not in this case.
3.1 papctl Options
In order to toggle features or protections you have to assign variables the correspoding values. This is the table of all variables, their values and their description.
3.2 Examples
3.3 Known problems
4 Papillon's functionalityThis section lists all features and protections that are included in the Papillon module. You should carefully read this section in order to understand how Papillon works and how it achieves an improvement in the system security.
4.1 FeaturesAs mentioned in the introduction the so called features of Papillon can be switched on or off either on compilation or even on runtime. See the sections about compilation and runtime configuration how to do both.
4.1.1 Restricted ProcBy default users on the Solaris OE are able to monitor all active processes (e.g. ps, top). An attacker that has local access to the system might gather useful information by watching system daemons and other users processes. The public information about all running processes also represent a lack of privacy, if a system hosts several independant users. If the Restricted Proc feature is active, users are only able to view their own processes (processes that are running under their user id uid). There is no possibilty for a user to monitor other users processes since Papillon effects the proc filesystem directly. An attacker which has a local account on the system gains no further information from running commands such as ps or top. Of cause the super-user is able to view all processes. A special group of users can be added that are also able to view inside the restricted proc. Papillon extends the access() function of the proc vnode operations provided by prvnodeops to implement the above feature. Unfortunatley the Solaris OE sets the correct permission on the files inside the proc filesystem but does not implement an access() in the proc kernel module. Papillon simply adds this missing access() function.
4.1.2 Pseudo Promiscuous FlagThe Solaris OE 8 and previous versions don't provide a promiscuous mode flag for network cards that is exported to the user. An administrator is not able to monitor a network device for an attacker that is sniffing. Papillon is able to log all attempts to turn a network device into promiscuous mode that are done using the DPLI Interface. Requests that are performed using a different approach are not detected. Most sniffers use the DLPI Interface. Papillon intercepts the putmsg() syscall and filters messages that match a DLPI requests (dl_primitive == DL_PROMISCON_REQ and dl_level == DL_PROMISC_PHYS). If a message contains the command for putting a network device into promiscuous mode a warning is send to the syslog. The module is not able to log when a network interface changes back from promiscuous mode to normal operation mode.
4.1.3 Module HidingIn most cases it is not necessary to hide a security module. But if an administrator wants to monitor an exisiting attacker, it might be necessary to make the attacker believe that this system is not protected by any security software. Papillon is able to remove itself from the list of loaded kernel modules. Papillon denies any access the module's files and hides the module's files from directory listings including the module itself, initscripts and the papctl control program. The super-user is able to view and access all of these files. The list of files to be hidden can be extended at compilation time. Papillon unlinks itself from the list of loaded modules and relinks itself back in if requested. It also intercepts the vop_lookup() function from his module's file vnode. Access to the file is denied if not the super-user accesses the file. Papillon also intercepts the vop_readdir() function of its parent directory and removes itself from all directory listings by patching the length of previous dirent64 entry using d_len. The entry for Papillon is covered this way.
4.1.4 Secure STDIO File DescriptorsBy default Unix uses the file descriptors 0, 1 and 2 for special purposes.
If an attacker closes one of these file descriptors and executes an insecure program with the suid/sgid bit (permission mode 4000/2000 or u+s/g+s) set, a file descriptor inside the program might be assigned to one of the closed standard file descriptors. In this case information written to STDIN, STDOUT or STDERR might be written to a file. By using this technique an attacker is able to destroy or even modify system files. Papillon intercepts the execution of all binaries that have the suid/sgid bit set. If the STDIO File Descriptors are closed, Papillon fake opens them during the execution of the suid/sgid program. No suid/sgid program is able to accidently assign a file to the STDIO File Descriptors. Papillon intercepts the execve() syscall and watches binaries with the suid/sgid bit (Vnode mode S_ISUID or S_ISGID) set. If the Standard File Descriptors are closed, they are faked opened using the kernel allocation routine ualloc(). After executing the original syscall the allocated file descriptors are set free.
4.2 ProtectionsProtections restrict access to resources (e.g. opening file) if specific conditions occur (e.g. the file is located in a directory with the sticky bit set). A protection has a behaviour that can be none (for doing nothing), warn (for warning only) or deny (for warning and denying access to the resource). You can customize the default behaviour of your protections at compilation time. You are also able to change the behaviour on runtime.
4.2.1 Symbolic Link ProtectionDirectories with the sticky bit (permission mode +t or 1000) and write-all (Permission mode a+w or 0222) permissions have a specific behaviour: files created in such a directory can only be removed by the file owner or the super-user eventhough write permissions are granted to all users, e.g. /tmp. An attacker can use this feature to drive a symbolic link attack. A symbolic link attack is basicly based on a symbolic link that has the name of a temporary file and links to a file the attacker wants to modify. Papillon provides a simple symbolic link protection. If a user wants to follow a symbolic link that is within a directory with the sticky bit set, access is denied if all of the following conditions are true:
This protection mechanism especially protects the super-user privileges, an attacker is not able to gain super-user privileges, if the admin executes a binary that creates insecure temporary files. Papillon watches all calls to the open() and open64() syscalls, if a symbolic link is to be opened that is placed in a directory with the sticky bit (Vnode mode S_ISVTX) set and the above conditions match, the open fails with permission denied (EPERM).
4.2.2 Hard Link ProtectionAn attacker can perform most symbolic link attacks by using hard links. If the symbolic links are protected, it is likely that hard links will be used in exploits. There is also another problem with hard links in the Solaris OE. Users are able to create hard links, that they cannot delete afterwards, e.g. by hard linking to /etc/password .Papillon fixes both problems. If the hard link protection is active users can not create hard links to files they donnot own. The super-user is able to create hard links to all files. The link() syscall is intercepted and the above protections are implemented. Papillon returns permission denied (EPERM).
4.2.3 FIFO ProtectionA FIFO (e.g. a file created with mkfifo) that is inside a directory with the sticky bit set and write-all permissions can be opened by an attacker using the open flag O_CREAT. In this case all saved content inside the FIFO will be lost. Papillon restricts access to FIFOs inside directories with the sticky bit set and write-all permissions. Open access to FIFOs is denied if all of the following conditions are true:
Papillon watches all calls to the open() and open64() syscalls, if a FIFO is to be opened with the O_CREAT flag in a directory with the sticky bit (Vnode mode S_ISVTX) set, access is denied if the above conditions match. In this case Papillon returns permission denied (EPERM).
4.2.4 Chroot ProtectionThe chroot() syscall is often used to create another security layer between an application and the operating systems, but it has been initially designed as a safe (not secure) development environment. An attacker that gained root in a chroot jail will soon focus on breaking out of the jail. Amoung the rich set of possibities Papillon protects against the most common techniques used.
Papillon prevents these attacks if a process runs in a chroot jail. Therefore the module intercepts the following syscalls and restricts access to them if the running process has the chroot vnode set (u.u_rdir != NULL): chroot(), mount(), mknod, xmknod, modctl and chmod. Inside the intercepted syscalls Papillon checks if one of the conditions mentioned above has occured and if positive forces the syscall to return permission denied, error number EPERM.
5 Closing
5.1 Bug ReportsPapillon has been developed in the free time of the author. It is a non-commercial opensource project. Papillon tries to offer a maximum of stability, but due to the reasons mentioned above, it can fail to do so. Therefore it is essential that users experiencing bugs report them to the author by sending an email to
echo \$c | mdb unix.0 vmcore.0
You should retrieve a backtrace of the kernel thread that paniced. Include this trace in the email instead of attaching any core file.
5.2 ThanksThe author would like to thank Job de Haas for his ideas, support and the fun during their presentation at HAL2001. Thanks to Fabian Kroenner for hours of constructive discussions regardings Papillon and its future, there would have been no release without his support. Thanks also go to Heiko Krupp who contributed the initial implementation of the chroot protection and is supporting the project with his own code and ideas. Konrad Kretschmer was so gentle to read through the complete documentation eleminating at least the obvious misspellings and Markus C. Gottwald and Manuel Beetz who contributed parts of the documentation system. The author also would like to thank Philipp Stucke and Skyper who provided some of the test environment. Thanks to following persons who contributed beta test reports and/or feedback (in order of appearance): Sergei Rousakov, Michael Parkin, Adam Mazza, Adam Morley, Juri Haberland, Erik Parker and Eric Thern.
References
|