SSH Root Login Permitted

The SSH server lets the root account log in directly, so a guessed or stolen root credential gives full control in one step and leaves no record of which administrator used it.

SeverityMedium
CVSS 3.16.6 CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H Open in the calculator
CVSS 4.07.5 CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N Open in the calculator
CWECWE-250: Execution with Unnecessary Privileges
MITRE ATT&CKT1021.004 SSH, T1078.003 Local Accounts, T1110.001 Password Guessing
CategorySecurity Misconfiguration

Description

The SSH server accepts logins as root, through PermitRootLogin yes or, where root has a key, prohibit-password (formerly without-password). Administrators can then sign in to the root account directly, instead of signing in with a named account and elevating with sudo or su when they need to.

Because the root account exists on every Unix-like system, its name never has to be guessed, and it is the first account automated attacks try. An attacker who guesses, captures or finds the root password or a root private key gains complete control of the server at once: they can read and change any data, install persistent access, alter logs and use the server to attack other systems.

Direct root login removes the extra step, and the separate credential, that a named account followed by sudo would require. It also means that the server's logs record only that root signed in, not which administrator it was, which makes it harder to establish who performed an action, or whether an attacker did. The risk is greater where password logins are also accepted, where the service is reachable from the internet, and where the same root password is used on several servers.

The setting cannot be read reliably from the network, because OpenSSH answers a refused root login in the same way as a wrong password. It is normally identified from the configuration during an authenticated scan or build review (sshd -T shows the value in effect), or when a root password or key is obtained during testing. The OpenSSH default is prohibit-password, which still allows root to log in with a key; older releases, and some distributions and appliances, use yes.

Remediation

Disable direct root logins and give each administrator a named account:

  • Set PermitRootLogin no in sshd_config, check that no file included from /etc/ssh/sshd_config.d/ sets it earlier (OpenSSH uses the first value it reads), and reload the service. Confirm the value in effect with sshd -T | grep -i permitrootlogin.
  • Before the change, make sure each administrator has a named account with key-based login and is allowed to elevate with sudo, so that access is not lost.
  • Where an automated process genuinely needs root over SSH, use PermitRootLogin forced-commands-only and restrict its key in root's authorized_keys file with the command= and from= options, or give the process its own account with narrowly scoped sudo rules.
  • Limit who may log in at all with AllowGroups or AllowUsers.
  • Change the root password, and remove keys from root's authorized_keys file that are no longer needed.

Until the change is made, restrict SSH to management networks and monitor authentication logs for root logins. Confirm the fix by attempting to log in as root with valid credentials, which should be refused.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Network Services Findings

Every Network Services finding