Page 1 of 1

D6 AppArmor Profile für Daemons

Posted: Sat Nov 28, 2020 9:53 pm
by pietinger
(Dieser Post ist Teil einer Installation-Anleitung. Falls nicht schon geschehen lies bitte: Installation Guide for Paranoid Dummies Post Nr. 3)



D.6 AppArmor Profile für Daemons


Ich biete Dir hier kein Profil für den "sshd". Ich habe nicht einmal versucht diesen mit einem AA-Profil zu sichern, weil ich der Meinung bin, dass ein laufender SSHD anderweitig gesichert werden muss: Entweder erlaubst Du (mittels Deiner FireWall) nur Zugang von vertrauenswürdigen Admin-Stations von Deinem lokalen Netzwerk und blockst jeglichen Versuch von anderen Netzen, ODER falls Du wirklich aus dem Internet auf den sshd gehen willst, dann mach das NUR über eine VPN-Leitung ! Alles andere ist für mich Harakiri.

  • Profile: /etc/apparmor.d/usr.sbin.privoxy
  • Beschreibung/Bemerkung: Wie Du siehst ist der Privoxy ein ganz ein braver :-) Die Capabilites braucht er damit er den root abgeben kann um dann als User privoxy zu laufen.

Code: Select all

# version 1

abi <kernel>,

profile privoxy /usr/sbin/privoxy
{
include <local/ONLYNETWORK>
capability setgid,
capability setuid,
/run/privoxy.pid  rw,
/var/log/privoxy/privoxy.log  rw,
}
  • Profile: /etc/apparmor.d/sbin.dhcpcd
  • Beschreibung/Bemerkung: Ich bin der Meinung dass dynamische IP-Adresszuweisung nur von Unternehmen mit großen Client-Netzen benötigt wird und für einen privaten Anwender statische IP-Adressen sinnvoller und einfacher zu handeln sind. Ich konnte dieses Profil daher nur rudimentär prüfen. Dabei ist mir aufgefallen, dass der dhcpcd in der Lage ist meine FW zu umgehen ... Ich mag ihn nicht ...

Code: Select all

# version 1

abi <kernel>,

profile dhcpcd /sbin/dhcpcd
{
include <local/ONLYNETWORK>
include <local/USECONSOLE>
/bin/hostname  ix,
/bin/rm  ix,
/bin/sed  ix,
/lib/dhcpcd/**  rix,
/usr/bin/cmp  ix,
capability dac_override,
capability net_admin,
capability net_bind_service,
capability net_raw,
/etc/resolv.conf  rw,
/run/dhcpcd.pid  krw,
/run/dhcpcd.sock  krw,
/run/dhcpcd.unpriv.sock  rw,
/run/dhcpcd/**  rw,
/var/lib/dhcpcd/*  rw,
}
  • Profile: /etc/apparmor.d/usr.sbin.ntpdate
  • Beschreibung/Bemerkung: Ich habe überlegt ob er hier oder eigentlich nach D.7 gehört. Weil er aber von /etc/init.d/ntp-client gestartet wird, habe ich ihn hier rein.

Code: Select all

# version 1

abi <kernel>,

profile ntpdate /usr/sbin/ntpdate
{
include <local/ONLYNETWORK>
capability sys_time,
capability sys_nice,
}
Du bist herzlich eingeladen diesen Thread mit Deinen Profilen zu erweitern.

.

Posted: Mon Nov 30, 2020 8:51 pm
by pietinger
Dieses Profil ist vermutlich veraltet ! (Da ich kein Update auf die neue Version des ddclient gemacht habe, konnte ich es nicht anpassen.)
  • Profile: /etc/apparmor.d/usr.bin.ddclient
  • Beschreibung/Bemerkung: Jo, mei, der ddclient halt aus /etc/init.d/ddclient.

Code: Select all

# version 1

abi <kernel>,

profile ddclient /usr/bin/ddclient
{
include <local/ONLYNETWORK>
/usr/bin/ddclient  r,
/run/ddclient/ddclient.pid  rwk,
/var/cache/ddclient/**  rw,
}
.

Posted: Sun Dec 13, 2020 12:36 am
by pietinger
  • Profile: /etc/apparmor.d/usr.sbin.unbound
  • Beschreibung/Bemerkung: Der DNS-Server unbound mit einer Konfiguration wie in B.6 beschrieben.

Code: Select all

# version 1

abi <kernel>,

profile unbound /usr/sbin/unbound
{
include <local/ONLYNETWORK>
capability net_bind_service,
capability setgid,
capability setuid,
capability sys_chroot,
capability sys_resource,
/run/unbound.pid  rw,
}
.

Posted: Mon Apr 03, 2023 3:44 pm
by pietinger
  • Profile: /etc/apparmor.d/usr.sbin.chronyd
  • Beschreibung/Bemerkung: Der NTP-Client/-Server chrony mit einer Konfiguration wie im 5. Post von A.3 beschrieben.

Code: Select all

# version 1

abi <kernel>,

profile chronyd /usr/sbin/chronyd
{
include <local/ONLYNETWORK>
capability sys_time,
capability sys_nice,
capability dac_read_search,
capability dac_override,
capability net_bind_service,
capability setgid,
capability setuid,
/run/chrony/*  rwk,
/var/lib/chrony/*  rwk,
}
.

Achtung Umstellung auf merged-usr

Posted: Wed Apr 03, 2024 1:53 pm
by pietinger
Achtung: Umstellung auf merged-usr

... sorgt für eine böse Überraschung: Einige Profile wurden nicht mehr geladen ... weil ... der Pfad nicht mehr stimmt !

Betroffen sind alle Profile die früher in /usr/sbin/... waren. Leider ist das nach einer Umstellung von split-usr auf merged-usr nicht mehr der Fall, weil /usr/sbin nur noch ein Link auf /usr/bin ist. Wir haben ja in D.4 gelernt dass AppArmor solche Links nicht beachtet ...

Ich musste daher in drei meiner eingesetzten Profilen den Aufruf ändern (das ist die dritte Zeile im jeweiligen Profil):

Code: Select all

profile chronyd /usr/bin/chronyd

profile privoxy /usr/bin/privoxy

profile unbound /usr/bin/unbound
Natürlich habe ich dann den Namen des Profils auch noch geändert obwohl dies nicht zwingend nötig wäre; es soll aber alles seine gute Ordnung haben:

Code: Select all

# lal
...
drwx------  2 root root 4096  7. Mai 2023  local
...
-rw-r--r--  1 root root  299  3. Apr 15:39 usr.bin.chronyd
...
-rw-r--r--  1 root root  187  3. Apr 15:40 usr.bin.privoxy
...
-rw-r--r--  1 root root  230  3. Apr 15:40 usr.bin.unbound