Debian Codegraph @

doc/capability.md

raw
1 # Notes concerning wider use of capabilities
2
3 ## Overview
4
5 **NOTE** These notes were added to the libcap package in
6 libcap-1.03. They pre-date file capability support, but fully
7 anticipate it. They are some thoughts on how to restructure a system
8 to better leverage capability support. I've updated them to render as
9 an `.md` formatted file.
10
11 As of Linux 2.2.0, the power of the superuser has been partitioned
12 into a set of discrete capabilities (in other places, these
13 capabilities are know as privileges).
14
15 The contents of the libcap package are a library and a number of
16 simple programs that are intended to show how an application/daemon
17 can be protected (with wrappers) or rewritten to take advantage of
18 this fine grained approach to constraining the danger to your system
19 from programs running as 'root'.
20
21 ## Notes on securing your system
22
23 ### Adopting a role approach to system security
24
25 Changing all of the system binaries and directories to be owned by
26 some user that cannot log on. You might like to create a user with
27 the name 'system' who's account is locked with a '*' password. This
28 user can be made the owner of all of the system directories on your
29 system and critical system binaries too.
30
31 Why is this a good idea? In a simple case, the `CAP_FOWNER` capability
32 is required for the superuser to delete files owned by a non-root user
33 in a _sticky-bit_ protected non-root owned directory. Thus, the sticky
34 bit can help you protect the `/lib/` directory from a compromized
35 daemon where the directory and the files it contains are owned by the
36 system user. It can be protected to ensure that the daemon is not
37 running with the `CAP_FOWNER` capability...
38
39 ### Limiting the damage
40
41 If your daemon only needs to be setuid-root in order to bind to a low
42 numbered port. You should restrict it to only having access to the
43 `CAP_NET_BIND_SERVICE` capability. Coupled with not having any files
44 on the system owned by root, it becomes significantly harder for such
45 a daemon to damage your system.
46
47 Note, you should think of this kind of trick as making things harder
48 for a potential attacker to exploit a hole in a daemon of this
49 type. Being able to bind to any privileged port is still a formidable
50 privilege and can lead to difficult but _interesting_
51 man-in-the-middle attacks -- hijack the telnet port for example and
52 masquerade as the login program... Collecting passwords for another
53 day.
54
55 ### The /proc/ filesystem
56
57 This Linux-specific directory tree holds most of the state of the
58 system in a form that can sometimes be manipulated by file
59 read/writes. Take care to ensure that the filesystem is not mounted
60 with uid=0, since root (with no capabilities) would still be able to
61 read sensitive files in the `/proc/` tree - `kcore` for example.
62
63 [Patch is available for 2.2.1 - I just wrote it!]