Checks / Files

Sensitive files have loose permissions

Check
fs.sensitive_perms
Severity
high
Runs
on the server, in the daily run of the agent
Looks at
Mode and owner of /etc/shadow, /etc/gshadow, /etc/passwd, /etc/group, /etc/sudoers, sshd_config, SSH host keys
Updated 26 Nov 2026

What the check looks at

The owner and mode of /etc/shadow, /etc/gshadow, /etc/passwd, /etc/group, /etc/sudoers, /etc/ssh/sshd_config and the private SSH host keys (/etc/ssh/ssh_host_*_key). The check fails when a file is not owned by root, when its group or other users can write to it, or when other users can read a file with secrets (shadow, gshadow, sudoers, host keys). Only the groups shadow (shadow files) and ssh_keys (host keys) may read those. The agent does not read the contents.

Risk

  • /etc/shadow and /etc/gshadow hold the password hashes, which a reader can try to crack offline.
  • /etc/passwd, /etc/sudoers and sshd_config decide who is root, who may use sudo and how SSH logins work. A normal user who can write to one of them can make themselves root; sshd does not check the permissions of its configuration file.
  • A private host key that others can read lets them impersonate the server. sshd refuses such a key with Permissions 0644 for '/etc/ssh/ssh_host_ed25519_key' are too open. and This private key will be ignored.

Loose permissions usually come from a chmod -R, or from a cp without -p during a migration or a restore.

How to fix it

The defaults we found on fresh installations in November 2026:

File Debian, Ubuntu RHEL, Rocky Linux, AlmaLinux Alpine
/etc/shadow 640 root:shadow 000 root:root 640 root:shadow
/etc/gshadow 640 root:shadow 000 root:root (does not exist)
/etc/passwd 644 root:root 644 root:root 644 root:root
/etc/sudoers 440 root:root 440 root:root 440 root:root
/etc/ssh/sshd_config 644 root:root 600 root:root 644 root:root
private host keys 600 root:root 600 root:root (Rocky Linux 9 key generation: 640 root:ssh_keys) 600 root:root

Debian and Ubuntu

sudo chown root:shadow /etc/shadow /etc/gshadow && sudo chmod 640 /etc/shadow /etc/gshadow
sudo chown root:root /etc/passwd /etc/sudoers /etc/ssh/sshd_config
sudo chmod 644 /etc/passwd /etc/ssh/sshd_config
sudo chmod 440 /etc/sudoers
sudo chmod 600 /etc/ssh/ssh_host_*_key

RHEL, Rocky Linux and AlmaLinux

The package setup owns the account files, so rpm can put them back:

sudo rpm -V setup               # lists files whose mode or owner changed (M, U, G)
sudo rpm --restore setup        # restores mode and owner of shadow, gshadow, passwd, group
sudo chmod 440 /etc/sudoers
sudo chmod 600 /etc/ssh/sshd_config /etc/ssh/ssh_host_*_key

Alpine

chown root:shadow /etc/shadow && chmod 640 /etc/shadow
chown root:root /etc/passwd /etc/sudoers /etc/ssh/sshd_config
chmod 644 /etc/passwd /etc/ssh/sshd_config
chmod 440 /etc/sudoers
chmod 600 /etc/ssh/ssh_host_*_key

If others could read a private host key for a while, generate new host keys (ssh-keygen -A after you move the old ones away) and update the known_hosts entries of the clients.

How to check the fix

sudo stat -c '%a %U:%G %n' /etc/shadow /etc/gshadow /etc/passwd /etc/sudoers \
    /etc/ssh/sshd_config /etc/ssh/ssh_host_*_key
sudo sshd -t

The modes must match the table, and sshd -t must not print UNPROTECTED PRIVATE KEY FILE.

When a warning is fine

Modes stricter than the table pass, for example 600 for sshd_config on Debian, and so does the RHEL layout of host keys (640, group ssh_keys).

Sources