Bug 730822 - policy for miredo ( with a patch )
Summary: policy for miredo ( with a patch )
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 15
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks: 846473
TreeView+ depends on / blocked
 
Reported: 2011-08-15 20:41 UTC by Michael S.
Modified: 2012-08-07 21:12 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 846473 (view as bug list)
Environment:
Last Closed: 2012-08-07 17:20:05 UTC


Attachments (Terms of Use)
Type enforcement policy for miredo (3.19 KB, text/plain)
2011-08-15 20:43 UTC, Michael S.
no flags Details
interface for miredo policy (1.29 KB, text/plain)
2011-08-15 20:43 UTC, Michael S.
no flags Details
File context for miredo policy (325 bytes, text/plain)
2011-08-15 20:45 UTC, Michael S.
no flags Details
Type enforcement policy for miredo (2.95 KB, text/plain)
2011-08-16 15:40 UTC, Michael S.
no flags Details
miredo.te patch (4.38 KB, patch)
2011-08-22 08:02 UTC, Miroslav Grepl
no flags Details | Diff

Description Michael S. 2011-08-15 20:41:52 UTC
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.

Comment 1 Michael S. 2011-08-15 20:43:03 UTC
Created attachment 518336 [details]
Type enforcement policy for miredo

Comment 2 Michael S. 2011-08-15 20:43:41 UTC
Created attachment 518337 [details]
interface for miredo policy

Comment 3 Michael S. 2011-08-15 20:45:26 UTC
Created attachment 518338 [details]
File context for miredo policy

Comment 4 Daniel Walsh 2011-08-16 12:04:18 UTC
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.

Comment 5 Daniel Walsh 2011-08-16 12:09:03 UTC
# 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/...

Comment 6 Michael S. 2011-08-16 13:38:14 UTC
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.

Comment 7 Daniel Walsh 2011-08-16 14:22:41 UTC
Are you running with dontaudit disabled.

semodule -B 

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

Comment 8 Michael S. 2011-08-16 14:29:35 UTC
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.

Comment 9 Michael S. 2011-08-16 14:49:24 UTC
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.

Comment 10 Michael S. 2011-08-16 15:40:30 UTC
Created attachment 518520 [details]
Type enforcement policy for miredo

Newer version of the type enforcement policy

Comment 11 Miroslav Grepl 2011-08-22 08:02:16 UTC
Created attachment 519237 [details]
miredo.te patch

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

Comment 12 Fedora End Of Life 2012-08-07 17:20:07 UTC
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


Note You need to log in before you can comment on or make changes to this bug.