Description
The account databases (/etc/passwd, /etc/shadow, /etc/group, /etc/gshadow) must be
consistent: each user and group name and each UID and GID is unique, every primary group of a
user exists, and every passwd entry has a shadow entry. pwck -r and grpck -r check
these rules without changing anything.
Rationale
Two accounts with the same UID are the same user for the kernel: files, processes and logs cannot tell them apart. Duplicates and dangling entries are often the trace of a manual edit or of an attacker adding an account.
Impact
None. The check is read-only; fixes need a human decision.
Audit
- Run
pwck -randgrpck -r. They must report nothing, apart from missing home directories of system accounts (lp,news,www-data...), which Debian does not create. cut -d: -f3 /etc/passwd | sort | uniq -dandcut -d: -f3 /etc/group | sort | uniq -dprint nothing.
Automated: every check must pass. Scanners report each check by its id.
pwck
script: |
out=$(pwck -r 2>&1 | grep -v -e "directory '.*' does not exist" -e '^pwck: no changes$')
echo "${out:-pwck: no problem (missing system homes ignored)}"
[ -z "$out" ]
grpck
script: |
out=$(grpck -r 2>&1); rc=$?
echo "${out:-grpck: no problem}"
[ "$rc" -eq 0 ]
duplicate-ids
script: |
u=$(cut -d: -f3 /etc/passwd | sort | uniq -d | tr '\n' ' ')
g=$(cut -d: -f3 /etc/group | sort | uniq -d | tr '\n' ' ')
echo "duplicate UIDs: ${u:-none}; duplicate GIDs: ${g:-none}"
[ -z "$u$g" ]
Remediation
Investigate each reported entry: a duplicate UID 0 or an unknown account may be malicious.
Fix with usermod, groupmod, userdel and groupdel, or interactively with pwck and
grpck (without -r).
References
- pwck(8), Debian manual pages Debian, vendor-doc, accessed 2026-10-18
- grpck(8), Debian manual pages Debian, vendor-doc, accessed 2026-10-18
Mappings
| Framework | ID | Relation |
|---|---|---|
| NIST SP 800-53 Rev. 55.1.1 | IA-2 | related |
How this control relates to the other framework's: equivalent, stricter, looser, partial or related.
Threats mitigated
| Taxonomy | ID |
|---|---|
| MITRE ATT&CK | T1136.001 |
People and lifecycle
| Authors |
|
| Verified | 2026-10-18 by Sn0wAlice on 12, Proxmox VM, Debian 12 genericcloud image, kernel 6.1.0-54-cloud-amd64. Generated check, fix and check again for profiles core and server-hardened; state kept after reboot. |
| Verified | 2026-10-18 by Sn0wAlice on 13, Proxmox VM, Debian 13 genericcloud image, kernel 6.12.113+deb13-cloud-amd64. Generated check, fix and check again for profiles core and server-hardened; state kept after reboot. |
| Introduced in | v0.1.0 |
| Created, updated | 2026-10-18, 2026-10-18 |
| Translations | fr |