Part 4 of 7 · 2 min read
Check the process
Think of a visitor whose badge is checked at the door. The guard may read the room's rules correctly and still refuse, because the badge in the visitor's pocket is not the badge that the visitor thinks it is. The analogy stops in one place: a visitor can look at the badge, while a program's real identity can differ from the one in the shell that started it.
In plain words: The file side is only half the question. The other half is who the process really is, what capabilities it holds and what limits sit on it. /proc/PID/status lists these fields. A service started by systemd or a container may run under a different user, a different group list, fewer capabilities or a filter, whatever the administrator's own shell shows.
A worked example. A process started as nobody with no_new_privs:
Uid: 65534 65534 65534 65534
Gid: 65534 65534 65534 65534
Groups:
CapEff: 0000000000000000
NoNewPrivs: 1
Seccomp: 0
| Field | Reads as | Tells whether |
|---|---|---|
Uid, Gid |
Real, effective, saved, file-system IDs | the process is the user that the operator thinks |
Groups |
Supplementary groups | a group permission on the file can apply |
CapEff |
Effective capability mask (page 4) | root-like acts are possible; 0 means none |
NoNewPrivs |
1 if set (page 4) | a setuid program or file capability can raise rights |
Seccomp |
0 off, 1 strict, 2 filter | a filter may answer EPERM (page 6) |
The process has no capability, so it passes only through the permission bits. Its group list is empty, so no group permission can help it. The file view is the same as the shell's: /proc/PID/root points to / and /proc/PID/ns/mnt shows mnt:[4026531832], which equals the mount namespace of the shell, so no chroot or container hides or replaces paths.
The key lines. Compare the process with the shell that you are testing from. A test that passes in the administrator's shell proves nothing about a service running under another identity. On the test machine, root reads a mode-000 file with exit status 0 (the CAP_DAC_OVERRIDE power of page 4), and nobody is refused.
Effective user ID
The effective user ID is the ID that the kernel uses in permission checks for a process. It can differ from the real user ID, which names who started the process. A setuid program has the owner's ID as its effective ID (page 2).
Example: a setuid-root program started by nobody shows real 65534 and effective 0 in /proc/PID/status.
Check yourself:
1. Why does a test in the administrator's shell not prove that a service can read a file?
2. What does CapEff: 0000000000000000 tell?
3. How does a mount namespace number show that no chroot changed the path?