Test Day:2009-10-20 SELinux Confined Users

What to Test?
Today's Fedora Test Day will focus on SELinux Confined Users - users which are assigned to a SELinux role and where the SELinux policy controls what the user can do/access on the system. Current confined user types with their purpose of use are:

The purpose of test day is to test these SELinux users in usual/specific use cases.

Who's available
The following cast of characters will be available for testing, workarounds, bug fixes, and general discussion.


 * Development: dwalsh, mgrepl
 * Quality: mmalik, ebenes

What's Needed to test
echo > /var/log/audit/audit.log service auditd restart service messagebus start service restorecond restart setenforce 1 tail -f /var/log/messages
 * You will need a fully updated Rawhide, Fedora 12 Beta or the Rawhide nightly Live Image
 * You will need following packages installed on the machine. Please run  as root to install them and check that their versions match:
 * The content of will be useful during testing and reporting issues.  Connect to your test system and prepare the system for gathering output using the commands below:
 * The content of will be useful during testing and reporting issues.  Connect to your test system and prepare the system for gathering output using the commands below:
 * The content of will be useful during testing and reporting issues.  Connect to your test system and prepare the system for gathering output using the commands below:
 * The content of will be useful during testing and reporting issues.  Connect to your test system and prepare the system for gathering output using the commands below:
 * The content of will be useful during testing and reporting issues.  Connect to your test system and prepare the system for gathering output using the commands below:
 * The content of will be useful during testing and reporting issues.  Connect to your test system and prepare the system for gathering output using the commands below:

Live Image
You may download a non-destructive rawhide live image for your architecture. Tips on using a live image are available at FedoraLiveCD.

How to Test
The main goal is to test whether chosen confined user is able to do things which are allowed considering his/her SELinux role. And whether chosen confined user is not able to do things which are not allowed considering his/her role. For example if you log in as  and try to run   or   in your favourite terminal you won't be able to run it. But if you won't be able to run Firefox then probably this is a bug.

If you usually use another web browser than Firefox, please continue to do so during the test day. Our intent is to test at least one program from each of the following groups:
 * 1) mail clients (,   etc.)
 * 2) editors (,  ,   etc.)
 * 3) networking tools (,   etc.)
 * 4) FTP clients
 * 5) web browsers
 * 6) audio / video players
 * 7) samba mounting / tools
 * 8) NFS mounting / tools
 * 9) Java apps
 * 10) office apps
 * 11) printing / scanning tools
 * 12) photo / camera manipulation
 * 13) CD/DVD reading / writing
 * 14) IM clients
 * 15) flash players

Issues found during the test day will help us to improve SELinux policy in future Fedora releases and derived distributions (e.g. RHEL and CentOS).

How to Report Problems
If you encounter problems (e.g. appl. A did not start, appl. B failed to do what you wanted, appl. C works only partially), try the following before filing a bug
 * 1) Permissive mode - switch to permissive mode  and repeat your action. If SELinux denied your action in enforcing mode, it won't deny your action in permissive mode. Do not forget to switch back to enforcing mode  before next testing. Root shell is needed.
 * 2)  - Run  as advised below to see if new AVC messages appeared. Root shell is needed.
 * 3) fpaste.org - Make the AVC message public via http://fpaste.org/ . Add a short description what you did and what happened or did not happen. Please increase the default expiry time to 1 day, because the default is 1 hour.
 * 4) IRC - Communicate with others on IRC channel to find out if they encountered the same problem. It's likely that someone on IRC channel knows the solution or already reported the problem.
 * 5)  - Look at the end of  and search for messages containing  . Run   with parameters as advised. Root shell is needed.
 * 6) Bugzilla - Lastly, file a bug in Red Hat Bugzilla.  Be sure to set the following attributes: Product: Fedora, Version: rawhide, Component: selinux-policy.  Alternatively, follow this link to file a bug  against selinux-policy.  Do not forget to supply the description of actions you did, the AVC message and the full output of.

Here is an example how to display AVCs which arose since a specific time:
 * 1) do something as confined user
 * 1) do something as confined user

Test Cases
Here you can find a few test cases. Please run as many of them as possible. Below each test case you can see a table, where you should write your results. Please add a line with your username and list of tests you ran/skipped into the table. The table could look this way:

guest_u
As root set up a server only machine, with Apache service. Configure Apache in such a way that user home directories are accessible. Make sure Apache service is running. Add an user which can log in as. Create a directory named. Install MySQL. Make sure MySQL service is running and the database is world readable.

Log in to the machine and try the following:


 * Good Test - try to behave correctly
 * Edit files in home directory.
 * files to home directory and  directory.
 * Copy files to  directory.
 * Verify that the content is viewable via Apache.


 * Bad Test - try to do evil
 * Try to  off the machine.
 * Try any network protocol, try to get off the machine (ssh, mail, rsh, telnet etc.)
 * Copy an executable into home directory and try to execute it.
 * Try to read a file in the  directory.
 * Try to read the MySQL database.

{| ! User ! Passed ! Failed ! Skipped ! References ! User:czhang ! G1.G3.B1.B2.B3.B4.B5 ! G4 ! G2 !. Create a directory named. Install MySQL. Make sure MySQL service is running and the database is world readable.

Log in to the machine and try the following:


 * Good Test - try to behave correctly
 * Edit files in home directory.
 * Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify that flash works.
 * Plug in USB disk and make sure  user can read/write the disk.
 * Plug in USB camera and make sure it works.
 * Plug in other USB devices.
 * Verify Network Manager works.
 * Verify printing from Firefox and from the desktop works.


 * Bad Test - try to do evil
 * Try to  off the machine.
 * Try any network protocol, try to get off the machine (ssh, mail, rsh, telnet etc.)
 * Copy an executable into home directory and try to execute it.
 * Try to read a file in the  directory.
 * Try to read the MySQL database.

{| ! User ! Passed ! Failed ! Skipped ! References ! User:czhang ! G1.G5.G6.G7 .B1~B5 ! G2 .G3 ! G4 !. Create a directory named. Install MySQL. Make sure MySQL service is running and the database is world readable.

Log in to the machine and try the following:


 * Good Test - try to behave correctly
 * Edit files in home directory
 * Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
 * Verify other network protocols work (aol, ssh, mail etc.)
 * Plug in USB disk and make sure  user can read/write disk.
 * Plug in USB camera and make sure it works.
 * Plug in other USB devices.
 * Verify Network Manager works.
 * Verify printing from Firefox and from the desktop works.


 * Bad Test - try to do evil
 * Try to  off the machine.
 * Try to break into the root account via,.
 * Copy an executable into home directory and try to execute it.
 * Try to read a file in the  directory.
 * Try to read the MySQL database.

{| ! User ! Passed ! Failed ! Skipped ! References\ ! guaneryu ! G.1 G.2 G.3 G.7 B.1 B.2 B.4 B.5 ! B.3 ! G4~G6 .G8 !. Create a directory named. Install MySQL. Make sure MySQL service is running and the database is world readable.

Log in to the machine and try the following:


 * Good Test - try to behave correctly
 * Edit files in home directory.
 * Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
 * Verify other network protocols work (aol, ssh, mail etc.)
 * Plug in USB disk and make sure  user can read/write disk.
 * Plug in USB camera and make sure it works.
 * Plug in other USB devices.
 * Verify Network Manager works.
 * Verify printing from Firefox and from the desktop works.
 * Try to  off the machine
 * Copy an executable into home directory and try to execute it.
 * Set up  and SELinux to allow   to become   via  . add a record to sudoers using visudo:
 * Execute sudo sh and make sure you end up as unconfined_t.
 * Bad Test - try to do evil
 * Try to break into the root account via.
 * Try to read a file in the  directory.
 * Try to read the MySQL database.

{| ! User ! Passed ! Failed ! Skipped ! References ! User:jbao ! G1.G2.G3.G4.G8.G9.G10.G11.G12.B1~B3 ! G7 ! G5~G6 !  get destroyed on logout.}}

As root set up a client machine, with network access. Make sure  package is installed.

Log in to the machine and try the following:


 * Good Test - try to behave correctly
 * Edit files in home directory.
 * Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
 * Plug in USB disk and make sure the kiosk user can read/write the disk.
 * Plug in USB camera and make sure it works.
 * Plug in other USB devices.
 * Verify that Network Manager works.
 * Verify printing from Firefox and from the desktop works.
 * Logout and login to verify that home directory disappeared.
 * Verify that password is not required.


 * Bad Test - try to do evil
 * Try to  off the machine.
 * Try any network protocol, try to get off the machine (ssh, mail, telnet, rsh etc.)
 * Copy an executable into home directory and try to execute it.
 * Try to read a file in the  directory.
 * Try to read the MySQL database.
 * Verify that you can not  into the machine as.

{| ! User ! Passed ! Failed ! Skipped ! References ! jkoten ! G1 G2 ! G8 G9 ! B1-6 !  (Example how to create confined SELinux user). Add an user which can log in as.

Log in to the machine and try the following:


 * Good Test - try to behave correctly
 * Edit files in home directory.
 * Verify you can send a mail as this user.


 * Bad Test - try to do evil
 * Try to break into the root account via.
 * Try to read a file in the  directory.
 * Try to read the MySQL database.

{| ! User ! Passed ! Failed ! Skipped ! References
 * ebenes      ||  G1,G2, B1,B2,B3         ||              ||       ||     (Example how to create confined SELinux user). Add an user which can log in as   . Set up a transition from   to  . Set up   to make this happen automatically. Create a directory named   and install MySQL . Make sure MySQL is running  and the database is world readable. Install Apache  and make sure the service is running.
 * ebenes      ||  G1,G2, B1,B2,B3         ||              ||       ||     (Example how to create confined SELinux user). Add an user which can log in as   . Set up a transition from   to  . Set up   to make this happen automatically. Create a directory named   and install MySQL . Make sure MySQL is running  and the database is world readable. Install Apache  and make sure the service is running.

Log in to the machine and try the following:


 * Good Test - try to behave correctly
 * Edit files in home directory.
 * Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
 * Verify other network protocols work (aol, ssh, mail etc.)
 * Plug in USB disk and make sure the confined administrator can read/write the disk.
 * Plug in USB camera and make sure it works.
 * Plug in other USB devices.
 * Verify Network Manager works.
 * Verify printing from Firefox and from the desktop works.
 * Try to  off the machine.
 * Copy an executable into home directory and try to execute it.
 * Set up  and SELinux to allow   to become   via.
 * Execute  and make sure you end up as.
 * Try to edit  directory and some of the MySQL directories.
 * Try to stop and start MySQL and Apache ( and  ).


 * Bad Test - try to do evil
 * Try to break into the root account via.
 * Try to read a file in the  directory.
 * Try to read the MySQL database.
 * As  try to add an user, modify files in.

Links

 * 1) http://docs.fedoraproject.org/selinux-user-guide/f10/en-US/sect-Security-Enhanced_Linux-Targeted_Policy-Confined_and_Unconfined_Users.html
 * 2) http://magazine.redhat.com/2008/07/02/writing-policy-for-confined-selinux-users/
 * 3) http://www.linuxtopia.org/online_books/fedora_selinux_guides/fedora_10_selinux_user_guide/fedora_10_selinux_sect-Security-Enhanced_Linux-Targeted_Policy-Confined_and_Unconfined_Users.html
 * 4) http://selinux-mac.blogspot.com/2009/06/selinux-lockdown-part-one-confined.html