LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-03-2017, 09:49 AM   #1
ricksanchez36
LQ Newbie
 
Registered: Oct 2017
Posts: 1

Rep: Reputation: Disabled
Post SELinux - Audit2allow Question


Security team at my company decided that they want us to start running SELinux as an extra level of security on our Linux servers. They don’t care how we implement it, just that it’s set to enforcing. To implement this change we figure it would be easiest to run audit2allow on all systems to build the rules and then just hit each server one at a time after verifying everything is working correctly. After using audit2allow on a few systems I’m noticing some strange behavior that I wanted to post about. I can’t figure out if this is by design or if I’m using it wrong.

1. I tried to kick off a virus scan after installing SELinux and it was blocked. After I ran 'audit2allow -a -M allowlist' then re-ran the virus scanner it had a second deny. I then re-run audit2allow 'audit2allow -a -M allowlist' which I figured would see the additional deny (all denies) in the logs and then over-ride the allowlist module with all the rules. When I re-ran the virus scan it was denied again and then after checking audit2allow it seemed to show that it needed the first rule again. After re-running this a few times to confirm I gave up and instead ran 'audit2allow -a -M allowlist_1', ran virus scanner again followed by 'audit2allow -a -M allowlist_2'. I'm not sure why it wouldn't see all denies and add them all to one module.

2. Is there a way to compile a list of rules using audit2allow and then just copy that module to different servers to install? Sort of like a golden list… If so I'm trying to decide between combining every allow rule from all RHEL7 servers or making a few groups since some of our servers are similar. So far since we have a core set of software on all servers (syslog, antivirus, rhsm, etc) I’m seeing all the same denies so it seems silly not to just certify that this one list is OK to install globally / on our main template.


Thanks!
 
Old 10-03-2017, 10:42 AM   #2
dac.override
LQ Newbie
 
Registered: Oct 2016
Posts: 24

Rep: Reputation: Disabled
You have overwritten your previous "allowlist" module with a new one. Because the names of the modules were the same.

To get a broader view of the permissions a particular process needs, you should test the functionality in permissive mode or preferably with the process type declared permissive type (semanage permissive -a/-d mytype_t)

-- make sure to remove any permissive type declarations that you added while testing!:
1. to list existing permissive types: semanage permissive -l
2. to remove a permissive type (mytype_t): semanage permissive -d mytype_t

Example: To read a file successfully various permissions are required in particular order

1. needs to be able to get to the file (traverse parent directories)
2. needs to be able to get attributes of the file (test whether the file exists (test -f myfile )
3. open the file
4. read the file
5. maybe lock the file, use ioctls etc

If any of these steps are blocked then the process might not be able to proceed and it might stop trying
for example if step 2 is blocked by SELinux then the process might think the file does not exist and act accordingly)

So to get the fuller picture you have to make sure that when in a testing phase the process is allowed to do what it wants, but SELinux would log what it would normally would have blocked in enforcing mode

audit2allow with the -r option can be used to tell audit2allow to print out the rules translated from the SELinux events and their requiements.

This output can then be pasted into a new file with a .te suffix

You should manually add a module declaration on top of the file.

echo "module mymodule 1.0.0;" > mymodule.te
ausearch -m avc,user_avc -ts recent | audit2allow -r >> mymodule.te

then you can manually build and install the mymodule.te source policy module (after reviewing the contents of mymodule.te):

checkmodule -M -m mymodule.te -o mymodule.mod
semodule_package -o mymodule.pp -m mymodule.mod
semodule -i mymodule.pp
semodule -l | grep mymodule

Remember that modules with the same module name that are installed using the same priority will be overwritten! and that if theyre not installed with the same priority, that the module on the highest priority takes precedence.
.
although not strictly needed. it is good to keep a copy of the source policy file (mymodule.te) for reference and for your co-workers so that they can see what is in there) . Can also be handy if later on you want to append some new rules to the module.

alternatively you can use semodule to export the loaded version in a readable cil language:

semodule --cil -E mymodule && cat mymodule.cil

Last edited by dac.override; 10-03-2017 at 11:02 AM.
 
3 members found this post helpful.
Old 10-03-2017, 01:10 PM   #3
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 190

Rep: Reputation: 51
I would copy policies.
Perhaps even keep then in a repo.

Also when you start moving files in an SElinux environment don't forget to set the right context in files.
 
1 members found this post helpful.
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: SELinux - Audit2allow should be your third option not the first. LXer Syndicated Linux News 0 04-18-2013 02:10 PM
RHEL6 audit2allow policy savona Linux - Server 3 07-13-2011 11:25 AM
SELinux create policy with audit2allow tinymark Linux - Security 4 03-21-2009 04:17 PM
SELINUX Question Iamriccati Linux - Server 2 12-04-2007 04:23 PM
audit2allow messages lothario Linux - Security 2 07-05-2006 11:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:54 AM.

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