Skip to contentSkip to conversation

Firewall Policy

DISCUSSION Reino Wallin 4 participants 9 messages Mar 12, 2002 – Mar 13, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

I just posted a new release of my policy scripts for an application layer firewall. The scripts can be found at
http://www.oribium.com/selinux/
This release is pretty much better then the initial one. They are not yet ready for a production environment though.

I have a few suggestions to improve the example policy as well.

named_t:

To make the nameserver to work as a slave server, we may consider to grant write permissions to named_conf_t:dir and named_conf:file:

inetd_t:

If we allow inetd to setuid, then it will be more flexible, and the daemons can run as non root.

It seems the following line is needed on my machine, but I haven't actually checked this up more in detail.

allow system_crond_t var_lib_rpm_t:dir { add_name remove_name write };

I have modified the network.te, and net_contexts, to allow multiple NIC's and IPSEC features. Patches are enclosed. This will allow a more fine grained control as well.

I think most policy developers will use the example policy as a starting point for their work. I suggest that all new policy scripts for domains should contain all the required networking capabilities, so we don't have to grant full networking rights to all domains anymore.

As far as I can understand there is no need to grant an ftpuser or a popuser the right to change role, neither to have access to a shell. It seems appealing, just to grant a very limited set of rights to the default user, and add a few more user types, like a shell user and a trusted user. Am I wrong here? I am figuring to add a few new user types to my firewall policy. Please let me know your thoughts, and I may put something together that suits the example policy as well.

Signature · 2 lines
Reino Wallin, Oribium Labs
[email protected]

6c6,7
< #
---

Quoted 2 lines

# Modified by Reino Wallin <[email protected]>
# Multi NIC, and IPSEC features

20a22,24

Quoted 3 lines

tcp 9873 system_u:object_r:http_port_t
tcp 9874 system_u:object_r:telnet_port_t
tcp 9875 system_u:object_r:ftp_port_t

32c36,39
<
---

Quoted 4 lines

eth2 system_u:object_r:netif_eth2_t system_u:object_r:netmsg_eth2_t ipsec0 system_u:object_r:netif_ipsec0_t system_u:object_r:netmsg_ipsec0_t ipsec1 system_u:object_r:netif_ipsec1_t system_u:object_r:netmsg_ipsec1_t ipsec2 system_u:object_r:netif_ipsec2_t system_u:object_r:netmsg_ipsec2_t

48c55
< 10.33.1.2 255.255.255.255 system_u:object_r:nfs_t system_u:object_r:nfs_t
---

Quoted 1 line

192.168.2.32 255.255.255.255 system_u:object_r:nfs_t system_u:object_r:nfs_t

4c4,5
<
---

Quoted 2 lines

# Modified by Reino Wallin <[email protected]>
# Multi NIC, and IPSEC features

50a52

Quoted 1 line

type netif_eth2_t, netif_type;

51a54,56

Quoted 3 lines

type netif_ipsec0_t, netif_type;
type netif_ipsec1_t, netif_type;
type netif_ipsec2_t, netif_type;

60a66

Quoted 1 line

type netmsg_eth2_t, netmsg_type;

62c68,70
<
---

Quoted 3 lines

type netmsg_ipsec0_t, netmsg_type;
type netmsg_ipsec1_t, netmsg_type;
type netmsg_ipsec2_t, netmsg_type;

92a101

Quoted 1 line

allow netmsg_eth2_t node_t:node { tcp_recv udp_recv rawip_recv };

94a104,106

Quoted 3 lines

allow netmsg_ipsec0_t node_t:node { tcp_recv udp_recv rawip_recv }; allow netmsg_ipsec1_t node_t:node { tcp_recv udp_recv rawip_recv }; allow netmsg_ipsec2_t node_t:node { tcp_recv udp_recv rawip_recv };

#1 lore raw
Quoted 6 lines · Reino Wallin

I have a few suggestions to improve the example policy as well.

named_t:

To make the nameserver to work as a slave server, we may consider to grant write permissions to named_conf_t:dir and named_conf:file:

For my Debian packages I am going to use a separate type for /etc/bind/secondary to allow named to write files to that directory but not the other named config files. No way do I want named writing to my primary zone files!

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 4 lines · Russell Coker

For my Debian packages I am going to use a separate type for /etc/bind/secondary to allow named to write files to that directory but not the other named config files. No way do I want named writing to my primary zone files!

That's going to screw up dynamic DNS updates and is bound to piss off quite a few of your users. Better document it well ;)

cheers,

Rik

Signature · 9 lines
<insert bitkeeper endorsement here>

http://www.surriel.com/		http://distro.conectiva.com/


--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 8 lines · Rik van Riel
Quoted 4 lines · Russell Coker

For my Debian packages I am going to use a separate type for /etc/bind/secondary to allow named to write files to that directory but not the other named config files. No way do I want named writing to my primary zone files!

That's going to screw up dynamic DNS updates and is bound to piss off quite a few of your users. Better document it well ;)

Good point.

However with the current state of sample policy if you install SE Linux with the defaults you'll be lucky to have your machine boot...

With the way these things work we can't have a default policy any more restrictive than unix permissions (IE usefully restrictive) without breaking things for people who apply it blindly. That's life.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
In reply to Reino Wallin
Quoted 5 lines · Reino Wallin

I just posted a new release of my policy scripts for an application layer firewall. The scripts can be found at
http://www.oribium.com/selinux/
This release is pretty much better then the initial one. They are not yet ready for a production environment though.

Thanks.

Quoted 6 lines

I have a few suggestions to improve the example policy as well.

named_t:

To make the nameserver to work as a slave server, we may consider to grant write permissions to named_conf_t:dir and named_conf:file:

I'd agree with Russell Coker's suggestion of defining a new type for this purpose.

Quoted 4 lines

inetd_t:

If we allow inetd to setuid, then it will be more flexible, and the daemons can run as non root.

Ok.

Quoted 4 lines

It seems the following line is needed on my machine, but I haven't actually checked this up more in detail.

allow system_crond_t var_lib_rpm_t:dir { add_name remove_name write };

We've defined a new domain for the rpm utilities when run as system cron jobs, and granted that domain the necessary permissions. That domain (along with many other changes to the example policy) will be included in the next public release, which should be soon.

Quoted 3 lines

I have modified the network.te, and net_contexts, to allow multiple NIC's and IPSEC features. Patches are enclosed. This will allow a more fine grained control as well.

Thanks. These patches probably won't make it into the next public release, but possibly in future releases.

Quoted 4 lines

I think most policy developers will use the example policy as a starting point for their work. I suggest that all new policy scripts for domains should contain all the required networking capabilities, so we don't have to grant full networking rights to all domains anymore.

This is more difficult than it might seem. Many applications end up accessing the network transparently for various services, e.g. NIS lookups to map uids to usernames, DNS lookups to lookup hosts and IP addresses, NFS accesses, etc. Hence, removing can_network for a given domain might work in one environment that isn't using certain services but prevent the application from functioning in other environments.

Nonetheless, the example policy is undergoing some changes to make it easier to selectively apply the every.te rules to particular domains, and to partition those rules into finer-grained subsets.

Quoted 7 lines

As far as I can understand there is no need to grant an ftpuser or a popuser the right to change role, neither to have access to a shell. It seems appealing, just to grant a very limited set of rights to the default user, and add a few more user types, like a shell user and a trusted user. Am I wrong here? I am figuring to add a few new user types to my firewall policy. Please let me know your thoughts, and I may put something together that suits the example policy as well.

This depends on the degree of flexibility that you need from a given service. If you want the policy to be able to enforce different restrictions based on the authorized domains for a given ftp user, then you would presumably want a modified ftpd that transitions to a security context with the user's identity, an appropriate role, and a derived domain (similar to the derived domains used for user cron jobs). A prototype of a modified ftpd was included in the initial public release of SELinux along with a macro to define derived domains, but this was phased out later and ultimately superseded by the modified sshd. If you simply want the policy to treat all ftp sessions identically, then you can use an unmodified ftpd with a very limited ftpd_t domain, as in the current example policy. In that case, you don't need to define any user domains for ftp users.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
Quoted 4 lines · Stephen Smalley

We've defined a new domain for the rpm utilities when run as system cron jobs, and granted that domain the necessary permissions. That domain (along with many other changes to the example policy) will be included in the next public release, which should be soon.

Please send me the RPM sample policy ASAP so I can get you a policy for dpkg, dselect, and apt-get in time for the next release!!!

Quoted 3 lines

This is more difficult than it might seem. Many applications end up accessing the network transparently for various services, e.g. NIS lookups to map uids to usernames, DNS lookups to lookup hosts and IP addresses,

Can't this all go through nscd? If so then all you need is nscd access (unix domain socket) for all those applications.

Quoted 1 line

NFS accesses, etc. Hence, removing can_network for a given domain might

Does NFS access go through the security policy as network access? Surely NFS would be regarded as regular access to untyped files?

Quoted 4 lines

If you simply want the policy to treat all ftp sessions identically, then you can use an unmodified ftpd with a very limited ftpd_t domain, as in the current example policy. In that case, you don't need to define any user domains for ftp users.

Or you could take the cynical view that there's no point investing the effort of installing SE Linux if you're just going to go run insecure programs such as FTP servers.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
Quoted 2 lines · Russell Coker

Please send me the RPM sample policy ASAP so I can get you a policy for dpkg, dselect, and apt-get in time for the next release!!!

We aren't committing any further changes for the next public release, excluding any critical bug fixes. So this will have to wait. In any event, this domain is very simple and is merely to support the execution of rpm by the /etc/cron.daily/rpm script on RH7.2. When an administrator process runs rpm, it remains in sysadm_t, which already has sufficient permissions.

Quoted 2 lines

Can't this all go through nscd? If so then all you need is nscd access (unix domain socket) for all those applications.

Possibly, if you run nscd and all applications go through nscd to perform such queries. But that is an environmental assumption that may not apply to all users.

Quoted 2 lines

Does NFS access go through the security policy as network access? Surely NFS would be regarded as regular access to untyped files?

On second thought, I think that NFS requests are proxied through a UDP socket created by mount, so it should be sufficient to grant access to this socket rather than directly granting network access. We haven't truly addressed NFS in SELinux, as I've mentioned previously.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#7 lore raw
In reply to Stephen Smalley

tis 2002-03-12 klockan 16.05 skrev Stephen Smalley:

Quoted 7 lines
Quoted 3 lines

To make the nameserver to work as a slave server, we may consider to grant write permissions to named_conf_t:dir and named_conf:file:

I'd agree with Russell Coker's suggestion of defining a new type for this purpose.

I agree this is more secure. Should I use named_conf_t just for /etc/named.conf and then use a new type like dns_masterzone_t for /var/named/master and dns_slavezone_t for /var/named/slave ?

Quoted 12 lines
Quoted 4 lines

I think most policy developers will use the example policy as a starting point for their work. I suggest that all new policy scripts for domains should contain all the required networking capabilities, so we don't have to grant full networking rights to all domains anymore.

This is more difficult than it might seem. Many applications end up accessing the network transparently for various services, e.g. NIS lookups to map uids to usernames, DNS lookups to lookup hosts and IP addresses, NFS accesses, etc. Hence, removing can_network for a given domain might work in one environment that isn't using certain services but prevent the application from functioning in other environments.

Quoted 4 lines

Nonetheless, the example policy is undergoing some changes to make it easier to selectively apply the every.te rules to particular domains, and to partition those rules into finer-grained subsets.

Thanks. Since there are just a few applications, and a few user accounts on a firewall, Russel Coker's suggestion to use nscd might be a good solution in this particular case. I will continue to define fine grained networking capabilities to the type enforcement files I am writing, and hopefully get more experiences.

Signature · 8 lines
Reino Wallin, Oribium Labs
[email protected]


--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw
Quoted 9 lines · Reino Wallin
Quoted 5 lines
Quoted 2 lines

To make the nameserver to work as a slave server, we may consider to grant write permissions to named_conf_t:dir and named_conf:file:

I'd agree with Russell Coker's suggestion of defining a new type for this purpose.

I agree this is more secure. Should I use named_conf_t just for /etc/named.conf and then use a new type like dns_masterzone_t for /var/named/master and dns_slavezone_t for /var/named/slave ?

Sounds like a reasonable idea.

Also make the default policy:
allow named_t dns_masterzone_t:file r_file_perms;
allow named_t dns_masterzone_t:dir r_dir_perms;
With a comment suggesting rw_file_perms and rw_dir_perms for if you want dynamic updates (most people don't want it).

Then for the slave zones, a different domain for the named-xfer program to allow only that program to write the slave files would be good. Then someone who cracks named can't change the zone files on disk.

Quoted 5 lines

Thanks. Since there are just a few applications, and a few user accounts on a firewall, Russel Coker's suggestion to use nscd might be a good solution in this particular case. I will continue to define fine grained networking capabilities to the type enforcement files I am writing, and hopefully get more experiences.

Also some of the network access shouldn't be allowed. I've already discovered one bug in a Debian library where a network socket was incorrectly set to allow it to remain open across exec through my tests of SE security policies.

Signature · 10 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.


--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.