10 ms·
There's something to the idea of rehabilitating "obscurity", or at least recognizing that "cost" is part of threat models, and you can raise costs for particula
by tptacek 6y ago
There's something to the idea of rehabilitating "obscurity", or at least recognizing that "cost" is part of threat models, and you can raise costs for particular attack vectors by degrees instead of "to infinity".
But SSH is a terrible example, because the cost to the defender of simply not having SSH vulnerabilities is the same, or even less, than the cost of obfuscating it with nonstandard ports, "port knocking", or fail2ban, which are all silly ideas.
Just use SSH keys, and disable passwords.
I think maybe it comes down to this: dialing attacker costs up incrementally can make sense if it's the most cost-effective way for a fully-informed defender to improve security. But incremental cost-increasing countermeasures aren't a substitute for sound engineering; you don't get to count "having to learn stuff" as a valid defender cost.
- MiroF 6y agoThe cost of not having SSH vulnerabilities is infinite because there is no way to ensure that.
- deleted 6y ago[deleted]
- meowface 6y agoIt's not really a direct security advantage, so this is mostly off-topic, but changing the default port does greatly reduce log noise, and theoretically could be a bit less taxing for your network connection or CPU if it's a cheap server not intended for publicly hosting services. (If it is then the traffic would be a drop in the bucket compared to regular production traffic, though. And it's admittedly probably a drop in the bucket either way.) Reducing log clutter alone probably does confer some small indirect benefit, since it's less likely a more sophisticated attempt or successful breach would go unnoticed when inspecting logs. (Assuming there's some SIEM log forwarding or that it's not a situation where an attacker was able to or wise enough to wipe logs.)
- xioxox 6y agoOne advantage of putting ssh on a non-standard port is that your logs, which are otherwise filled with automated ssh break-in attempts, now become almost empty. It's much easier to look for other problems when the signal to noise is increased.
- p49k 6y agoHeartbleed caused data leakage in the handshake phase of the protocol. I don’t know if SSH was affected, but there’s no reason why a similar exploit won’t be found for SSH in the future, and trivially obscuring your SSH port protects you from 99.9+% of automated attacks, possibly buying you time to patch or mitigate.
- jjeaff 6y agoI could be wrong, but if you are using public/private keys to authenticate to ssh, then even attacks that can listen in on the connection would be limited. Because the private key is never transmitted, unlike a password.
- p49k 6y agoWith heartbleed, a bug in the implementation of the protocol led to the server randomly leaking contents of the server’s memory, which could be anything from private keys to user or system passwords to other confidential information. No passwords or MitM was required. You can read more at heartbleed.com
- yjftsjthsd-h 6y agoAnd it still doesn't matter, because sshd literally never has the private key that allows access. If a server only allows access via SSH key, you could literally have a complete RAM dump of the whole system and not be able to access it.
- boredpenguin 6y ago> still doesn't matter (...) you could literally have a complete RAM dump of the whole system and not be able to access it. I'd say that matters. Think about all the secrets (tls keys, whatever) a server has in memory. If you can't connect to the sshd daemon, you can't attack it.
- justinsaccount 6y ago> Just use SSH keys, and disable passwords. CVE-2001-0144 - SSH1 CRC-32 compensation attack detector allows remote attackers to execute arbitrary commands on an SSH server or client via an integer overflow CVE-2008-0166 - OpenSSL 0.9.8c-1 up to versions before 0.9.8g-9 on Debian-based operating systems uses a random number generator that generates predictable numbers, which makes it easier for remote attackers to conduct brute force guessing attacks against cryptographic keys. I had a machine almost get compromised from the 1st vulnerability ( noexec on /tmp broke their script ). When the 2nd came out I was using non standard ports and or port knocking. Despite having vulnerable keys I was safe until I could upgrade. If a SSH RCE 0day was released: * every "Just use SSH keys, and disable passwords" box sitting on the internet with ssh on port 22 will get compromised within hours. * The boxes using fail2ban will get compromised within hours. * The majority of boxes on nonstandard ports would likely be ok, at least for some time. * The boxes using port knocking would be safe.
- acdha 6y agoOnly the 4th point is really true: if you run SSH on a non-standard port but it's otherwise accessible, you'll still see scans on a regular basis. Port knocking isn't a terrible idea but I generally prefer locking down the networks (or, these days, using AWS SSM / GCP IAP to avoid listening publicly at all) since having something on the internet means you're just one mistake away from problems and need to staff monitoring accordingly. The other thing to remember here is that we're talking about one general CVE in two decades. Almost any other running service has been much worse so while SSH is important to protect I don't know that I'd make the argument that further pushing that one service is really the best bang for your buck.
- justinsaccount 6y ago> Only the 4th point is really true: if you run SSH on a non-standard port but it's otherwise accessible, you'll still see scans on a regular basis. Possibly.. It does depend on the port. 222 and 2222 often are scanned with 22. 2200-2299 is probably common now. I was using 2221 for a bit but after a few years that started seeing some auth attempts. I mostly watched entire /16s, not single hosts.. the scan patterns for a large netblock are very interesting. It takes as much effort to scan the entire internet on port 22 as it does to scan all ports on a /16.. attackers simply do not do that. The benefit of some of the port knocking systems is that the attack surface is almost nothing and they are easy to audit. I used it a few jobs ago on my management system/bastion host. I couldn't rely on the VPN since I was the one that managed the VPN, so I needed a way to securely login remotely that did not go through the VPN, and did not end up having sshd exposed to the world. These days I run sshd at home behind https://www.tarsnap.com/spiped.html https://www.tarsnap.com/spiped.html Ubiquitous wireguard may change things.. we'll see.
- wazoox 6y agoI use SSH keys, and disabled passwords. However when I was running SSH on port 22, the number of attempts was slowing my machine to a crawl at times. Moving the port to some obscure random one divided the number of requests from several thousands per hour to a few per day. Definitely an improvement by any measure : suddenly you can analyze the attacks if necessary. I run fail2ban on top of it, because why not? In case someone would attempt to really target my system, any obstacle is good to take. And who knows what ssh vulnerabilities exist; any protection is good to take.
- tptacek 6y agoI love it when people say this. Analyze the attacks... and then what? I'm seriously asking. Block the specific source addresses you know about so far?
- wazoox 6y agoActually fail2ban takes care of that for me. Anyway, the important part was having my home PC not crawling and its disk filled with failed connection logs because of the deluge of bots requests. Avoiding being DDOS'ed, for short.
- ufmace 6y agoI gotta wonder - how in the world can you ever get enough failed SSH login attempts to noticeably affect system performance? I usually have several cloud servers running with a normally secured SSHD running. There's some failed login attempts yeah. I've never seen even 1% CPU usage from them. I doubt even posting my server address on every hacking forum I could find and daring them to try and hack me would result in getting enough failed SSH login attempts to blip my CPU usage. I have no idea how that could even happen, aside from somebody intentionally targeting your server with a really weird attack for whatever reason.
- cataflam 6y ago> There's something to the idea of rehabilitating "obscurity", or at least recognizing that "cost" is part of threat models, and you can raise costs for particular attack vectors by degrees instead of "to infinity". Exactly! Especially when you can create a high cost asymmetry, low-cost for you to add, high cost for the attacker to bypass. Agree that the SSH examples aren't the best. I would have picked DRM.
- saagarjha 6y agoDRM has the problem that it is illegal to bypass, even if your intent is not malicious.
- daneel_w 6y agoThough it would be a tragicomic shame if you got caught by a nasty 0-day while the clown up at port 34015 narrowly escaped and earned enough time to patch before pre-mapped host scans begun.
- yabones 6y agoI think a lot of the people in this comment thread are missing the point when using the `sshd` example. There is no single infallible way to secure ssh, but there are a lot of things that can be done together to make it pretty darn hard to hack, and most of those countermeasures have some degree of 'obscurity' to them. Example: * Use RSA keys instead of passwords -> This will eliminate most risk, except for exploits in sshd itself, * Change the default port from 22 to something in the 40k+ range, which will keep you from being scanned, and * Whitelist IP addresses that can connect to port xx on your server -> This will eliminate 95% of remaining risk * Using a 'clean' bastion server to access other systems via agent-forwarding, preventing malware on admin workstations from being able to propagate over SSH. So, no you're never going to be 100% secure, that's just unreasonable. But like you said, the cost can be increased to the point that all but the most determinted state sponsored APT groups.
- scarmig 6y agoEach security measure has a value and a cost. Keys over passwords provide by far the best value/cost ratio. Using obscure ports or port knocking or whitelisted IPs are relatively clunky mechanisms that are more expensive and obscure your security posture as much to yourself as to adversaries.
- yabones 6y agoThis is absolutely true, but in some ways this is more about reducing the number of 'attempted connections' in the sshd log. Meaning, any failed connection that is recorded (and ideally shipped off to a centralized log system) is in some way actionable. Opening up port 22 (with keys) will still create tonnes of alerts from any SIEM. The other thing to consider is that there could be exploits in OpenSSH itself. There hasn't been a truly critical vulnerability in a very long time, but low severity or non RCE vulnerabilities aren't exactly rare: https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=openssh https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=openssh
- somedude11 6y ago>obscure your security posture as much to yourself as to adversaries Almost barfed from sheer intensity of tech corpobabble. Its for blocking 0-days dummy!
- joelthelion 6y ago> Just use SSH keys, and disable passwords Or even use a good password, if you don't have many untrusted users. It works perfectly.
- rsync 6y ago"But SSH is a terrible example, because the cost to the defender of simply not having SSH vulnerabilities is the same, or even less, than the cost of obfuscating it with nonstandard ports, "port knocking", or fail2ban, which are all silly ideas." I know who I am arguing with here but port knocking is not silly. It's fantastic. When I say fantastic, I don't mean it solves all of our problems and obviates any other protections ... what I mean is, for almost zero cost[1] it adds a non-zero level of actual protection. As a lifelong UNIX sysadmin, it is one of the few totally unalloyed security improvements that I have been able to add to my systems. I believe there are sshd vulns extant that you and I don't know about and port knocking allows me to worry less about them. I also recommend SMS alerts on successful knocks - SMS alerts that you should never see in surprise. This is trivial, by the way, as you can put semicolons in the knock command: /sbin/ipfw add 01021 allow tcp from %IP% to 10.0.0.10 22 setup ; /usr/local/sbin/timestamped_sms 4155551212 "knock from %IP% - " [1] knockd on FreeBSD, 10+ years, not one hang or crash.
- cthalupa 6y agoWhy not just block SSH access from the public internet and use a VPN? Trivially easy to setup and more secure than knocking. All it takes is me somehow being able to listen in on your traffic - not even decrypt it - and now I know the knock sequence. I know that you have SSH listening on that server. I know you are actively doing something on it. vs. a VPN where... all I know is you are communicating over a VPN. With DPI I might be able to determine what type of traffic you're sending, but not where it is ultimately going.
- rsync 6y agoAgain, this is where all port knocking debates devolve to ... Port knocking is not the christ child that will wash away all of our sins ... and therefore is not worth implementing. You're right! It doesn't add that much. But it's non-zero and has almost zero cost. It's very elegant, in my mind, and it makes me very happy.
- cthalupa 6y ago
- Avamander 6y ago> are all silly ideas. Changing the port is not silly, it increases the SNR in logs, that's already a worthy goal.
- ThA0x2 6y ago>But SSH is a terrible example, because the cost to the defender of simply not having SSH vulnerabilities is the same, or even less, than the cost of obfuscating it with nonstandard ports, "port knocking", or fail2ban, which are all silly ideas. This just shows how ignorant you (and most) are on the topic of port knocking. SPA port knocking is cryptographically secure and does not suffer from replay attacks. Similarly, it defends you against 0-day hacks, and greatly increases your signal-to-noise ratio. With port knocking, ANY failed attempt is super suspicious. Before you'd get hundreds of attempts a day.
- dang 6y agoNo personal attacks in HN comments, please. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- cthalupa 6y ago>This just shows how ignorant you (and most) are on the topic of port knocking. You, uh, do know who you're replying to, right? https://sockpuppet.org/me/ https://sockpuppet.org/me/ if not - I don't mention this to go "lol he must be right because of who he is", but calling a well respected security researcher with plenty of real world street cred ignorant is a bit much. >SPA port knocking is cryptographically secure and does not suffer from replay attacks. SPA port knocking doesn't suffer from passive replay attacks, but it does suffer from block and replay attacks. An active MITM can still get you. His suggestion hasn't been "if you care about security just don't do port knocking", his suggestion has been "if you care about security just throw up a VPN it'll be more secure and just as much work"
- ThA0x2 6y ago>You, uh, do know who you're replying to, right? https://sockpuppet.org/me/ https://sockpuppet.org/me/ if not This means nothing to me? I see a shitty website from probably a has-been "security researcher". >I don't mention this to go "lol he must be right because of who he is", but calling a well respected security researcher with plenty of real world street cred ignorant is a bit much. That's sad. Speaks volumes about how meaningless that term has become. >SPA port knocking doesn't suffer from passive replay attacks, but it does suffer from block and replay attacks. An active MITM can still get you. Wrong. SPA does not suffer from any MITM attacks. >His suggestion hasn't been "if you care about security just don't do port knocking", his suggestion has been No one suggests otherwise. >"if you care about security just throw up a VPN it'll be more secure and just as much work" Not the same amount of work, so no, wrong. If I had a dollar for every billion dollar unicorn that that didn't have a corporate VPN, I'd have a lot of dollars.
- AmericanChopper 6y ago> But SSH is a terrible example I’m not sure there is any such good example though. Every obscurity control I’ve ever seen has imposed costs upon the users, administrators, engineers... but I’ve never seen one that I would rely on to improve security posture in any meaningful way. I’ve certainly never seen an obscurity control that was worth its opportunity cost. I can think of dozens of actually useful controls where even a marginal improvement in operational performance would be worth more than every conceivable obscurity control combined.
- speleding 6y agoI agree that changing the SSH port may not be the best example of a low cost measure, since bypassing is also low cost. I would like to see a list of suggestions of "low cost" ways to obscure systems that are (relatively) harder to counteract. But I guess as soon as anyone publishes such a list then hackers will start checking for them.