<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="font-family:Noto Sans;">Hello everyone,</span><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Recently I tried to set up Kea for DHCP4 on a small Hyper-V internal network using Debian 12 on my guest. The network range is 192.168.15.0/24 and the IP address of the DHCP server is 192.168.15.2.</p>
<p> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I have attempted to install Kea using `apt install kea` and disabling the kea-dhcp-ddns-server service. Instead, I will use a systemd unit of my own against kea-dhcp4 running under the _kea user. So far so good.</p>
<p> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">When I attempted to start Kea as either _kea or root, it gave me the error below.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Unable to use interprocess sync lockfile (Permission denied): /var/run/kea/logger_lockfile</p>
<p> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">It turns out that this is a limitation imposed by AppArmor. When looking at the output of `journalctl | tail`, I see the following error message.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Oct 21 16:10:32 dhcp audit[109415]: AVC apparmor="DENIED" operation="open" profile="kea-dhcp4" name="/run/kea/logger_lockfile" pid=109415 comm="kea-dhcp4" requested_mask="wrc" denied_mask="wrc" fsuid=102 ouid=102</p>
<p> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">For now I have simply moved the /etc/apparmor.d/usr.sbin.kea-dhcp4 file out of there, which seems to have solved the issue. I still do need to run the program as root however, it can't seem to bind to 67/udp as _kea.</p>
<p> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Considering that I'm on a limited schedule, and am already running this in Hyper-V using an internal switch, security is not my primary concern at this moment. But I don't think it's a great idea to keep this "hotfix" of mine (foregoing AppArmor for Kea altogether) left at rest for too long either.</p>
<p> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Below is the documentation I've used so far.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="https://kea.readthedocs.io/en/latest/arm/config.html#json-configuration">https://kea.readthedocs.io/en/latest/arm/config.html#json-configuration</a></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="https://datatracker.ietf.org/doc/html/rfc7159">https://datatracker.ietf.org/doc/html/rfc7159</a></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="https://groups.google.com/g/linux.debian.bugs.dist/c/EyXCDu5yL4o?pli=1">https://groups.google.com/g/linux.debian.bugs.dist/c/EyXCDu5yL4o?pli=1</a></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="https://wiki.debian.org/AppArmor/HowToUse">https://wiki.debian.org/AppArmor/HowToUse</a></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="https://blog.frehi.be/2023/12/25/protecting-your-linux-server-against-security-exploits-with-apparmor/">https://blog.frehi.be/2023/12/25/protecting-your-linux-server-against-security-exploits-with-apparmor/</a></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="https://gitlab.com/apparmor/apparmor/-/wikis/AppArmor_Core_Policy_Reference#file-permissions">https://gitlab.com/apparmor/apparmor/-/wikis/AppArmor_Core_Policy_Reference#file-permissions</a></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">-- </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Met vriendelijke groet,</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Michael De Roover</p>
</body>
</html>