Bug 846473

Summary: policy for miredo ( with a patch )
Product: [Fedora] Fedora Reporter: Michael S. <misc>
Component: selinux-policy-targetedAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED EOL QA Contact: Ben Levenson <benl>
Severity: low Docs Contact:
Priority: unspecified    
Version: 19CC: dwalsh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 730822 Environment:
Last Closed: 2015-02-18 13:45:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 730822    
Bug Blocks:    

Description Michael S. 2012-08-07 21:12:50 UTC
+++ This bug was initially created as a clone of Bug #730822 +++

Miredo, a ipv6 over ipv4 tunnel tool is running without being confined. So here is a policy file for it.
That's my first policy, and while I tested it ( and the tunnel is working ), that's also the first policy I wrote, based on various internet documentation. So some stuff could likely be missing ( like some interfaces ), or the policy could be overengineered, or too fragile, so I would welcome feedback on it.

I tested on fedora 15, just installed miredo-client, started it, and tried to ping ipv6 enabled web site ( www.free.fr , in this case ). There is no message in /var/log/audit/audit.log, and everything work fine.

--- Additional comment from misc on 2011-08-15 16:43:03 EDT ---

Created attachment 518336 [details]
Type enforcement policy for miredo

--- Additional comment from misc on 2011-08-15 16:43:41 EDT ---

Created attachment 518337 [details]
interface for miredo policy

--- Additional comment from misc on 2011-08-15 16:45:26 EDT ---

Created attachment 518338 [details]
File context for miredo policy

--- Additional comment from dwalsh on 2011-08-16 08:04:18 EDT ---

require {
        type tun_tap_device_t;
        type random_device_t;
        type sysctl_kernel_t;
        type proc_net_t;
        type shell_exec_t;
        type bin_t;
        type ifconfig_exec_t;
        type proc_t;
}

Should never be used within a te file, that is being submitted for upstream use.  You need to use interfaces.

audit2allow -R 

Is helpful in finding interfaces that match the AVC's that you were seeing.

--- Additional comment from dwalsh on 2011-08-16 08:09:03 EDT ---

# for executing client_hook with bash 
# should we use corecmd_exec_shell ?
allow miredo_helper_t shell_exec_t:file { read execute open };
allow miredo_helper_t bin_t:lnk_file read;

Should be 

corecmd_exec_shell(miredo_helper_t)

allow miredo_client_hook_t proc_t:file { read open getattr };

kernel_read_system_state(miredo_client_hook_t)

allow miredo_t random_device_t:chr_file { read open };

dev_read_random(miredo_t)

# miredo read ngroups_max and others files for changing dropping privileges
allow miredo_t sysctl_kernel_t:file { read open };
allow miredo_t sysctl_kernel_t:dir search;

Does miredo ever write to these devices?

kernel_rw_kernel_sysctl(miredo_t)

allow miredo_t proc_t:file read;

kernel_read_system_state(miredo_t)

allow miredo_t proc_net_t:file read;

kernel_read_network_state(miredo_t)


Interface definitions are stored in /usr/share/selinux/devel/include/...

--- Additional comment from misc on 2011-08-16 09:38:14 EDT ---

I do not understand the comment #4, audit2allow tell me to use the various types with requires : 

# grep 1313436933.639:702307   /var/log/audit/audit.log | audit2allow -R 

require {
	type ifconfig_t;
	type miredo_client_hook_t;
	class process { siginh noatsecure rlimitinh };
}

#============= miredo_client_hook_t ==============
#!!!! This avc has a dontaudit rule in the current policy

allow miredo_client_hook_t ifconfig_t:process { siginh rlimitinh noatsecure };

But i see the point about using interfaces, that's indeed clearer. There is lots of them, and it was not obvious at first sight which one would be useful. I will correct this and upload a new version of the .te file later after testing.

--- Additional comment from dwalsh on 2011-08-16 10:22:41 EDT ---

Are you running with dontaudit disabled.

semodule -B 

will turn them back on and these AVC's will dissappear.

--- Additional comment from misc on 2011-08-16 10:29:35 EDT ---

Yes, the avc was just here to act as a example. I disabled dontaudit to catch some avc that were silently ignored 

Trying to apply what you told me, I face a problem :

+ make -f /usr/share/selinux/devel/Makefile
Compiling targeted miredo module
/usr/bin/checkmodule:  loading policy configuration from tmp/miredo.tmp
miredo.te":87:ERROR 'syntax error' at token 'dev_read_random' on line 13776:
dev_read_random(miredo_t)

And a quick search show that dev_read_random do not seems to exist on f15.

Regarding writing to /proc, I found by reading code that miredo write 0 to /proc/sys/net/ipv6/conf/teredo/accept_redirects , and I didn't catched it with my tests. However, it also fail silently ( and yet open a potential security problem with icmp redirect ).
 
So read write access should be added to file with the  sysctl_net_t , I assume that kernel_rw_net_sysctls is the proper 
 interface.

--- Additional comment from misc on 2011-08-16 10:49:24 EDT ---

Ok, so the missing interface is  dev_read_urand . I removed all requires in the .te, and I will test and upload the new version for comment.

--- Additional comment from misc on 2011-08-16 11:40:30 EDT ---

Created attachment 518520 [details]
Type enforcement policy for miredo

Newer version of the type enforcement policy

--- Additional comment from mgrepl on 2011-08-22 04:02:16 EDT ---

Created attachment 519237 [details]
miredo.te patch

I made some fixes and attached the patch for your .te file.

--- Additional comment from endoflife on 2012-08-07 13:20:07 EDT ---

This message is a notice that Fedora 15 is now at end of life. Fedora
has stopped maintaining and issuing updates for Fedora 15. It is
Fedora's policy to close all bug reports from releases that are no
longer maintained. At this time, all open bugs with a Fedora 'version'
of '15' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that
we were unable to fix it before Fedora 15 reached end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora, you are encouraged to click on
"Clone This Bug" (top right of this page) and open it against that
version of Fedora.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

The process we are following is described here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 1 Fedora End Of Life 2013-04-03 16:18:24 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 2 Michael S. 2013-06-29 20:09:39 UTC
So, anything missing on this bug for being fixed ? Miredo is still running unconfined, and i am not sure on what to do next to have this merged.

Comment 3 Miroslav Grepl 2013-07-01 11:25:47 UTC
I apologize. I dropped ball on this. Just checking it.

Do we need to have 3 domains?

Comment 4 Miroslav Grepl 2013-07-01 11:29:53 UTC
Michael,
could you play around

# sepolicy generate --init -n miredo /usr/sbin/miredo-server 
# sh miredo.sh

on F19. Thank you.

Comment 5 Michael S. 2013-07-01 12:38:48 UTC
You mean miredo_helper_t miredo_t and  miredo_client_hook_t ?

That's indeed overkill, but I prefer to keep the process handling network input spearate from the others. Miredo run in different process, so it make sense to restrict as much as possible those that do not need network access. 

But that was my first attempt at a policy, so this is likely full of beginner mistakes, I will post a 2.0 with less domains, and using macros, etc.

Comment 6 Miroslav Grepl 2013-07-01 13:35:05 UTC
It is correct and it is good to think this way. But for example I see that net_admin cap is needed by both midero domains.

Comment 7 Fedora End Of Life 2015-01-09 21:59:52 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Fedora End Of Life 2015-02-18 13:45:16 UTC
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.