nested inheritance and interpreters (ruby, perl, etc)
Posted: Wed Oct 15, 2008 4:52 pm
I'm trying to develop a sane grsec policy for puppet (a changeconfig application based on cfengine), which is written in Ruby. Because puppet is basically going to be managing everything about a system, we want it to have unfettered access to pretty much everything. The only way the puppet client gets its 'instructions' is through a TLS-encrypted channel to the 'puppetmaster' server, so even if someone does get root (but not gradm admin) on the box they won't be able to tell the puppet client to do anything because they won't be communicating to it via the channel to the puppetmaster. Anyways, so my grsec acls under the 'root' role currently look like this:
We've got the ACL for /usr/bin/puppet:
subject /usr/bin/puppet rvka {
/ rwcdmlxi
/usr/bin/ruby1.8 rwcdmlxi
# Default connections: Allow to LDAP, DNS, NFS, and Puppetmaster
connect <ldap-servers>/24:636 stream tcp dgram udp
connect <puppetmaster>/32:8140 any_sock any_proto
connect <dns>/0:53 any_sock any_proto
connect <nfs subnet>/24:2049 any_sock any_proto
connect ! 0.0.0.0/0 any_sock any_proto
}
Then the ACL for the interprer/usr/bin/ruby1.8:
subject /usr/bin/ruby1.8 {
/etc/init.d r
/etc/passwd r
/etc/group r
/etc/puppet r
/usr/bin/ruby1.8 rx
/var/log/puppet rwcdl
/var/run/puppet rwcdl
/var/lib/puppet rwcdl
/var/state/puppet r
+CAP_SETUID
# Default connections: Allow to LDAP and DNS
connect <ldap>/24:636 stream tcp dgram udp
connect <dns>/0:53 any_sock any_proto
connect <nfs>/24:2049 any_sock any_proto
connect ! 0.0.0.0/0 any_sock any_proto
}
So with that set up, I dropped in a (testing!) nested ACL that I figure *should* give the puppet client the access it needs:
subject /usr/bin/puppet:/usr/bin/ruby1.8 rvka {
/ rwcdmlxi
connect <puppetmaster ip>/32:8140
}
and it promptly does a whole lot of nothing. I still get in my logs, on the puppet client startup, errors like the following:
[83091.156540] grsec: From <myhost>: (root:U:/usr/bin/ruby1. denied connect() to <puppetmaster IP> port 8140 sock type stream protocol tcp by /usr/bin/ruby1.8[ruby:8623] uid/euid:0/0 gid/egid:0/0, parent /sbin/init[init:1] uid/euid:0/0 gid/egid:0/0
[83091.164215] grsec: From <myhost>: (root:U:/usr/bin) denied executable mmap of /var/lib/dpkg/status by /usr/bin/dpkg-query[dpkg-query:8712] uid/euid:0/0 gid/egid:0/0, parent /usr/bin/ruby1.8[ruby:8623] uid/euid:0/0 gid/egid:0/0
The first one is showing that it cannot connect to the puppetmaster IP, even though it's explicitly allowed in the nested ACL and the /usr/bin/puppet ACL. The second error is showing that it can't get enumerate the packages listed in the system, despite the over-generous ACL permission set on the nested subject. What am I doing wrong?
We've got the ACL for /usr/bin/puppet:
subject /usr/bin/puppet rvka {
/ rwcdmlxi
/usr/bin/ruby1.8 rwcdmlxi
# Default connections: Allow to LDAP, DNS, NFS, and Puppetmaster
connect <ldap-servers>/24:636 stream tcp dgram udp
connect <puppetmaster>/32:8140 any_sock any_proto
connect <dns>/0:53 any_sock any_proto
connect <nfs subnet>/24:2049 any_sock any_proto
connect ! 0.0.0.0/0 any_sock any_proto
}
Then the ACL for the interprer/usr/bin/ruby1.8:
subject /usr/bin/ruby1.8 {
/etc/init.d r
/etc/passwd r
/etc/group r
/etc/puppet r
/usr/bin/ruby1.8 rx
/var/log/puppet rwcdl
/var/run/puppet rwcdl
/var/lib/puppet rwcdl
/var/state/puppet r
+CAP_SETUID
# Default connections: Allow to LDAP and DNS
connect <ldap>/24:636 stream tcp dgram udp
connect <dns>/0:53 any_sock any_proto
connect <nfs>/24:2049 any_sock any_proto
connect ! 0.0.0.0/0 any_sock any_proto
}
So with that set up, I dropped in a (testing!) nested ACL that I figure *should* give the puppet client the access it needs:
subject /usr/bin/puppet:/usr/bin/ruby1.8 rvka {
/ rwcdmlxi
connect <puppetmaster ip>/32:8140
}
and it promptly does a whole lot of nothing. I still get in my logs, on the puppet client startup, errors like the following:
[83091.156540] grsec: From <myhost>: (root:U:/usr/bin/ruby1. denied connect() to <puppetmaster IP> port 8140 sock type stream protocol tcp by /usr/bin/ruby1.8[ruby:8623] uid/euid:0/0 gid/egid:0/0, parent /sbin/init[init:1] uid/euid:0/0 gid/egid:0/0
[83091.164215] grsec: From <myhost>: (root:U:/usr/bin) denied executable mmap of /var/lib/dpkg/status by /usr/bin/dpkg-query[dpkg-query:8712] uid/euid:0/0 gid/egid:0/0, parent /usr/bin/ruby1.8[ruby:8623] uid/euid:0/0 gid/egid:0/0
The first one is showing that it cannot connect to the puppetmaster IP, even though it's explicitly allowed in the nested ACL and the /usr/bin/puppet ACL. The second error is showing that it can't get enumerate the packages listed in the system, despite the over-generous ACL permission set on the nested subject. What am I doing wrong?