LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-21-2012, 05:40 AM   #1
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
SELinux - confining regular user: Unexpected result


Hi all,

I'm rather new to SELinux and decided it was time to get acquainted with this material.

While playing around with confining users I ran into the following unexpected result:

I created a regular user and applied the following commands to restrict this user to the user_u role and check the result:
Code:
# semanage login -a -s user_u tstuser
# semanage login -l

Login Name                SELinux User              MLS/MCS Range            

__default__               unconfined_u              s0-s0:c0.c1023           
tstuser                   user_u                    s0                       
root                      unconfined_u              s0-s0:c0.c1023           
system_u                  system_u                  s0-s0:c0.c1023
If I log in as tstuser all works as expected:
Code:
$ whoami
tstuser

$ id -Z
user_u:user_r:user_t:s0

$ su -
-bash: su: command not found
The following, however, was not what I expected:

After logging in as a different, unconfined user and then log in as tstuser using su - tstuser all the confinement for tstuser is gone.
Code:
$ ssh druuna@192.168.122.100
druuna@192.168.122.100's password: 

[druuna ~]$ id -Z
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[druuna ~]$ su - tstuser
Password: 

[tstuser ~]$ id -Z
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[tstuser ~]$ su -
Password:
[root ~]# 
To make sure all settings are applied I:
- logged out all users and redid the above login steps-> same result
- rebooted and redid all the login steps -> same result

Am I overlooking something, 'cause this "feels" wrong.
Or is this by design? And if so, what is the logic behind this?

Using the staff_u role instead of the user_u role doesn't make any difference.

Tests are executed on (virtualized) RHEL 6.2
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-21-2012, 06:11 PM   #2
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
I am rather new to SELinux myself, but I think what is happening is that your rules are only temporary unless you use the commands to actually create a (permanent) rule that gets reloaded. I found this link for the CentOS wiki to be quite helpful in understanding SELinux and since your running RH, it should apply to your version too.
 
Old 03-22-2012, 02:13 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Original Poster
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi Noway2,
Quote:
Originally Posted by Noway2 View Post
I am rather new to SELinux myself, but I think what is happening is that your rules are only temporary unless you use the commands to actually create a (permanent) rule that gets reloaded. I found this link for the CentOS wiki to be quite helpful in understanding SELinux and since your running RH, it should apply to your version too.
Yes, certain parts of SELinux need to be made permanent to survive a reboot, the setsebool tool is an example (you need to use the -P option to make it stick). Using semanage to set a role does survive a reboot. I did not take the author's word for it, I actually tried and it does stick.

The questions isn't about what sticks when, but why a user role isn't enforced when that specific user doesn't log in using the "noraml" CLI/GUI but uses su (or su -) from a terminal started by a different (unconfined) user (see the last code block in my first post).

I have to assume that there is a lack of understanding on my side, but it does look like a way to circumvent the specific user role that was set.

BTW: Thanks for the link!
 
Old 03-22-2012, 07:20 AM   #4
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Druuna, thank you for clarifying. Now I understand the problem now and would have to say that it goes over my understanding of SELinux. I too have just begun to try and learn how to use it effectively. Yesterday, I read on Wikipedia that the permissions structure is tied to the inode and that things like moving and replacing files will cause it to break. It sounds like there is something similar at work where the process path doesn't execute the same way when SU is used, but my understanding of SELinux limits me to vague speculation. I'm pretty sure that there are a couple of expert level users here and perhaps one of them can shed some light on this.
 
Old 03-30-2012, 08:37 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Original Poster
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I might have found the reason for the above mentioned behaviour: SELinux - 4.2. Unconfined Processes (RHEL6).

Do read the full chapter when you are interested, but I do believe it boils down to this:
Quote:
Processes running in unconfined domains fall back to using DAC rules exclusively.
Closing this thread. If and when I find additional info I will add it.
 
2 members found this post helpful.
Old 03-30-2012, 10:25 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Well I for one didn't realize that was the case. Learned something new. Thanks.
 
  


Reply

Tags
selinux



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vsFTP - confining a user to one directory? arashi256 Linux - Software 4 06-15-2008 10:21 AM
LXer: Fedora 9 and Summit preview: Confining the user with SELinux LXer Syndicated Linux News 0 04-18-2008 03:30 AM
mysql count(*) unexpected result kpachopoulos Programming 3 01-03-2008 10:08 AM
MySQL queries from Shell - unexpected result philipz Programming 5 05-04-2004 05:38 PM
cp command problem..... unexpected result hamster Linux - General 2 04-10-2003 04:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration