Commit Graph

1184 Commits

Author SHA1 Message Date
Chris PeBenito c6396d5a79 Merge pull request #88 from fishilico/usr-bin-fc 2019-09-11 06:26:24 -04:00
Chris PeBenito cfdf3b7981 Merge pull request #98 from fishilico/ulogd-dynamic-user 2019-09-11 06:22:44 -04:00
Nicolas Iooss 10cd3fb258
bitlbee: allow using GetDynamicUser on Debian
On Debian 10, starting bitlbee daemon leads to:

    type=AVC msg=audit(1567941717.044:14204): avc:  denied  { search }
    for  pid=5704 comm="bitlbee" name="dbus" dev="tmpfs" ino=13798
    scontext=system_u:system_r:bitlbee_t
    tcontext=system_u:object_r:system_dbusd_var_run_t tclass=dir
    permissive=0

    type=AVC msg=audit(1567941717.044:14205): avc:  denied  { read } for
    pid=5704 comm="bitlbee" name="direct:64707" dev="tmpfs" ino=16529
    scontext=system_u:system_r:bitlbee_t
    tcontext=system_u:object_r:init_var_run_t tclass=lnk_file
    permissive=0

    type=AVC msg=audit(1567941756.020:14208): avc:  denied  { search }
    for  pid=6363 comm="bitlbee" name="dbus" dev="tmpfs" ino=13798
    scontext=system_u:system_r:bitlbee_t
    tcontext=system_u:object_r:system_dbusd_var_run_t tclass=dir
    permissive=0

    type=AVC msg=audit(1567941756.020:14209): avc:  denied  { read } for
    pid=6363 comm="bitlbee" name="direct:64707" dev="tmpfs" ino=16529
    scontext=system_u:system_r:bitlbee_t
    tcontext=system_u:object_r:init_var_run_t tclass=lnk_file
    permissive=0

    type=USER_AVC msg=audit(1567941770.492:14215): pid=432 uid=106
    auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t
    msg='avc:  denied  { send_msg } for msgtype=method_call
    interface=org.freedesktop.systemd1.Manager member=GetDynamicUsers
    dest=org.freedesktop.systemd1 spid=6694 tpid=1
    scontext=system_u:system_r:bitlbee_t
    tcontext=system_u:system_r:init_t tclass=dbus permissive=0
    exe="/usr/bin/dbus-daemon" sauid=106 hostname=? addr=? terminal=?'

All these denials are related to getting dynamic users through a D-Bus
call to GetDynamicUsers() of interface org.freedesktop.systemd1.Manager.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-08 23:07:15 +02:00
Nicolas Iooss f5a4ce1d35
ulogd: adjust policy for Debian
On a Debian 10 system, I saw denials for ulogd service:

* It uses a pipe with itself:

    type=AVC msg=audit(1567874422.328:13744): avc:  denied  { write }
    for pid=11416 comm="ulogd" path="pipe:[29006]" dev="pipefs"
    ino=29006 scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:ulogd_t tclass=fifo_file permissive=0

* It enumerates users in /run/systemd/dynamic-uid/ when changing to the
  ulog user (which is not dynamic):

    type=AVC msg=audit(1567874512.576:13748): avc:  denied  { read } for
    pid=18290 comm="ulogd" name="dynamic-uid" dev="tmpfs" ino=16527
    scontext=system_u:system_r:ulogd_t
    tcontext=system_u:object_r:init_var_run_t tclass=dir permissive=0

* It connects to the system D-Bus socket in order to call GetDynamicUser:

    type=AVC msg=audit(1567875114.147:13761): avc:  denied  { write }
    for  pid=28135 comm="ulogd" name="system_bus_socket" dev="tmpfs"
    ino=13799 scontext=system_u:system_r:ulogd_t
    tcontext=system_u:object_r:system_dbusd_var_run_t tclass=sock_file
    permissive=1

    type=AVC msg=audit(1567875114.147:13761): avc:  denied  { connectto
    } for  pid=28135 comm="ulogd" path="/run/dbus/system_bus_socket"
    scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:system_dbusd_t tclass=unix_stream_socket
    permissive=1

    type=USER_AVC msg=audit(1567875276.683:13776): pid=432 uid=106
    auid=4294967295 ses=4294967295 subj=system_u:system_r:system_db
    usd_t msg='avc:  denied  { send_msg } for msgtype=method_call
    interface=org.freedesktop.systemd1.Manager member=GetDynamicUsers
    dest=org.freedesktop.systemd1 spid=30953 tpid=1
    scontext=system_u:system_r:ulogd_t tcontext=system_u:system_r:init_t
    tclass=dbus permissive=1  exe="/usr/bin/dbus-daemon" sauid=106
    hostname=? addr=? terminal=?'

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-08 23:06:34 +02:00
Chris PeBenito 208296a0c2 various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-07 16:58:51 -04:00
Chris PeBenito bbd7f748a6 Merge pull request #82 from fishilico/typo-cups-fc 2019-09-07 16:47:34 -04:00
Chris PeBenito 1dea588464 Merge pull request #94 from fishilico/wireguard 2019-09-07 16:39:48 -04:00
Dominick Grift 210b64f10a Remove shell automatic domain transitions to unconfined_t from various pam login programs
I think these may have been adopted from the old Red Hat targeted policy (that model only had unconfined users)

Some aspect to note:

1. The ssh_sysadm_login boolean now applies to unconfined_t as well
2. remotelogin only allows unpriv logins

The rshd module also calls unconfined_shell_domtrans() but I ignored that one because that policy currently does not have support for manual transitions with pam_selinux.

Signed-off-by: Dominick Grift <dac.override@gmail.com>
2019-09-07 16:26:49 -04:00
Nicolas Iooss a7c9634eca
Add a policy module for WireGuard VPN
WireGuard is a fast, modern, secure VPN tunnel, according to
https://www.wireguard.com/. In order to install it, the mostly
documented way consists in building and installing an out-of-tree kernel
module and using userland tools to configure this module (wg and
wg-quick).

* WireGuard is like "ip": the userland tool communicates with the kernel
  module through a netlink socket.

* WireGuard is like "iptables": there is no daemon, but some
  distributions ship systemd units that restores a WireGuard
  configuration when started.

* WireGuard is like other services: its configuration files are in /etc,
  and it can use /run and /tmp.

Create a new policy module which handles all of this.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-06 22:20:40 +02:00
Nicolas Iooss e399c7f642
Label programs in /usr/bin like /usr/sbin
Some recent modifications added patterns in .fc files for programs in
/usr/sbin without adding the patterns for /usr/bin. On Arch Linux, where
/usr/sbin is a symlink to /usr/bin, such patterns are never matched.

Add the missing patterns.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-04 22:28:09 +02:00
Nicolas Iooss b8f2c55109
cups: use ([^/]+/)? to match a subdirectory of CUPS configuration
It seems that /opt/brother/Printers/ only has one level of directories
before a directory named "inf", according to several websites. For
example:

* https://www.linuxquestions.org/questions/slackware-14/trying-to-add-driver-for-brother-hl-l2300d-4175535636/
* https://forums.opensuse.org/showthread.php/531271-Brother-printer-driver-installs-but-can-t-print/page2

Modify the pattern for /opt/brother/Printers/${MODEL_NAME}/inf in order
to only allow at most one level, with "([^/]+/)?".

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-04 20:57:07 +02:00
Chris PeBenito 5d636c2d16 various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-03 19:47:12 -04:00
Chris PeBenito 9d80ada777 Merge pull request #78 from fishilico/debian-dynamic-motd 2019-09-03 19:44:13 -04:00
Chris PeBenito 2fa4070b60 Merge pull request #63 from fishilico/systemd-privatedev 2019-09-03 19:39:18 -04:00
Nicolas Iooss aa7e8d4091
ntp: allow systemd-timesyncd to read network status
systemd-timesyncd uses network_is_online() [1], which calls
sd_network_get_operational_state() [2], which reads
/run/systemd/netif/state [3]:

    r = parse_env_file(NULL, "/run/systemd/netif/state", "OPER_STATE", &s);

On a Debian virtual machine created with Vagrant,
/run/systemd/netif/state contains:

    # This is private data. Do not parse.
    OPER_STATE=routable
    DNS=192.168.121.1 172.28.128.1

systemd-timesyncd's access produces the following logs:

    type=AVC msg=audit(1567359197.660:323): avc:  denied  { read } for
    pid=230 comm="systemd-timesyn" name="state" dev="tmpfs" ino=24564
    scontext=system_u:system_r:ntpd_t
    tcontext=system_u:object_r:systemd_networkd_var_run_t tclass=file
    permissive=1

    type=AVC msg=audit(1567359197.660:324): avc:  denied  { open } for
    pid=230 comm="systemd-timesyn" path="/run/systemd/netif/state"
    dev="tmpfs" ino=24564 scontext=system_u:system_r:ntpd_t
    tcontext=system_u:object_r:systemd_networkd_var_run_t tclass=file
    permissive=1

    type=AVC msg=audit(1567359197.660:325): avc:  denied  { getattr }
    for  pid=230 comm="systemd-timesyn" path="/run/systemd/netif/state"
    dev="tmpfs" ino=24564 scontext=system_u:system_r:ntpd_t
    tcontext=system_u:object_r:systemd_networkd_var_run_t tclass=file
    permissive=1

Allow these accesses.

[1] https://github.com/systemd/systemd/blob/v242/src/timesync/timesyncd.c#L158
[2] https://github.com/systemd/systemd/blob/v242/src/libsystemd/sd-network/network-util.c#L13
[3] https://github.com/systemd/systemd/blob/v242/src/libsystemd/sd-network/sd-network.c#L27

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-01 20:44:14 +02:00
Nicolas Iooss e09bcff3d2
cups: add a slash to match /opt/brother/Printers/
The pattern /opt/brother/Printers(.*/)?inf(/.*)? matches the content of
directories such as /opt/brother/Printersinf/, which seems buggy. On
several systems, /opt/brother/Printers/ is a directory that contains
directories named as printer models.

Add a "/" before "(.*/)?" in order to make sure subdirectories of
/opt/brother/Printers named "inf" are matched by the pattern.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-01 16:07:41 +02:00
Nicolas Iooss 58189f4965
entropyd: haveged service uses PrivateDevices=yes
On Debian, haveged fails to start with "haveged: Couldn't open random
device: Permission denied". strace shows:

    openat(AT_FDCWD, "/dev/random", O_RDWR) = -1 EACCES (Permission denied)

audit.log has:

    type=AVC msg=audit(1566048720.132:1338): avc:  denied  { search }
    for  pid=20235 comm="haveged" name="/" dev="tmpfs" ino=76666
    scontext=system_u:system_r:entropyd_t
    tcontext=system_u:object_r:tmpfs_t tclass=dir permissive=0

With systemd, /dev is a temporary filesystem (tmpfs_t), so haveged needs
the search permission to it in order to open /dev/random. Use the
newly-added interface to allow this access.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-01 13:47:45 +02:00
Nicolas Iooss c021287125
Allow Debian to generate a dynamic motd when users log in
Debian's PAM configuration uses a patched pam_motd module that runs
files in /etc/update-motd.d/ in order to generate a dynamic Message Of
The Day (MOTD). By default, there is only one script:

    $ cat /etc/update-motd.d/10-uname
    #!/bin/sh
    uname -snrvm

According to https://wiki.debian.org/motd, the script is executed
through run-parts:

    if (!system("/usr/bin/env -i
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    run-parts --lsbsysinit /etc/update-motd.d >
    /run/motd.dynamic.new"))
        rename("/run/motd.dynamic.new", "/run/motd.dynamic");

This requires allowing pam_motd users to execute bin_t commands
(/usr/bin/env) and shells (/bin/sh), and to manage /run/motd.dynamic*
files.

Allow relevant accesses for Debian-based systems.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-01 13:44:28 +02:00
Chris PeBenito 6b11dcef89 Various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-08-31 06:55:57 -04:00
Chris PeBenito b43aebcc2f Merge pull request #70 from fishilico/typo-dot-star-question-fc 2019-08-31 06:26:00 -04:00
Nicolas Iooss d386950b0d
Fix use of buggy pattern (.*)?
The pattern "(.*)?" means "match anything including the nothing, or
nothing": the question mark is redundant. This is likely to be a
mispelling for "(/.*)?", which means "match a slash and anthing, or
nothing", or for ".*", or for other patterns.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-29 19:57:05 +02:00
Nicolas Iooss f0cade07b2
Remove unescaped single dot from the policy
In a pattern, a dot can match any character, including slash. It makes
sense when it is combined with ?, + or *, but makes little sense when
left alone.

Most of the time, the label was for file containing dots, where the dot
was not escaped. A few times, the dot was really intended to match any
character. In such case, [^/] better suits the intent.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-27 23:38:09 +02:00
Chris PeBenito b0fb76565b rpcbind: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-08-27 00:36:40 -04:00
Chris PeBenito 373a1c090a Merge pull request #73 from fishilico/rpcbind-redundant-pid-fc 2019-08-27 00:36:18 -04:00
Chris PeBenito 68b74385a4 various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-08-27 00:28:34 -04:00
Chris PeBenito 95c4192509 Merge pull request #64 from fishilico/haveged-unit 2019-08-27 00:20:24 -04:00
Chris PeBenito 7e5503155c Merge pull request #65 from fishilico/haveged-cmd-socket 2019-08-27 00:19:57 -04:00
Chris PeBenito 20f1151192 Merge pull request #66 from fishilico/ulogd-fix-context 2019-08-27 00:19:10 -04:00
Chris PeBenito 1106d0b692 Merge pull request #67 from fishilico/typo-monit-s9 2019-08-27 00:18:47 -04:00
Nicolas Iooss 6875a1b0a5
rpcbind: remove redundant file context for /run/rpc.statd.pid
There are two patterns that define file contexts for /run/rpc.statd.pid:

* in policy/modules/services/rpcbind.fc:

    /run/rpc.statd\.pid	--	gen_context(system_u:object_r:rpcbind_var_run_t,s0)

* in policy/modules/services/rpc.dc:

    /run/rpc\.statd\.pid	--	gen_context(system_u:object_r:rpcd_var_run_t,s0)

They coexist even though their labels differ because the first one uses
a unescaped dot. As it does not seem to exist other files matching the
first pattern, remove it in order to only keep the second one.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-22 21:49:28 +02:00
Nicolas Iooss d938683bf4
drbd: fix pattern for /usr/lib/ocf/resource.d/linbit/drbd
In order to match /usr/lib/ocf/resource.d/linbit/drbd, the dot needs to
be escaped, not the d.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-21 23:03:01 +02:00
Nicolas Iooss 271352c1c2
monit: use s0 instead of s9
This seems to be a misspelling, and there is no reason which would
explain why monit's init script would be labeled with a different
sensitivity while the main binary uses s0.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-21 21:39:26 +02:00
Nicolas Iooss 2bfb67d339
ulogd: fix pattern for /run/ulog directory
The pattern only matched /run/ulog, not its content.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-18 21:38:00 +02:00
Nicolas Iooss d7f66dce04
entropyd: allow haveged to create a Unix socket to received commands
haveged listens to commands using a Unix socket
(at path "\0/sys/entropy/haveged" according to
https://github.com/jirka-h/haveged/blob/1.9.4/src/havegecmd.h#L34).
The implementation of this server is available on
https://github.com/jirka-h/haveged/blob/1.9.4/src/havegecmd.c .

This fixes the following denial:

    type=AVC msg=audit(1551002989.396:27): avc:  denied  { listen } for
    pid=262 comm="haveged"
    path=002F7379732F656E74726F70792F68617665676564
    scontext=system_u:system_r:entropyd_t
    tcontext=system_u:system_r:entropyd_t tclass=unix_stream_socket
    permissive=1

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-18 21:34:52 +02:00
Nicolas Iooss 1ab82b1150
entropyd: label the unit file of haveged
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-18 21:20:27 +02:00
Chris PeBenito 230262368b ulogd: Rename ulogd_var_run_t to ulogd_runtime_t.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-08-17 15:17:51 -04:00
Chris PeBenito ac1659e79f ulogd: Module version bump. 2019-08-17 15:11:32 -04:00
Nicolas Iooss 9686bf05a7
ulogd: allow starting on a Debian system
When ulogd is run by systemd on Debian, it logs messages to the journal,
it used a PID file in /run/ulog/ulogd.pid, and logs packets to
/var/log/ulog/syslogemu.log. This last ones triggers a dac_read_search
capability check because the directory is configured as:

    drwxrwx---. ulog adm /var/log/ulog

(root does not have an access to the directory without bypassing the DAC.)

Add a comment describing how to avoid allowing dac_read_search to ulogd_t.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-17 16:03:39 +02:00
Nicolas Iooss d91d41b53a
ulogd: allow creating a netlink-netfilter socket
This is used to get the packets logged by the firewall.

I experienced this on a Debian system which uses nftables rules with the
"log" keyword:

    type=AVC msg=audit(1565901600.257:348): avc:  denied  { create } for
    pid=8586 comm="ulogd" scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:ulogd_t tcla
    ss=netlink_netfilter_socket permissive=1

    type=AVC msg=audit(1565901103.154:327): avc:  denied  { read } for
    pid=436 comm="ulogd" scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:ulogd_t tclass=netlink_netfilter_socket
    permissive=1

    type=SYSCALL msg=audit(1565901103.154:327): arch=c000003e syscall=45
    success=yes exit=148 a0=8 a1=7f651d19d010 a2=249f0 a3=0 items=0 ppid=1
    pid=436 auid=4294967295 uid=111 gid=118 euid=111 suid=111 fsuid=111
    egid=118 sgid=118 fsgid=118 tty=(none) ses=4294967295 comm="ulogd"
    exe="/usr/sbin/ulogd" subj=system_u:system_r:ulogd_t key=(null)

    type=PROCTITLE msg=audit(1565901103.154:327):
    proctitle=2F7573722F7362696E2F756C6F6764002D2D6461656D6F6E002D2D75696400756C6F67002D2D70696466696C65002F72756E2F756C6F672F756C6F67642E706964

    [ ... ]

    type=AVC msg=audit(1565901600.241:338): avc:  denied  { write } for
    pid=436 comm="ulogd" scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:ulogd_t tclass=netlink_netfilter_socket
    permissive=1

    type=AVC msg=audit(1565901600.257:348): avc:  denied  { create } for
    pid=8586 comm="ulogd" scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:ulogd_t tclass=netlink_netfilter_socket
    permissive=1

    type=AVC msg=audit(1565901600.257:349): avc:  denied  { getattr } for
    pid=8586 comm="ulogd" scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:ulogd_t tclass=netlink_netfilter_socket
    permissive=1

    type=AVC msg=audit(1565901600.257:350): avc:  denied  { bind } for
    pid=8586 comm="ulogd" scontext=system_u:system_r:ulogd_t
    tcontext=system_u:system_r:ulogd_t tclass=netlink_netfilter_socket
    permissive=1

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-17 15:53:32 +02:00
Nicolas Iooss f37b4b5ddd
ulogd: add Debian's log directory
Debian uses /var/log/ulog/syslogemu.log by default to log network
packets sent through a netlink multicast group by the firewall.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-17 15:52:58 +02:00
Sugar, David 566fd554a6 Module for tpm2
Module for tpm2

v2 - updated to rename module and interface names, different dbus
interface

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2019-08-11 15:02:20 -04:00
Chris PeBenito de8cf73de0 knot: Move lines.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-13 14:06:44 -04:00
Chris PeBenito 7a1260ffe3 knot: Whitespace changes.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-13 14:06:02 -04:00
Alexander Miroshnichenko 491ae9991a Add knot module
Add a SELinux Reference Policy module for the
Knot authoritative-only DNS server.

Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
2019-07-13 14:00:31 -04:00
Chris PeBenito 8c3893e427 Bump module versions for release.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-06-09 14:05:19 -04:00
Chris PeBenito 10784f3b33 various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-06-09 13:37:51 -04:00
Chris PeBenito d348413004 apache: Web content rules simplification.
Signed-off-by: Chris PeBenito <Christopher.PeBenito@microsoft.com>
2019-06-03 15:01:43 -04:00
Chris PeBenito 2d9ad29d04 dovecot, logrotate: Module version bump. 2019-05-03 20:39:36 -04:00
Chris PeBenito eaed7a9123 Merge pull request #48 from bigon/dovecot_lmtp 2019-05-03 08:00:41 -04:00
Laurent Bigonville 8215279af4 Add dovecot to listen to LMTP port
Mails can be injected in dovecot directly using LMTP
2019-05-03 12:33:09 +02:00