{"id":3760,"date":"2023-09-13T11:47:40","date_gmt":"2023-09-13T09:47:40","guid":{"rendered":"https:\/\/linux-bibel.at\/?p=3760"},"modified":"2023-09-13T11:47:42","modified_gmt":"2023-09-13T09:47:42","slug":"apparmor-zusaetzliche-sicherheit-unter-debian-durch-einschraenkung-von-anwendungen","status":"publish","type":"post","link":"https:\/\/linux-bibel.at\/index.php\/2023\/09\/13\/apparmor-zusaetzliche-sicherheit-unter-debian-durch-einschraenkung-von-anwendungen\/","title":{"rendered":"AppArmor &#8211; Zus\u00e4tzliche Sicherheit unter Debian durch Einschr\u00e4nkung von Anwendungen"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">AppArmor ist ein Dienst unter Debian, mit dem man sich zus\u00e4tzliche Sicherheit schaffen kann. Diese zus\u00e4tzliche Sicherheit wird dadurch geschaffen, dass Anwendungen \/ Prozesse in ihren Rechten eingeschr\u00e4nkt werden &#8211; genauer gesagt &#8211; die Anwendungen \/ Prozesse haben nur auf diese Verzeichnisse und Dateien Zugriff, auf die sie solche Rechte auch ben\u00f6tigen. In diesem Artikel der Linux Bibel sehen wir uns diese Software etwas genauer an.<br>Diese Anleitung kann unter Debian genutzt werden und sollte auch unter Ubuntu und darauf basierenden Distributionen funktionieren.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Voraussetzungen schaffen<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u00dcber die <a rel=\"noreferrer noopener\" href=\"https:\/\/www.linux-bibel-oesterreich.at\/viewtopic.php?f=10&amp;t=10\" target=\"_blank\">Paket-Verwaltung<\/a> installieren Sie folgende Pakete &#8222;<strong>apparmor apparmor-profiles apparmor-profiles-extra apparmor-utils<\/strong>&#8222;.<br><br>Nach der Installation gilt es AppArmor mit dem System von Beginn an automatisch starten zu lassen. Daf\u00fcr sehen Sie sich zuerst an, ob es das Verzeichnis &#8222;<em>\/etc\/default\/grub.d\/<\/em>&#8220; gibt &#8211; am <a rel=\"noreferrer noopener\" href=\"https:\/\/www.linux-bibel-oesterreich.at\/viewtopic.php?f=9&amp;t=3\" target=\"_blank\">Terminal<\/a> geben Sie dazu folgenden Befehl ein:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls \/etc\/default\/grub.d\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Ist das Verzeichnis nicht vorhanden, erstellen Sie dieses als <a rel=\"noreferrer noopener\" href=\"https:\/\/www.linux-bibel-oesterreich.at\/viewtopic.php?f=10&amp;t=366\" target=\"_blank\">Administrator<\/a> am Terminal mit dem Befehl:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p \/etc\/default\/grub.d<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Anschlie\u00dfend und ebenfalls als Administrator am Terminal erstellen wir nun die Konfiguration mit folgendem Befehl:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 'GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT apparmor=1 security=apparmor\"' | tee \/etc\/default\/grub.d\/apparmor.cfg<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Nun zeigen wir dem Bootloader GRUB seine neue Konfiguration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update-grub<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Anschlie\u00dfend starten Sie den Rechner neu.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">AppArmor anpassen<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nach den oben vorgenommenen Anpassungen sollte AppArmor laufen, dies k\u00f6nnen wir als normaler Benutzer am Terminal mit folgendem Befehl erfragen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/sys\/module\/apparmor\/parameters\/enabled<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Erhalten wir eine Ausgabe wie die folgende l\u00e4uft die Software:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01.jpg\" rel=\"lightbox-0\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01-1024x576.jpg\" alt=\"\" class=\"wp-image-3776\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-01.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Nun k\u00f6nnen wir uns als Administrator mit folgendem Befehl den Status ansehen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aa-status<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02.jpg\" rel=\"lightbox-1\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02-1024x576.jpg\" alt=\"\" class=\"wp-image-3777\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-02.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Sehen wir uns die Ausgabe (<em>in diesem Beispiel<\/em>) als Text an:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apparmor module is loaded.\n53 profiles are loaded.\n34 profiles are in enforce mode.\n   \/usr\/bin\/akonadiserver\n   \/usr\/bin\/evince\n   \/usr\/bin\/evince-previewer\n   \/usr\/bin\/evince-previewer\/\/sanitized_helper\n   \/usr\/bin\/evince-thumbnailer\n   \/usr\/bin\/evince\/\/sanitized_helper\n   \/usr\/bin\/man\n   \/usr\/bin\/pidgin\n   \/usr\/bin\/pidgin\/\/sanitized_helper\n   \/usr\/bin\/totem\n   \/usr\/bin\/totem-audio-preview\n   \/usr\/bin\/totem-video-thumbnailer\n   \/usr\/bin\/totem\/\/sanitized_helper\n   \/usr\/lib\/cups\/backend\/cups-pdf\n   \/usr\/lib\/x86_64-linux-gnu\/lightdm\/lightdm-guest-session\n   \/usr\/lib\/x86_64-linux-gnu\/lightdm\/lightdm-guest-session\/\/chromium\n   \/usr\/sbin\/cups-browsed\n   \/usr\/sbin\/cupsd\n   \/usr\/sbin\/cupsd\/\/third_party\n   \/usr\/sbin\/gpsd\n   \/usr\/sbin\/haveged\n   apt-cacher-ng\n   firejail-default\n   libreoffice-senddoc\n   libreoffice-soffice\/\/gpg\n   libreoffice-xpdfimport\n   lsb_release\n   man_filter\n   man_groff\n   mariadbd_akonadi\n   mysqld_akonadi\n   nvidia_modprobe\n   nvidia_modprobe\/\/kmod\n   postgresql_akonadi\n19 profiles are in complain mode.\n   \/usr\/bin\/irssi\n   avahi-daemon\n   dnsmasq\n   dnsmasq\/\/libvirt_leaseshelper\n   identd\n   klogd\n   libreoffice-oosplash\n   libreoffice-soffice\n   mdnsd\n   nmbd\n   nscd\n   php-fpm\n   ping\n   smbd\n   smbldap-useradd\n   smbldap-useradd\/\/\/etc\/init.d\/nscd\n   syslog-ng\n   syslogd\n   traceroute\n0 profiles are in kill mode.\n0 profiles are in unconfined mode.\n6 processes have profiles defined.\n4 processes are in enforce mode.\n   \/usr\/bin\/akonadiserver (7219) \n   \/usr\/sbin\/cups-browsed (1370) \n   \/usr\/sbin\/cupsd (947) \n   \/usr\/sbin\/haveged (604) \n2 processes are in complain mode.\n   \/usr\/sbin\/avahi-daemon (611) avahi-daemon\n   \/usr\/sbin\/avahi-daemon (659) avahi-daemon\n0 processes are unconfined but have a profile defined.\n0 processes are in mixed mode.\n0 processes are in kill mode.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Folgende Ausgabe:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apparmor module is loaded.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.linux-bibel-oesterreich.at\/viewtopic.php?t=424#\"><\/a>bedeutet nat\u00fcrlich das AppArmor ohne Probleme l\u00e4uft.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>53 profiles are loaded<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">zeigt uns, dass 53 Profile (<em>Regeln f\u00fcr Anwendungen \/ Prozesse<\/em>) geladen sind &#8211; 53 Anwendungen \/ Prozesse werden also durch AppArmor eingeschr\u00e4nkt. Nun wird es interessant &#8211; es gibt verschiedene Modi in denen Profile laufen k\u00f6nnen:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>complain<\/strong> &#8211; Der Modus, in dem ein Profil lernt, was der Prozess darf und was nicht<\/li>\n\n\n\n<li><strong>enforce<\/strong> &#8211; Dies ist der Idealzustand, der Prozess l\u00e4uft nach den Regeln des Profils<\/li>\n\n\n\n<li><strong>audit<\/strong> &#8211; Es werden Zugriffe auf Dateien und Verzeichnisse sowie Regelverst\u00f6\u00dfe aufgezeichnet, ideal um zu sehen, worauf eine Software zugreifen k\u00f6nnen sollte oder will<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Nun gehen wir zur\u00fcck zu unserer Ausgabe:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>34 profiles are in enforce mode.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">34 Profile laufen im &#8222;<strong>enforce<\/strong>&#8222;-Modus, schr\u00e4nken die darunter verzeichneten Prozesse wie es soll in ihren Rechten ein. Weitere 19 Prozesse laufen im &#8222;<strong>complain<\/strong>&#8222;-Modus, lernen also was sie tun d\u00fcrfen und was nicht und so weiter und so fort &#8211; das Lernen geschieht teilweise automatisch, vor allem kurz nach der Installation.<br><br>Nun k\u00f6nnen wir uns auch ansehen, welche Prozesse nicht gesch\u00fctzt sind:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aa-unconfined\naa-unconfined --paranoid<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Diese Liste ist etwas l\u00e4nger:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03.jpg\" rel=\"lightbox-2\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03-1024x576.jpg\" alt=\"\" class=\"wp-image-3778\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-03.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Vor allem nach dem zweiten Befehl:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04.jpg\" rel=\"lightbox-3\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04-1024x576.jpg\" alt=\"\" class=\"wp-image-3779\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-04.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Nun, f\u00fcr viele nicht eingeschr\u00e4nkte Prozesse haben wir uns das Paket &#8222;<strong>apparmor-profiles-extra<\/strong>&#8220; installiert, diese Profile liegen unter &#8222;<em>\/usr\/share\/apparmor\/extra-profiles\/<\/em>&#8220; und sind nicht aktiviert. Diese lassen sich nun etwa mit dem Befehl:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls \/usr\/share\/apparmor\/extra-profiles\/ | less<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">anzeigen:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05.jpg\" rel=\"lightbox-4\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05-1024x576.jpg\" alt=\"\" class=\"wp-image-3780\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-05.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Oder nat\u00fcrlich auch im grafischen Dateimanager:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06.jpg\" rel=\"lightbox-5\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06-1024x576.jpg\" alt=\"\" class=\"wp-image-3781\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-06.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Ein Profil nennt sich so wie der Pfad zu seiner ausf\u00fchrbaren Datei, also f\u00fcr Skype etwa &#8222;<em>\/usr\/bin\/skype<\/em>&#8220; &#8211; so nennt sich das Profil &#8222;<strong>usr.bin.skype<\/strong>&#8222;. M\u00f6chte ich ein Profil nun aktivieren, um die jeweilige Anwendung einzuschr\u00e4nken, gilt es das dazu passende in das Verzeichnis &#8222;\/etc\/apparmor.d\/&#8220; zu kopieren &#8211; also f\u00fcr das obige Beispiel:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp \/usr\/share\/apparmor\/extra-profiles\/usr.bin.skype \/etc\/apparmor.d\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Anschlie\u00dfend gilt es das Profil in den jeweiligen Modus zu versetzen &#8211; in der Regel sollte es bei bestehenden Profilen gen\u00fcgen diese einfach in den &#8222;<strong>enforce<\/strong>&#8222;-Modus zu versetzen &#8211; also (<em>bei nicht laufender Software &#8211; hier eben Skype<\/em>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aa-enforce \/etc\/apparmor.d\/usr.bin.skype<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Nun testet man die Software &#8211; in diesem Beispiel eben Skype, funktioniert alles so wie es soll &#8211; perfekt. Gibt es mit Funktionen Probleme, beenden Sie die Software, versetzen Sie das Profil in den Lern-Modus (<em>die Software darf beim \u00c4ndern in den Lern-Modus nicht laufen<\/em>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aa-complain \/etc\/apparmor.d\/usr.bin.skype<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Nun starten Sie die Software &#8211; in diesem Fall eben Skype und f\u00fchren alle Funktionen aus &#8211; unter anderem eben auch aktivieren der Kamera, speichern von Dateien, Zugriff auf die gew\u00fcnschten Verzeichnisse, &#8230; haben Sie alle Funktionen ausgef\u00fchrt beenden Sie die Software und versetzen deren Profil wieder in den &#8222;<strong>enforce<\/strong>&#8222;-Modus.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Selbst Profile erstellen<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nun gibt es nat\u00fcrlich etliche Anwendungen, f\u00fcr die es keine Profile gibt, beispielsweise gibt es ein Profil f\u00fcr <a rel=\"noreferrer noopener\" href=\"https:\/\/www.linux-bibel-oesterreich.at\/viewtopic.php?f=24&amp;t=422&amp;p=1260#p1260\" target=\"_blank\">Firefox<\/a> unter &#8222;<em>\/usr\/share\/apparmor\/extra-profiles\/<\/em>&#8220; &#8211; es ist aber nicht aktiviert &#8211; aber keines f\u00fcr Google Chrome. M\u00f6chte man ein solches erstellen &#8211; kein Problem, f\u00fcr welche Anwendung oder welchen Prozess auch immer, alles l\u00e4sst sich selbst anfertigen.<br><br>Nehmen wir einmal das Beispiel Google Chrome &#8211; als Erstes gilt es zu erfahren, wie sich die ausf\u00fchrbare Datei nennt &#8211; ein Blick in das Anwendungsmen\u00fc f\u00fchrt meist zum Ziel &#8211; hier etwa unter KDE:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07.jpg\" rel=\"lightbox-6\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07-1024x576.jpg\" alt=\"\" class=\"wp-image-3782\" title=\"apparmor-6.jpg (222.49 KiB) 2167 mal betrachtet\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-07.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">In diesem Beispiel nennt sich die Datei &#8222;<strong>google-chrome-stable<\/strong>&#8220; &#8211; hier findet sich auch gleich der Pfad zur ausf\u00fchrbaren Datei &#8211; ist dies aber nicht der Fall gen\u00fcgt am Terminal der Befehl:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>which google-chrome-stable<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08.jpg\" rel=\"lightbox-7\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08-1024x576.jpg\" alt=\"\" class=\"wp-image-3783\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08-1024x576.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08-300x169.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08-150x84.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08-768x432.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08-1536x864.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/09\/Appamor-08.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Und schon erh\u00e4lt man den Pfad zur ausf\u00fchrbaren Datei, in diesem Fall:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/bin\/google-chrome-stable<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Nun k\u00f6nnen wir als Administrator ein Profil erstellen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aa-genprof \/usr\/local\/bin\/google-chrome-stable<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Der Pfad muss komplett angegeben werden, ansonsten funktioniert die Geschichte nicht. Lassen Sie den Befehl nun laufen und starten die Anwendung ganz normal &#8211; also eben im Beispiel Chrome. Nun surfen Sie im Internet, speichern Dateien unter &#8222;<em>Downloads<\/em>&#8222;, greifen auf das Verzeichnis &#8222;<em>Dokumente<\/em>&#8220; zu &#8211; speichern Sie keine Datei unter Downloads, wird die Software sp\u00e4ter keine Dateien unter &#8222;<em>Downloads<\/em>&#8220; speichern k\u00f6nnen. Greifen Sie beispielsweise nicht auf das Verzeichnis &#8222;<em>Dokumente<\/em>&#8220; (<em>oder andere Verzeichnisse<\/em>) zu, kann die Software dies auch sp\u00e4ter nicht. Das Profil befindet sich im Lern-Modus &#8211; also im &#8222;<strong>complain<\/strong>&#8222;-Modus beim Erstellen.<br><br>Haben Sie alles ausgef\u00fchrt, was Chrome d\u00fcrfen soll, beenden Sie den Browser, wechseln Sie zur\u00fcck auf das Terminal und dr\u00fccken <strong>s<\/strong>. Damit beendet AppArmor den &#8222;<strong>complain<\/strong>&#8222;-Modus und zeigt Ihnen am Terminal was Chrome w\u00e4hrend dieser Zeit getan hat &#8211; jede Aktion wird am Terminal der Reihe nach gezeigt &#8211; erst eine &#8211; diese gilt es nun zu erlauben mit <strong>a<\/strong>, mit <strong>d<\/strong> wird nicht erlaubt &#8211; mehr ben\u00f6tigen Sie in der Regel nicht, anschlie\u00dfend zeigt AppArmor die n\u00e4chste Aktion die durchgef\u00fchrt wurde. Ein Beispiel f\u00fcr eine solche Frage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Profile:      \/usr\/local\/bin\/google-chrome-stable\nPath:         \/etc\/pkcs11\/modules\nMode:         r\nSeverity:     unknow<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Darunter zeigt AppArmor noch eine Legende f\u00fcr alle zu nutzenden Tasten, aber wie schon beschrieben &#8211; mehr als <strong>a<\/strong> und <strong>d<\/strong> brauchen Sie in der Regel nicht. Melder AppArmor das alle Fragen von Ihnen beantwortet wurden speichern Sie das Profil mit <strong>s<\/strong> und beenden den &#8222;<strong>complain<\/strong>&#8222;-Modus mit <strong>f<\/strong>. Das so erstellte Profil ist automatisch aktiv.<br><br>Gibt es nun Probleme starten Sie am einfachsten den &#8222;audit&#8220;-Modus mit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aa-audit \/usr\/local\/bin\/google-chrome-stable<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">und starten die Anwendung &#8211; hier sehen Sie nun was der Software verboten wird, aber vielleicht doch ben\u00f6tigt wird. Wird es Ihnen zu viel l\u00f6schen Sie die Datei aus dem Verzeichnis &#8222;<em>\/etc\/apparmor.d\/<\/em>&#8222;. Diese Dateien k\u00f6nnen Sie nat\u00fcrlich auch mit einem Texteditor bearbeiten. Ein kleines Beispiel:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;tunables\/global&gt;\n\/usr\/bin\/firefox flags=(complain) {\n  #include &lt;abstractions\/base&gt;\n  #include &lt;abstractions\/nameservice&gt;\n  #include &lt;abstractions\/samba&gt;\n  capability net_bind_service,\n  \/proc\/sys\/kernel\/core_pattern r,\n  \/usr\/bin\/firefox mr,\n  \/var\/cache\/samba\/gencache.tdb rwk,\n  \/var\/{cache,lib}\/samba\/browse.dat* rw,\n  \/var\/{cache,lib}\/samba\/gencache.dat rw,\n  \/var\/{cache,lib}\/samba\/wins.dat* rw,\n  \/var\/{cache,lib}\/samba\/smb_krb5\/ rw,\n  \/var\/{cache,lib}\/samba\/smb_krb5\/krb5.conf* rw,\n  \/var\/{cache,lib}\/samba\/smb_tmp_krb5.* rw,\n  \/var\/{cache,lib}\/samba\/sync.* rw,\n  \/var\/{cache,lib}\/samba\/unexpected rw,\n  \/{,var\/}run\/samba\/** rwk,\n  # Site-specific additions and overrides.\n  # See local\/README for details.\n  #include &lt;local\/usr.bin.firefox&gt;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Sie finden die Verzeichnisse und Dateien aufgelistet, dahinter die Rechte:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>r<\/strong> &#8211; Lesezugriff<\/li>\n\n\n\n<li><strong>w<\/strong> &#8211; Schreibzugriff<\/li>\n\n\n\n<li><strong>a<\/strong> &#8211; Hinzuf\u00fcgen von Datei-Inhalten<\/li>\n\n\n\n<li><strong>l<\/strong> &#8211; Setzen von Links<\/li>\n\n\n\n<li><strong>k<\/strong> &#8211; Sperren von Dateien<\/li>\n\n\n\n<li><strong>m<\/strong> &#8211; Datei via mmap ins RAM laden<\/li>\n\n\n\n<li><strong>x<\/strong> &#8211; Ausf\u00fchren von Drittanwendungen<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">AppArmor deaktivieren<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">L\u00f6schen Sie die erstellte Datei unter &#8222;<em>\/etc\/default\/grub.d\/<\/em>&#8220; und f\u00fchren anschlie\u00dfend ein:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update-grub<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">aus.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Erstver\u00f6ffentlichung: Mi 29. Sep 2021, 07:23<\/strong><\/p>\n<div class=\"pld-like-dislike-wrap pld-custom\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"Gef\u00e4llt mir\" data-post-id=\"3760\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                            <img src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/12\/Daumen-Hoch.png\" alt=\"Gef\u00e4llt mir\" \/>\r\n            <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">1    <\/span>\r\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-dislike-trigger pld-like-dislike-trigger  \" title=\"Gef\u00e4llt mir nicht\" data-post-id=\"3760\" data-trigger-type=\"dislike\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                            <img src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/12\/Daumen-Runter.png\" alt=\"Gef\u00e4llt mir nicht\" \/>\r\n            <\/a>\r\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\r\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>AppArmor ist ein Dienst unter Debian, mit dem man sich zus\u00e4tzliche Sicherheit schaffen kann. Diese zus\u00e4tzliche Sicherheit wird dadurch geschaffen, dass Anwendungen \/ Prozesse in ihren Rechten eingeschr\u00e4nkt werden &#8211; genauer gesagt &#8211; die Anwendungen \/ Prozesse haben nur auf diese Verzeichnisse und Dateien Zugriff, auf die sie solche Rechte auch ben\u00f6tigen. In diesem Artikel [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3775,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[],"class_list":["post-3760","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sicherheit"],"_links":{"self":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/3760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/comments?post=3760"}],"version-history":[{"count":3,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/3760\/revisions"}],"predecessor-version":[{"id":3812,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/3760\/revisions\/3812"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media\/3775"}],"wp:attachment":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media?parent=3760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/categories?post=3760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/tags?post=3760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}