From Fedora Project Wiki

Revision as of 15:56, 21 October 2009 by Tpelka (talk | contribs) (→‎xguest_u)

DATE TIME WHERE
Tue Oct 20, 2009 ALL DAY #fedora-test-day)

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:

user role terminal login xwindows login network exec in homedir setuid notes
guest_u yes no no no no
xguest_u yes yes no* no no * only Firefox
user_u yes yes yes no no
staff_u yes yes yes yes no* * sudo allowed
kiosk user yes yes no no no No password required. Home directory and /tmp get destroyed on logout.
confined admin yes yes yes yes yes Able to manage only a predefined set of services.

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

  • 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 yum install PACKAGE as root to install them and check that their versions match:
    • selinux-policy-targeted-3.6.32-24.fc12
    • policycoreutils-gui-2.0.74-4.fc12
    • setroubleshoot-2.2.37-1.fc12
    • audit-2.0.1-1.fc12
    • xguest-1.0.7-7.fc12
  • The content of /var/log/messages will be useful during testing and reporting issues. Connect to your test system and prepare the system for gathering output using the commands below:
echo > /var/log/audit/audit.log
service auditd restart
service messagebus start
service restorecond restart
setenforce 1
tail -f /var/log/messages
No production testing
Please do not use production machine for this testing.

Live Image

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

Architecture SHA256SUM
i686 b4c8631aeb40bf4594bbb64c189b1c66f0c7f7cd763ae50ce8f6ce800746aee4
x86_64 fa4e971ed3af85b4aaf7ac5630b0efce5b51c11749dc13b42556cfc7ccf5af56

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 xguest_u and try to run ping or sudo 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 (mutt, alpine etc.)
  2. editors (vim, emacs, nano etc.)
  3. networking tools (ping, traceroute 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).

audit.log upload
Be so kind and upload your /var/log/audit/audit.log after you finish the testing. Please leave a reference to it in the following table. This action is optional but it will help us not to forget/miss any of possible AVC messages.
User audit.log references

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 (setenforce 0) 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 (setenforce 1) before next testing. Root shell is needed.
  2. ausearch - Run ausearch 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. sealert - Look at the end of /var/log/messages and search for messages containing sealert. Run sealert 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 sealert.
Before filing...
Do not file a bug if the user you are testing now is by the SELinux role prevented from doing certain things (e.g. guest_u is prevented from using network, staff_u is prevented from running su). The actions you are trying to do under userX must make sense considering the SELinux role of the userX.

Here is an example how to display AVCs which arose since a specific time:

  1. START_DATE_TIME=date "+%m/%d/%Y %T"
  2. do something as confined user
  3. ausearch -m AVC -ts $START_DATE_TIME

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:

User Passed Failed Skipped References
User:mmalik G.1 G.2 B.1 B.2 B.3 G.3 G.4

guest_u

User capabilities
Terminal login, nosetuid, nonetwork, noxwindows, noexec in home directory

As root set up a server only machine, with Apache service (yum install httpd). Configure Apache in such a way that user home directories are accessible. Make sure Apache service is running (service httpd start). Add an user which can log in as guest_u (useradd -Z guest_u USERNAME). Create a directory named /secrets. Install MySQL (yum install mysql-server). Make sure MySQL service is running (service mysqld start) and the database is world readable.

Log in to the machine and try the following:

  • Good Test - try to behave correctly
    1. Edit files in home directory.
    2. scp files to home directory and public_html directory.
    3. Copy files to public_html directory.
    4. Verify that the content is viewable via Apache.
  • Bad Test - try to do evil
    1. Try to ping off the machine.
    2. Try any network protocol, try to get off the machine (ssh, mail, rsh, telnet etc.)
    3. Copy an executable into home directory and try to execute it.
    4. Try to read a file in the /secrets directory.
    5. Try to read the MySQL database (mysqlshow).
User Passed Failed Skipped References
User:czhang G1.G3.B1.B2.B3.B4.B5 G4[1] G2[2]
  1. need chmod 711 /home/USER and execute setsebool -P httpd_enable_homedirs=1
  2. I don't understand what does this step means, scp from localhost to localhost?
User:hdong G1.G3.B1~B5 G4[1] G2[2]
  1. don't have permission to access /~guest_u/ on server
  2. ssh Permission denied
User:Rhe G1,G2,G3,B3,B4,B5 G4[1], B1[2], B2[3]
  1. need chmod 711 /home/USER and execute setsebool -P httpd_enable_homedirs=1 as czhang said
  2. can ping
  3. can ssh
User:tpelka G1~3,G4[1],B1~5
  1. Agree with czhang, but 701 is sufficient
User:mmaslano G1,G2,G3,G4,B1,B2,B3 B4,B5 Directions are ambiguous. Howto apache was missing.
varekova G1~G3,B1~B5 G4 [1]
  1. problems with setting up Appache - it would be good to have describe this step more precisely
User:psss G1, G2, G3, B1, B2, B3, B4, B5 G4[1]
  1. restorecond -u not running for guest_u (running restorecon -R public_html or adding "~/* ~/public_html/*" to /etc/selinux/restorecond.conf resolves the problem)
Filed bugs #529852 and #529827.
User:mmalik G1, G2, G3, B1, B2, B3, B4, B5 G4[1]
  1. chmod 711 /home/USER, setsebool httpd_enable_homedirs=1, restorecon -Rv /home/USER were needed

xguest_u

User capabilities
X Windows login and terminal login, nosetuid, nonetwork, noexec in home directory

As root set up a client machine, with network access. Add an user which can log in as xguest_u (useradd -Z xguest_u USERNAME). Create a directory named /secrets. Install MySQL (yum install mysql-server). Make sure MySQL service is running (service mysqld start) and the database is world readable.

Log in to the machine and try the following:

  • Good Test - try to behave correctly
    1. Edit files in home directory.
    2. Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify that flash works.
    3. Plug in USB disk and make sure xguest_u user can read/write the disk.
    4. Plug in USB camera and make sure it works.
    5. Plug in other USB devices.
    6. Verify Network Manager works.
    7. Verify printing from Firefox and from the desktop works.
  • Bad Test - try to do evil
    1. Try to ping off the machine.
    2. Try any network protocol, try to get off the machine (ssh, mail, rsh, telnet etc.)
    3. Copy an executable into home directory and try to execute it.
    4. Try to read a file in the /secrets directory.
    5. Try to read the MySQL database (mysqlshow).
User Passed Failed Skipped References
User:czhang G1.G5.G6.G7[1].B1~B5 G2[2].G3[3] G4[4]
  1. Firefox core dumped, but desktop printing is normal
  2. Firefox core dumped,can't test. Maybe RHBZ #512845 describes this bug.
  3. ntfs disks is readable/writable, ext2/3/4 are not permitted in enforce mode, setenforce 0 could solve this problem.
  4. no device
guaneryu G.1 G.2[1] G.6 G.7 B.1~B.5 G.3~G.5[2]
  1. Start firefox with 'firefox -safe-mode'
  2. no device
User:jbao G.1 G.2 G.3 G.7 B.1~B.5 G.6[1] G.4~G.5[2]
  1. can't start the NetworkManager
  2. no device
hdong G1.G2.G3.G7 B1~B5 G6[1] G4.G5[2]
  1. NetworkManager applet icon disappear
  2. no device
User:Rhe G1.G5.B1~B5 G2[1].G3[2].G6[3][4] G4.G7
  1. a crash in package firefox-3.5.3-1.fc12 has been detected.RHBZ #530007
  2. couldn't display
  3. unrecognised service.RHBZ #530013
  4. cant run selinux management RHBZ #530005
varekova G1 G6 B1~B5 G2[1] G3~G5[2]
  1. firefox problem, with 'firefox -safe-mode' OK
  2. virt. machines
User:mmaslano G1 G2 G3 G6 G7 B1-4 G4 G5 FF worked firefox-3.5.3-1.fc12.x86_64. I have updated rawhide.
jkoten G1 G3 G6 B1-5 G2[1] G7
  1. cannot play streamed video using totem-mozplugin RHBZ #529847
User:psss G1, G3, G6, B1, B2, B3, B4, B5 G2[1] G4, G5, G7
  1. Firefox crashes, works only in -safe-mode
Filed bug #529878 - Unable to login after logout
User:mmalik G1, B1, B2, B3, B4, B5 G2[1] G3, G4, G5, G6, G7
  1. Firefox crashes, must be executed with -safe-mode
User:tpelka [1]G1~3,G7,B1,B2,B3,B4,B5 G4,G5,G6[2]
  1. First login as xguest_u cause gphoto2 support for gvfs crash, RHBZ #530091
  2. no device

user_u

User capabilities
X Windows login and terminal login, nosetuid, noexec in home directory

As root set up a client machine, with network access. Add an user which can log in as user_u (useradd -Z user_u USERNAME). Create a directory named /secrets. Install MySQL (yum install mysql-server). Make sure MySQL service is running (service mysqld start) and the database is world readable.

Log in to the machine and try the following:

  • Good Test - try to behave correctly
    1. Edit files in home directory
    2. Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
    3. Verify other network protocols work (aol, ssh, mail etc.)
    4. Plug in USB disk and make sure user_u user can read/write disk.
    5. Plug in USB camera and make sure it works.
    6. Plug in other USB devices.
    7. Verify Network Manager works.
    8. Verify printing from Firefox and from the desktop works.
  • Bad Test - try to do evil
    1. Try to ping off the machine.
    2. Try to break into the root account via su, sudo.
    3. Copy an executable into home directory and try to execute it.
    4. Try to read a file in the /secrets directory.
    5. Try to read the MySQL database (mysqlshow).
User Passed Failed Skipped References\
guaneryu G.1 G.2 G.3 G.7 B.1 B.2 B.4 B.5 B.3[1] G4~G6[2].G8
  1. cd;cp /bin/ls ~/;./ls; can execute ls command at home directory
  2. no device
User:jbao G1.G2.G3.G4.G8 B1.B2.B4.B5 G7[1] B3[2] G5~G6[3]
  1. can't start the NetworkManager,with the error"(nm-applet:5910): Gtk-WARNING **: cannot open display: "
  2. RHBZ #529830
  3. no device
varekova G.1 G.3 G.7 B.1 B.2 B.4 G2[1] B.3[2] G.4~G.6, G.8[3]
  1. firefox problem
  2. RHBZ #529830
  3. virt machine
User:mmaslano G1-5 G7 B2-4 B1 B5 G6 G6 no NM applet in KDE tray
User:Rhe G1.G3.G4.G6.B1.B2.B4.B5 G2[1].G7[2].B3[3] G5.G8
  1. firefox crash.RHBZ #530007
  2. unrecognized service.RHBZ #530013
  3. executable.RHBZ #529830
User:hdong G1.G2.G3.G4.G8.B1.B2.B4.B5 G7[1].B3[2] G5.G6[3]
  1. Permission denied and applet icon disappear
  2. executable.RHBZ #529830
  3. no device
User:tpelka G1~3,G7,G8,B1,B2,B4,B5 B3[1] G4,G5,G6[2]
  1. same as guaneryu [1]
  2. no device

staff_u

User capabilities
X Windows login and terminal login, nosetuid except sudo

As root set up a client machine, with network access. Add an user which can log in as staff_u (useradd -Z staff_u USERNAME). Create a directory named /secrets. Install MySQL (yum install mysql-server). Make sure MySQL service is running (service mysqld start) and the database is world readable.

Log in to the machine and try the following:

  • Good Test - try to behave correctly
    1. Edit files in home directory.
    2. Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
    3. Verify other network protocols work (aol, ssh, mail etc.)
    4. Plug in USB disk and make sure staff_u user can read/write disk.
    5. Plug in USB camera and make sure it works.
    6. Plug in other USB devices.
    7. Verify Network Manager works.
    8. Verify printing from Firefox and from the desktop works.
    9. Try to ping off the machine
    10. Copy an executable into home directory and try to execute it.
    11. Set up sudo and SELinux to allow staff_t to become unconfined_t via sudo.
      # semanage user -m -R "staff_r unconfined_r system_r" staff_u
      add a record to sudoers using visudo:
      USERNAME ALL=(ALL) TYPE=unconfined_t ROLE=unconfined_r ALL
    12. Execute sudo sh and make sure you end up as unconfined_t.
      # sudo sh
      # id -Z
  • Bad Test - try to do evil
    1. Try to break into the root account via sudo.
    2. Try to read a file in the /secrets directory.
    3. Try to read the MySQL database (mysqlshow).
User Passed Failed Skipped References
User:jbao G1.G2.G3.G4.G8.G9.G10.G11.G12.B1~B3 G7[1] G5~G6[2]
  1. can't start the NetworkManager
  2. no device
guaneryu G.1~G.3 G.7 G.9~G.12 B.1~B.3 G.4~G.6 G.8[1]
  1. no device
varekova G.1 G.3 G.7 G.9~G.12 B.1~B.3 G.2[1] G.4~G.6 G.8[2]
  1. firefox problem
  2. virt machine
User:Rhe G1. G3. G4. G6. G9. G10. B1~B3 G2[1]. G7[2]. G11[3] G5. G6. G12
  1. firefox crash.RHBZ #530007
  2. unrecognised service.RHBZ #530013
  3. /user/sbin/semanage:SElinux Policy is not managed or store cannot be accessed.
User:hdong G1.G2.G3.G4.G8.G9.G10.G11.G12 B1~B3 G7[1] G5.G6[2]
  1. Permission denied and applet icon disappear.RHBZ #530013
  2. no device
User:tpelka G1~3,G7,G8,B1,B2,B4,B5 B3Cite error: Invalid <ref> tag; refs with no name must have content G4,G5,G6[1]
  1. no device

Kiosk user

User capabilities
X Windows login and terminal login, nosetuid, nonetwork, noexec in home directory. NO password required. Home directory and /tmp get destroyed on logout.

As root set up a client machine, with network access. Make sure xguest package is installed (yum install xguest).

Log in to the machine and try the following:

  • Good Test - try to behave correctly
    1. Edit files in home directory.
    2. Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
    3. Plug in USB disk and make sure the kiosk user can read/write the disk.
    4. Plug in USB camera and make sure it works.
    5. Plug in other USB devices.
    6. Verify that Network Manager works.
    7. Verify printing from Firefox and from the desktop works.
    8. Logout and login to verify that home directory disappeared.
    9. Verify that password is not required.
  • Bad Test - try to do evil
    1. Try to ping off the machine.
    2. Try any network protocol, try to get off the machine (ssh, mail, telnet, rsh etc.)
    3. Copy an executable into home directory and try to execute it.
    4. Try to read a file in the /secrets directory.
    5. Try to read the MySQL database (mysqlshow).
    6. Verify that you can not ssh into the machine as xguest_u.
User Passed Failed Skipped References
jkoten G1 G2 G8[1] G9[2] B1-6 [3]
  1. home dir still present - even before login for the first time
  2. cannot login after logout RHBZ #529847
  3. cannot login again :(
User: Rhe [1]
  1. how to be a kiosk user??
User:hdong G1.G2.G3.G7 G8[1].G9[2] G4.G5[3]G6 B1~B6[4]
  1. home dir still present,temporary files in home dir disappear
  2. cannot login again
  3. no device
  4. can not login

Guest user that can send an email

As root set up a server machine, with network access. Build policy for sendmail_user_t (Example how to create confined SELinux user). Add an user which can log in as sendmail_user_u (useradd -Z sendmail_user_u USERNAME).

Log in to the machine and try the following:

  • Good Test - try to behave correctly
    1. Edit files in home directory.
    2. Verify you can send a mail as this user.
  • Bad Test - try to do evil
    1. Try to break into the root account via sudo.
    2. Try to read a file in the /secrets directory.
    3. Try to read the MySQL database (mysqlshow).
User Passed Failed Skipped References
ebenes TBD

Confined administrator

User capabilities
Administrator that can manage MySQL and Apache

As root set up a client machine, with network access. Build policy for web_db_admin_t (Example how to create confined SELinux user). Add an user which can log in as staff_u (useradd -Z staff_u USERNAME). Set up a transition from staff_t to web_db_admin_t. Set up sudo to make this happen automatically. Create a directory named /secrets and install MySQL (yum install mysql-server). Make sure MySQL is running (service mysqld start) and the database is world readable. Install Apache (yum install httpd) and make sure the service is running (service httpd start).

Log in to the machine and try the following:

  • Good Test - try to behave correctly
    1. Edit files in home directory.
    2. Verify Firefox works and can access the network. Try to load several sites like http://www.ford.com to verify flash works.
    3. Verify other network protocols work (aol, ssh, mail etc.)
    4. Plug in USB disk and make sure the confined administrator can read/write the disk.
    5. Plug in USB camera and make sure it works.
    6. Plug in other USB devices.
    7. Verify Network Manager works.
    8. Verify printing from Firefox and from the desktop works.
    9. Try to ping off the machine.
    10. Copy an executable into home directory and try to execute it.
    11. Set up sudo and SELinux to allow staff_t to become web_db_adm_t via sudo.
    12. Execute sudo sh and make sure you end up as web_db_adm_t.
    13. Try to edit /var/www/html directory and some of the MySQL directories.
    14. Try to stop and start MySQL and Apache (service NAME start and service NAME stop).
  • Bad Test - try to do evil
    1. Try to break into the root account via su.
    2. Try to read a file in the /secrets directory.
    3. Try to read the MySQL database (mysqlshow).
    4. As web_db_adm_t try to add an user, modify files in /usr/share.
User Passed Failed Skipped References

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