All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: jwcart2@epoch.ncsc.mil
Cc: Russell Coker <russell@coker.com.au>,
	Thomas Bleher <bleher@informatik.uni-muenchen.de>,
	SELinux <selinux@tycho.nsa.gov>,
	James Morris <jmorris@redhat.com>
Subject: Re: can_network patch
Date: Tue, 09 Nov 2004 17:15:02 -0500	[thread overview]
Message-ID: <41914166.3070702@redhat.com> (raw)
In-Reply-To: <1100036063.30448.72.camel@moss-lions.epoch.ncsc.mil>

James Carter wrote:

>This patch is on the right track.
>
>On Sat, 2004-11-06 at 00:33, Daniel J Walsh wrote:
>  
>
>>This is the patch that eliminates connect from can_network.
>>
>>The batch basically does a couple of things
>>
>>can_network now calls
>>can_tcp_network
>>can_udp_network
>>    
>>
>
>I think can_network should have the same functionality as before.
>There should be new macros for the reduced permissions.
>It seems like we should have at least these macros:
>
>can_tcp_client (or can_tcp_out) - connect, etc
>can_tcp_server (or can_tcp_in) - bind, listen, accept, etc
>can_udp
>can_udp_connect - if connect is needed.
>
>  
>
>This patch has 34 lines adding connect permissions.  We should
>definitely seek to reduce the number of lines related to networking
>outside of the network macros.  I think Russell made a similar comment a
>while back.
>  
>
My goal with the redesign was to make connect equivalent to name_bind.

After examining this further and talking with James, I realize that this 
is not possible
without a modification to the kernel.

Basically I want name_connect permission, so the policy would be written 
such that
a domain can only "connect" to certain ports.   So a domain which did a 
connect(socket, DNS_PORT_T)
Would need a rule like
allow mydomain_t dns_port_t:socketc name_connect;

Then all domains that can_network would either have a name_bind or a 
name_connect  associated
with it and a lock down of the ports that they will use.

One goal of a lot of hackers now is to take over machines and use them 
as mail forwarders
(Spammers) or as launch sites for further attacks.  You don't even need 
root access to do this. 
Our current can_network() allows you all domains to connect to any port 
using UDP and TCP.

I have gotten partially there by breaking can_network into 
can_udp_network and
can_tcp_network.  Also eliminating the connect priveledge from all 
daemons that don't use it
makes them more secure. 

The port stuff that I added does not work as I expected and I am 
removing some of it.

>  
>
>>diff --exclude-from=exclude -N -u -r policy-1.18.2/macros/core_macros.te policy-1.18.2.old/macros/core_macros.te
>>--- policy-1.18.2/macros/core_macros.te	2004-11-05 23:39:10.000000000 -0500
>>+++ policy-1.18.2.old/macros/core_macros.te	2004-11-05 23:57:55.360848660 -0500
>>@@ -132,22 +132,32 @@
>> #
>> # Permissions for using sockets.
>> # 
>>-define(`rw_socket_perms', `{ ioctl read getattr write setattr append bind connect getopt setopt shutdown }')
>>+define(`rw_socket_perms', `{ ioctl read getattr write setattr append bind getopt setopt shutdown }')
>> 
>> #
>> # Permissions for creating and using sockets.
>> # 
>>-define(`create_socket_perms', `{ create ioctl read getattr write setattr append bind connect getopt setopt shutdown }')
>>+define(`connected_socket_perms', `{ create rw_socket_perms }')
>>    
>>
>
>This doesn't make sense to me.  Why grant "create", if already
>connected?
>
>  
>
connected_socket_perms might not be a great name, but it is to be used 
with accept(socket) daemons,
versus connect(socket) domains.  We named it that because it is just 
removing the "connect" privledge, so the
socket must all ready be "connected" :^).

>>+
>>+#
>>+# Permissions for creating, connecting and using sockets.
>>+# 
>>+define(`create_socket_perms', `{ connected_socket_perms connect }')
>> 
>> #
>> # Permissions for using stream sockets.
>> # 
>>-define(`rw_stream_socket_perms', `{ ioctl read getattr write setattr append bind connect getopt setopt shutdown listen accept }')
>>+define(`rw_stream_socket_perms', `{ rw_socket_perms listen accept }')
>>+
>>+#
>>+# Permissions for creating and using stream sockets.
>>+# 
>>+define(`connected_stream_socket_perms', `{ create rw_stream_socket_perms }')
>> 
>>    
>>
>
>Same thing here.
>
>  
>


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2004-11-09 22:15 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-18 19:31 Adding alternate root patch to restorecon (setfiles?) Daniel J Walsh
2004-10-18 19:55 ` Stephen Smalley
2004-10-18 20:11   ` Daniel J Walsh
2004-10-18 20:51 ` Thomas Bleher
2004-10-19 13:33   ` Daniel J Walsh
2004-10-19 18:36     ` Luke Kenneth Casson Leighton
2004-10-19 18:26       ` Stephen Smalley
2004-10-19 20:27         ` Luke Kenneth Casson Leighton
2004-10-25 15:35       ` Russell Coker
2004-10-25 15:38   ` Russell Coker
2004-10-25 21:31     ` Thomas Bleher
2004-10-26 14:36       ` Russell Coker
2004-11-05 21:39         ` James Carter
2004-11-06  5:23           ` Remaining changes from my patch excluding can_network changes Daniel J Walsh
2004-11-08 17:33             ` Small patch to allow pam_console handle /dev/pmu Daniel J Walsh
2004-11-08 21:21               ` James Carter
2004-11-08 21:21             ` Remaining changes from my patch excluding can_network changes James Carter
2004-11-06  5:33           ` can_network patch Daniel J Walsh
2004-11-09 21:34             ` James Carter
2004-11-09 22:15               ` Daniel J Walsh [this message]
2004-11-06 10:40           ` Adding alternate root patch to restorecon (setfiles?) Thomas Bleher
2004-11-10 23:11           ` Patches without the can_network patch Daniel J Walsh
2004-11-10 23:38             ` Thomas Bleher
2004-11-17 20:15             ` James Carter
2004-11-18 14:32               ` Daniel J Walsh
2004-11-18 19:43                 ` Thomas Bleher
2004-11-18 19:50                   ` Daniel J Walsh
2004-11-18 19:59                     ` Thomas Bleher
2004-11-19 22:05                 ` James Carter
2004-11-18 14:33               ` Daniel J Walsh
2004-11-23 18:52                 ` James Carter
2004-11-23 19:06                   ` Stephen Smalley
2004-11-23 19:37                     ` Daniel J Walsh
2004-11-23 20:07                       ` Stephen Smalley
2004-11-25 19:40                         ` Russell Coker
2004-11-26 11:55                           ` Daniel J Walsh
2004-11-24 16:22                   ` Daniel J Walsh
2004-11-24 16:39                     ` Stephen Smalley
2004-11-24 16:54                       ` Daniel J Walsh
2004-12-10 15:43                         ` Stephen Smalley
2004-12-10 17:06                           ` Daniel J Walsh
2004-12-10 17:10                             ` Stephen Smalley
2004-12-10 18:01                               ` Daniel J Walsh
2004-12-10 18:02                                 ` Stephen Smalley
2004-12-10 18:13                                   ` Daniel J Walsh
2004-12-10 18:11                                 ` Russell Coker
2004-12-10 19:11                                   ` Thomas Bleher
2004-12-10 20:23                                     ` James Carter
2004-12-10 21:39                                     ` Valdis.Kletnieks
2004-12-13 12:18                                       ` David Caplan
2004-12-10 21:01                                   ` Valdis.Kletnieks
2004-12-10 23:47                                     ` Russell Coker
2004-11-24 19:48                     ` James Carter
2004-11-24 20:24                       ` Daniel J Walsh
2004-11-30 21:19                       ` Reissue previous patch Daniel J Walsh
2004-12-02 13:54                         ` James Carter
2004-12-02 14:16                           ` Daniel J Walsh
2004-12-02 15:51                             ` Stephen Smalley
2004-12-02 18:35                               ` Daniel J Walsh
2004-12-02 17:51                             ` James Carter
2004-12-02 19:27                               ` Latest patch Daniel J Walsh
2004-12-03 13:40                                 ` James Carter
2004-11-17 23:35             ` Patches without the can_network patch Kodungallur Varma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41914166.3070702@redhat.com \
    --to=dwalsh@redhat.com \
    --cc=bleher@informatik.uni-muenchen.de \
    --cc=jmorris@redhat.com \
    --cc=jwcart2@epoch.ncsc.mil \
    --cc=russell@coker.com.au \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.