166 points · by media_hacker · 5y ago · 82 comments
Speaking of which, what is everyone here’s view on allowing passwordless sudo on Linux servers?
In my mind, if someone has already gained access to my user on the server, which has sudo privileges, they are only a couple of steps away from be able to take control over the server anyways. So I allow sudo without password on my servers.
sudo password is basically nothing but an annoyance.
Likewise, my ssh keys are also not password protected. If you are able to read my ssh keys, you have already won anyways. No point to me in having a password on them.
Where I do take extra steps instead include:
- I disable password based authentication for sshd, allowing only keybased authentication.
- On some servers I have sshd listening on WireGuard interfaces only.
- My personal devices use full disk encryption.
- I lock computers and other devices when I walk away from them.
- I use 2FA for any third-party services of importance such as mail etc, preferring TOTP/HOTP if available. Or SMS based if that’s the only option even though it’s not very good it’s something.
- I use an adblocker in the browser on my computers.
- I am careful not to get tricked by phishing emails, phishing SMSes and other scam messages.
- I install software from trusted sources mainly.
- I use an iPhone, not Android.
I’m pretty satisfied about my own computer security.
Next step I need to handle is proper backups. I have too many files that are stored in n=1 locations. I have some of the most important files in n>=2 locations, but still there are many important files that I don’t.
Passworded sudo is just another roadblock to give you more time. Passwordless means instead of the attacker getting local root and then having to find an exploit, they immediately get to escalate to root. For very sophisticated attackers, it may by a trivial difference in time, but for unsophisticated ones it may mean they don't get root to do more damage.
And given that sophisticated attackers are ones you can't really guard well against without a whole department devoted to it, unsophisticated ones are probably ones you should really make sure not to ignore.
I recently had the - unfortunate - opportunity to put this to the test. The house I live in has the highest grade burglary protection that you can still buy for normal money (courtesy of the previous owner). It still only took me 35 minutes to break into it when I accidentally closed the door behind me when there was nobody else home. This kind of surprised me, because I didn't have access to any tools at all, just the stuff that was laying around in the garden (some sticks and a little bit of steel wire). And all that without breaking anything, if that constraint would not have been there the 35 minutes would have been reduced to 30 seconds, tops.
Later I figured out three other ways to get in without any damage, but most of those would have cost a bit more time.
The problem with this world-view is that it's a fallacy. You're assuming that people won't be bothered by having to re-type their password all the time, and just implement a "secure" script using a setuid bit instead.
Now someone else intentionally adds the ability to allow that script to execute arbitrary commands and you've got a vulnerability with passworded sudo that would have never happened with passwordless sudo.
I've seen that same story happen countless times in the real world. E.g. a company I worked for went from a "bastion" login system (authenticate once) for the sysadmin "run a command on the fleet" interface of last resort to requiring "re-authentication on login", which now needed a re-login with a OTP for each machine, in a datacenter with quite a few machines.
That's conceptually the same as insisting on passworded sudo in terms of security. Guess what happened next in that setup? No points for "sysadmins just got used to re-typing their passwords in the for-loop" :)
For that reason, I’d prefer passphrase backed keys, even if they had very long (36h+) expiry time.
Edit: one cool hack I use is a conplex FDE password, but relatively simple /etc/shadow password - this saves a huge amount of effort.
For example, the obvious question is probably "why is anyone sudo'ing". A lot of operational capabilities don't need sudo. Some do.
Rather than handing over passwordless sudo, you can provide binaries that can execute with the required permissions but provide a much more granular interface. For example, if you need to take a memory dump of a service the binary could be set up to only allow that capability and to only work on a set of services.
Further, you may want to audit sudo access but allow it. If you remove the need for root capabilities for engineering purposes you should see sudo very rarely and be able to alert on that - but obviously this assumes you have an instrumentaiton pipeline set up.
Speaking of instrumentation, it's one of the major reasons why you don't want to just hand root over. An attacker with root can more or less just turn instrumentation off. An attacker without root is auditable.
For your specific situation your current security posture could be fine. For a large company they may want to do more.
The tl;dr is really that, yeah, on some default Linux system where you assume an attacker is executing within your user already, a password on sudo isn't gonna help much. But obviously you should harden that server, and a big part of that is going to be "how do I keep the attacker from getting root".
This seems like sound logic to me. If you have write permission to their bashrc, it's trivial to change their path to include a keylogging wrapper for sudo. The next time they use sudo, you have their password. If an attacker has gotten that far, a password on sudo seems like closing the barn doors after the horses already ran off.
1. Audit writes to paths like bashrc (I've written this alert and many others like it)
2. Audit writes from processes under uid X to files in uid Y's home
3. Limit the need to sudo in the first place
4. Add a TOTP auth to sudo
5. Limit the ability for arbitrary processes to write to arbitrary files (containerize your shells, services, etc).
The thing is that all of the above assume the attacker isn't already root. If the attacker is root, this all becomes a lot harder.
and not having to confirm anything to use your ssh keys means not only your machine is compromised but all of those that those keys allow access to are potentially compromised too now... i use an ssh-agent (gpg-agent implementation) to only ask once at the start of my session for the password and every time for confirmation of usage or after some time without usage it will ask for the password again. its not annoying at all...
Now, given we don't do any of that shit, it's trivially easy to hijack a root/ssh key password request by just faking the dialog. In that sense, you may as well go passwordless. However, IMO going passwordless is tantamount to admitting not just that our security sucks, but that our security is going to suck forever. Seems kind of defeatist.
Sudo can use root password instead of user password. Possibly other auth mechanisms also. It may be better to fine tune sudoers than to leave it wide open.
None of this is ever so black and white. If I have your ssh keys, haven't I only won if you're not also using a password? Otherwise, all I have is your ssh keys, which granted, is bad, but defense-in-depth, no?
In general if someone has enough access to get your ssh private keys, they have enough access to log the next time you type the password.
> Otherwise, all I have is your ssh keys, which granted, is bad, but defense-in-depth, no?
Everything is trade offs. In order for the password to not be completely worthless, it has to be complex enough to not be trivially broken by password crackers. But then it's long and hard to type. If you have to type it a lot, and all it's buying you is that the attacker has to wait for the next time you type the password, that's a poor cost benefit ratio.
Anecdotally, every machine I've RDP'ed to has prompted me with this [0] warning on first connection. Instructions from IT were to just click through the warning. How the hell am I supposed to vet that I'm actually connecting to the right server in that case?
[0] https://techcommunity.microsoft.com/t5/image/serverpage/imag...
If one of their servers gets compromised, it would be bad for us.
Granted most RDP sessions happen in a VM due to the VPN needed, but that's not a huge comfort.
Edit: Downvotes why?
More fundamentally, goes to show that it is possible to have an escape like this, over a communication channel which isn't readily obviously so exoloitable. This, beyond the viln itself, seems like a valuable thing.
What part of the learning process is turning off Windows Updates for months on the host machine? That's like saying cutting the brake lines is part of learning to drive. You have to go out of the way to mess things up, not forget or not know to do something.
This lets you view and control a full desktop session (rather than a text command shell) over a network connection to a remote client.
Like VNC, but a Microsoft proprietary protocol.
(I think VNC came into common usage after RDP was a thing, but I'm not certain.)
VNC was first created by the Oracle and Olivetti Research Lab, Cambridge, prior to their acquisition in 1999. RealVNC (the first version I remember using (I think on an Acorn)) was founded as a company in 2002, TightVNC first released 2001. From memory I was convinced VNC was around much earlier, though Wikipedia set me straight.
For remote desktop use, it seems unfair to mention Xorg. The X windowing system was designed from day 1 as "an architecture-independent system for remote graphical user interfaces and input device capabilities." and version 11 (X11), was first specified in 1987 and is still in common use today. Its also worth mentioning that the implementation and resulting usability /usecases of remote X applications has caused its fair share of conversation and consternation over its lifetime.
I attended one of those week long training classes on Distributed COM.. My take on it was it was fiendishly complicated to get type safety out of DCOM. They were going to make it work, but one group of old timers couldn't see any benefit over bare RPC (which grew into the wire protocol for serialization of Java objects)... oy. Then we has message brokers and somewhere in there I just backed slowly into the hedges and disappeared.
https://www.freerdp.com/ https://github.com/FreeRDP/FreeRDP/security/advisories/ https://security-tracker.debian.org/tracker/source-package/f...
There is also the point on ASLR making life difficult, well if ASLR is switched on, there are a number of other options which may be also switched on in that part of the system, eg Control Flow Guard, DEP (been around for a couple of decades now), forced ASLR, bottoms up ASLR, High Entropy (more useful if you have shed loads of ram installed than minimum amounts), SEHOP (http://www.uninformed.org/?v=5&a=2&t=txt) and Validate Heap integrity which are all on by default now a days in the systems I have seen. Then there is group policy where in Pro or above, you can control what programs run, in home you can add some of the group policy reg keys and get the same functionality when the functionality exists in the dll's.
It reminds me of the bug where you could use notepad to pop a shell, but I'd be interested to see if this would still work with core isolation switched on, Defender Application Guard switched on to sandbox different apps, not just Edge.
The number of installers for various apps which dont handle Ransomware Protection aka Controlled Folder Access being switched on, even some big names like Dell's Data Vault havent got that sorted yet, but I still think the best way to hack a system is the old way and get them to download and install an app which can run malicious software or become malicious like exploiting macro functionality because who even configures their firewalls to block anything by default from leaving your machine or network or router? Its such a pain configuring that side of things, exploiting human behaviour aka laziness is something you can count on.
Its worth reminding ourselves about Stuxnet, they still havent caught those people, but lots of assumptions exist. https://www.youtube.com/watch?v=Fqk_VUMzY_M https://www.youtube.com/watch?v=DDH4m6M-ZIU https://www.youtube.com/watch?v=CS01Hmjv1pQ
Its sheer size meant AV companies spent over a year reverse engineering it to find out if it was even a virus! Not something a lowly individual could do, but a team of crack coders might.
And a little reminder, when is a false positive not a false positive? https://www.theguardian.com/technology/2014/may/06/antivirus...
I thought it was widely known that stuxnet is very likely if not certainly a join NSA and Israel operation.