shadow.set_password is leaking passwords to log file
Using shadow.set_password prints the password to the minion log file. This creates a security issue undermining the usability of this module. This was created on salt 0.17.2 on Win 2012. I have not yet test it on Linux - it might be an issue there as well.
It is printed in 3 places 2 in DEBUG and 1 in INFO:
2014-01-28 18:53:50,369 [salt.minion ][INFO ] User root Executing command shadow.set_password with jid 20140128185350264669
2014-01-28 18:53:50,369 [salt.minion ][DEBUG ] Command details {'tgt_type': 'glob', 'jid': '20140128185350264669', 'tgt': '*srv1*', 'ret': '', 'user': 'root', 'arg': ['Administrator', 'PASSWORD12345'], 'fun': 'shadow.set_password'}
2014-01-28 18:53:50,384 [salt.minion ][DEBUG ] Parsed args: ['Administrator', 'PASSWORD12345']
2014-01-28 18:53:50,384 [salt.loaded.int.module.cmdmod][INFO ] Executing command 'net user Administrator PASSWORD12345' in directory 'C:\\Windows\\system32\\config\\systemprofile'
A quick/temp workaround might be to remove the INFO log (or just the password part) and to advertise that debug mode can leak some private info.
A better fix would be to make the log file only readable by root. This issue is not limited to passwords - everything is leaked to the log, including the contents of files only readable by root. If you have a chmod 700 backup script that contains a MySQL root password, this will also leak to the log.
@tweenk I would argue that in this case both fixes are appropriate, since someone gaining root/administrator access without that account's password would profit from that still being in the log.
@tweenk @kaithar note that some companies send this log to remote location (Splunk/Sumo/Logstash) for sec / compliance reasons. That info should never leave the machine (and actually should never exist in clear text even locally)
I would argue that Salt core / modules should be responsible not to leak private information while in higher than debug mode.
@froyke another excellent point. As a tangent to it, I'm not sure if there are any security standards that would throw a fit for having root passwords in clear, regardless of where that clear is. I'm thinking things like PCI DSS, ISO 27001, etc.
That "parsed args" bit is for debugging purposes only, and was added fairly recently. I'll remove it.
@thatch45 I don't think this issue is closed. There are 3 log lines where the password was written. That commit fixes only 1 of them - where the most critical IMO it is the info level one ( [salt.loaded.int.module.cmdmod][INFO ] Executing command 'net user Administrator PASSWORD12345'...).
Debug should be informative as possible.
Oh good point... I'm on it.
@thatch45 https://github.com/saltstack/salt/pull/10090
Thanks @terminalmage looking good. There is still one remaining debug line - but personally I think we can live with it if Salt documentation will clearly state that debug mode it can leak sensitive info.
@froyke So you're talking about the "command details" line? We have a bit less flexibility there unfortunately. The commands that are logged can be quieted using the output_loglevel parameter. But the one that logs the command is generic and doesn't have this ability.
@terminalmage ya, I had that feeling that this is something generic . This (plus the debugging value) is why I suggest not to handle it - and just note somewhere in Salt docs that debug mode should be for only debugging and could leak sensitive info.