Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

On all our boxes we have ssh access via keys. All keys are password protected. At this moment the sudo mode is not passwordless. Because the number of VMs are growing in our setup, we investigate the usage of Ansible.

Ansible itself says in the docs:

Use of passwordless sudo makes things easier to automate, but it’s not required.

This got me thinking about passwordless sudo and I found some questions/answers here. However, I couldn't really find anything about the security concerns of passwordless sudo per se.

It could happen in the future user Bob has a different password on machine X than Y. When Bob is a sudoer, this gives problems with Ansible to enter one sudo password for all boxes. Given the facts ssh is done via keys, keys are password protected and all user accounts have passwords (so su bob is impossible without a password): how is the security affected when NOPASSWD is set in the sudo file?

share|improve this question
add comment

4 Answers

up vote 7 down vote accepted

NOPASSWD doesn't have a major impact on security. Its most obvious effect is to provide protection when the user left his workstation unattended: an attacker with physical access to his workstation can then extract data, perform actions and plant malware with the user's permissions, but not elevate his access to root. This protection is of limited use because the attacker can plant a keylogger-type program that records the user's password the next time he enters it at a sudo prompt or in a screensaver.

Nonetheless, requiring the password does raise the bar for the attacker. In many cases, protection against unsophisticated attackers is useful, particularly in unattended-workstation scenarios where the attack is often one of opportunity and the attacker may not know how to find and configure discreet malware at short notice. Furthermore it is harder to hide malware when you don't have root permissions — you can't hide from root if you don't have root.

There are some realistic scenarios where the lack of a password does protect even against sophisticated attackers. For example, a stolen laptop: the user's laptop is stolen, complete with private SSH keys; either the thief manages to guess the password for the key file (perhaps by brute force), or he gains access to them from a memory dump of a key agent. If the theft is detected, this is a signal to investigate recent activity on that user's account, and this means that a planted malware should be detected. If the attacker only had user-level access, anything he did will leave traces in logs; if the attacker obtained the user's password and ran sudo, all logs are now compromised.

I don't know whether the downsides of NOPASSWD balance the upsides for your use case. You need to balance that against all the other factors of your situation. For example, it seems that you allow but don't enforce having different passwords. Can you instead use a centralized account database? How much containment do you need between your systems? Are you considering alternatives to Ansible that would support differing sudo passwords? Have you considered other authentication mechanisms?

share|improve this answer
    
We are also currently investigating usage of 2FA for ssh logins. That means the stolen laptop isn't that much of a risk anymore when the token isn't taken as well. Thank you for the response, as it most closely resembles what I somewhat expected for an answer :) –  Jurian Sluiman Nov 21 '13 at 8:31
1  
One other aspect to consider with respect to using NOPASSWORD is that it removes one very useful control. If access requires a password, you can centrally restrict access to everyone/everything by changing the password. This is not as useful if scripts all sudo to root. However, with good partitioning of authorisation into different accounts, can be quite useful. –  Tim X Nov 21 '13 at 21:59
add comment

There are two specific cases why you don't want passwordless sudo:

  1. This is a defense mechanism against malicious users who gain access to an administrative account. This can either be through exploitation or due to an admin leaving his workstation unattended without locking his session.
  2. Having to re-issue the password when using sudo gives impulsive users the time to think twice before actually performing the action.

About automation:

I agree you can do this passwordless, but by not requiring the sudo password you are actually giving ALL access to your automation tool. Now think what the tool is actually required to do? Does it really need all these accesses? Probably not.

Sudo comes with a nice feature which allows you to configure specific commands with the NOPASSWD flag within the sudoers file:

username myhost = (root) NOPASSWD: /sbin/shutdown
username myhost = (root) NOPASSWD: /sbin/reboot
share|improve this answer
    
For ansible provisioning the server, it is required ansible can use vim, has file read/write permissions in /etc and /var, can use apt and can start/stop/reload services. Is the protection for specific commands still a viable option then? –  Jurian Sluiman Nov 19 '13 at 13:57
    
sure why not? Vim is just another command no? –  Lucas Kauffman Nov 19 '13 at 14:44
    
Unfortunately I cannot accept two answers, so I had to choose between yours and @Gilles. Both are good answers, but it felt Gilles gets closer to the actual risk of NOPASSWD. I just +1'd you now :) –  Jurian Sluiman Nov 21 '13 at 8:32
    
No worries, I think his answer covers your question better than I did ^^ –  Lucas Kauffman Nov 21 '13 at 8:33
add comment

Given the facts ssh is done via keys, keys are password protected and all user accounts have passwords (so su bob is impossible without a password)

Let's be clear here. The passwords used to protect the SSH keys and the passwords of the user accounts ARE NOT THE SAME ONES.

NOPASSWD simply allows the user to execute commands as another user without entering his password. It does not affect the fact that the user has to enter his password when SSH-ing into the system.

share|improve this answer
    
Thanks for the answer. I know the fact NOPASSWD does not affect ssh logins. And of course there are different passwords, at least: that is what we ask from those who have the privilege. But in the end, I cannot check their passwords so I don't know for sure. –  Jurian Sluiman Nov 19 '13 at 13:55
1  
@JurianSluiman It's good that you know that, wasn't very clear coming from the question. NOPASSWD is really more of a convenience option and doesn't really affect security that much imo. It's more important to ensure that users are given only as much sudo privileges as required to get the job done. –  Terry Chia Nov 19 '13 at 13:58
add comment

There are pros and cons to having the user enter a password to access sudo.

Pro: better protection if someone gains access to an admin account. eg through an unlocked terminal, or some sort of exploit.

Con: the user is entering a plain text password which is encrypted in transit, but then decrypted before it reaches the user's shell. Someone could for example tamper with the bashrc script to run a key logger. Depending on your setup, and the users' haits that might permit use of the password for direct login to the users account on this machine, and perhaps on other machines as well. People re-use passwords all too often.

share|improve this answer
    
If they can tamper with your bashrc script they've pretty much already won anyhow. –  atk Nov 19 '13 at 15:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.