I launched named service with unprivileged account on my debian with:
useradd named
chown -R named:named /etc/bind/
named -u named
which is supported and it works. But i started to wonder how can normal user "named" listen on port 53 without being a root?
What I checked already on my debian:
- no changes in kernel parameters (net.ipv4.ip_unprivileged_port_start = 1024)
- no suid root on named binary (-rwxr-xr-x 1 root root 546K 09-21 19:33 /usr/sbin/named)
- no redirects in IPTABLES (iptables -L -v -n EMPTY)
- no capabilites on named binary (getcap /usr/sbin/named EMPTY)
please let me know how does it work as i cant listen on privileged port on normal account in my debian.
With
setcap, it's possible to add capabilities likeCAP_NET_BINDto be able to bind on port 53 as user.That's what is used in
bind9akanamed:gives:
from
man 7 capabilities:Linux kernel capabilities are a feature of the operating system that allow the traditional superuser (root) privileges to be broken down into smaller, more manageable units, which can be assigned individually to processes. Instead of granting a process all the privileges by giving it the UID (User ID) 0 (root), you can assign only the specific capabilities it needs to operate properly. This reduces the security risk associated with running processes with full superuser privileges.
How Capabilities Work
The Linux kernel divides privileges into a set of distinct capabilities, each controlling a specific aspect of the system. For example, the capability
CAP_NET_BIND_SERVICEallows a process to bind to a network port numbered below 1024, andCAP_DAC_OVERRIDEallows overriding discretionary access controls like file permissions.Assigning Capabilities
Capabilities can be assigned in several ways:
setcapor by a init system that supports capability assignments.setcap, you can assign capabilities directly to an executable file. When the file is executed, the process inherits the assigned capabilities.Managing Capabilities
execvesystem calls, making it easier to use capabilities in environments where binaries need to maintain their privileges after being launched by non-privileged users.Benefits of Using Capabilities
Capabilities thus provide a more granular and secure method of privilege management on modern Linux systems, allowing for better control and limitation of process rights.