News for hackers. Stuff that matters.
Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @01:00PM (#24444774)
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.

Re:Security by obscurity is underrated by rsync on Friday September 11, 2020 @02:48PM (#24446057)
"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.
Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @06:54PM (#24448161)
It solves none of your problems and adds complexity and cost to your defense without corresponding increases to attacker costs.

If you believe there are unknown OpenSSH attacks, you can't coherently believe that port knocking is a real defense, since port knocking doesn't do anything to protect the SSH channel that attacks will be carried out in.

Instead, if you're actually worried about OpenSSH vulnerabilities, you shouldn't be exposing SSH to the public Internet at all. I'm not super worried about OpenSSH server vulnerabilities, but I would never recommend that teams leave SSH exposed; they should just hide that stuff behind WireGuard.

Re:Security by obscurity is underrated by ThA0x2 on Friday September 11, 2020 @11:49PM (#24449668)
>It solves none of your problems

Wrong, it solves tons of them.

>adds complexity and cost

Almost zero complexity and cost. Maybe if you're a bad at sysadmin work it adds cost and complexity.

>defense without corresponding increases to attacker costs.

It adds a _huge_, almost incalculable cost increase to attackers.

>If you believe there are unknown OpenSSH attacks, you can't coherently believe that port knocking is a real defense, since port knocking doesn't do anything to protect the SSH channel that attacks will be carried out in.

Looks like you don't understand the concept of 0-days. Several CVEs we're listed elsewhere. I suggest researching 0-day exploits so you understand how port knocking mitigates them.

Port knocking mitigates 0-days.

>Instead, if you're actually worried about OpenSSH vulnerabilities, you shouldn't be exposing SSH to the public Internet at all.

I don't disagree here, VPN is a great solution. Nonetheless, for some shops simple port-knocking on a bastion host solves, a lot of these issues, and removed the complexity that VPNs add.

>I'm not super worried about OpenSSH server vulnerabilities, but I would never recommend that teams leave SSH exposed; they should just hide that stuff behind WireGuard.

No one is super worried about things like shellshock, heart bleed, etc. until they happen.

Port knocking solved a lot of problems, protects you from zero-days, and makes SSH noise a non-issue (huge signal-to-noise gains).

Used in production for years. It's fantastic.

Re:Security by obscurity is underrated by tptacek on Saturday September 12, 2020 @01:56AM (#24450201)
Port knocking adds a huge, almost incalculable cost increase to attackers. I'm going to remember that one, thanks!
Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @03:09PM (#24446257)
Why 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.

Re:Security by obscurity is underrated by rsync on Friday September 11, 2020 @03:16PM (#24446323)
Again, 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.

Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @06:56PM (#24448180)
It doesn't add enough to compensate for its costs, which are commensurate with those of VPNs, which provide drastically more return on the investment. But VPNs don't have a cheering section, because they're so obviously useful that nobody has any incentive to make that banal observation. "Port knocking" is idiosyncratic and widely looked down on by security engineering teams, so there's a contrarian impulse that makes them seem worth discussing.
Re:Security by obscurity is underrated by beefarino on Friday September 11, 2020 @07:56PM (#24448600)
I'm struggling to walk away with a crystallized view of why port-knocking is bad, though.

I do agree, nobody should be going to sleep at night, relying solely on obscurity as their source of protection. But these commenters are offering it as an additional layer of indirection. They're not touting it as _the_ solution, full stop.

At the most basic level, would you refute the claim that port knocking or alternate ports are adding additional friction for an attacker, or no?

Myself, I would prefer to run a simple, (hopefully) set-and-forget daemon on my server if it really did add an extra layer of obscurity to my secured SSH service.

I guess I just fail to see why it's one against the other.

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @08:41PM (#24448841)
There's several components to this.

Foremost, there is an opportunity cost to setting it up. The time you spend setting up port knocking could be spent setting up another form of security. I believe it is a sound argument to say that a VPN provides more security at a similar level effort. No public SSH means an attack cannot know SSH is running on the server from a port scan because it simply isn't listening. It allows you to reduce the attack surface - you can add more and more servers that you need to SSH into, but you are only allowing public access via your VPN - so you have fewer potential ingress points, and can ratchet up your security and auditing commensurately. And if your VPN concentrator is owned, you should have been setting things up so that they did not implicitly trust someone just because they were on the VPN, so you still have all of your usual measures of security in place.

In that case, there's just not much point. You could also enable port knocking, but I don't think it provides much benefit.

That brings us to the next part. Port knocking is a "weird" thing. It's idiosyncratic and not standardly used. Documenting it and understanding it is additional overhead, and it's something you have to manage and worry about on every server that's using it. Additionally, both standard and SPA implementations are vulnerable to man in the middle attacks, though most SPA based implementations will require an active MITM in that blocks the initial packet rather than just replaying a knock sequence. So extra complexity, less secure, and an oddity on the network that you have to have documented and explain to new team members, etc.

If you're a single person managing a single server, well, honestly you're probably fine just turning off password auth. And you can feel free to do port knocking and whatever else. It probably doesn't matter.

Re:Security by obscurity is underrated by beefarino on Friday September 11, 2020 @09:57PM (#24449209)
Thanks, I appreciate the thoughtful response.

It sounds like port knocking and VPNs, while starkly different in approach, have some overlap in their approach to threat mitigation.

Wireguard et al are much better equipped to handle the needs of an organization, while port knocking's value trends to smaller teams, or even individuals.

I wouldn't want to manage knock rotations for 600 employees, for example.

Re:Security by obscurity is underrated by Quiark on Friday September 11, 2020 @08:01PM (#24448629)
A tangent: are VPNs other than WireGuard less likely to have vulns compared to SSH? Seems the same to me (or worse for OpenVPN a few years ago)
Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @09:02PM (#24448942)
You're asking for my opinion, and that's all I can relate, but here's my ranked ordering of things likely to have RCE vulnerabilities, from least to most secure:

* A Java, Python, or Ruby app server

* OpenVPN

* Stock nginx

    ----- starts to get really unlikely right here ----
* OpenSSH

* The Linux IP stack

* WireGuard

Re:Security by obscurity is underrated by wglb on Friday September 11, 2020 @08:15PM (#24448700)
One crude first-order comparison is to look at the relative size of the code. More code is more likely to have more vulnerabilities, to a first-order BOEC metric.
Re:Security by obscurity is underrated by rsync on Saturday September 12, 2020 @03:42AM (#24450683)
""Port knocking" is idiosyncratic and widely looked down on by security engineering teams"

I can't comment on that.

I'm not a UNIX sysadmin because it's a rewarding career path with excellent opportunities for advancement.

I'm a UNIX sysadmin because I truly love doing it and always have. I would do it for free.

Re:Security by obscurity is underrated by tptacek on Saturday September 12, 2020 @08:39AM (#24451966)
That's why I do software security!
Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @03:31PM (#24446450)
I guess my point is largely: I can set up a VPN in a roughly similar timeframe to setting up port knocking, and it has roughly similar overhead for end user, but the VPN gives me significantly more security while also solving the same issue port knocking does. In that case, why not just set up a VPN instead of port knocking?
Re:Security by obscurity is underrated by rsync on Friday September 11, 2020 @04:34PM (#24447061)
I will again agree with you that the VPN is a more robust and more complete protection. You are correct.

I think the reason I continue to prefer (and evangelize) port knocking is that the intersection of (modest) security gain and simplicity/robustness hits a sweet spot for me.

Again, 10+ years in production on many hosts, worldwide, and never so much as a blip. IF knockd were to fail, it would fail in a very boring way. VPNs, on the other hand, are far more complex and they fail in fascinating ways.

I am a sysop turned sysadmin - this is my lifes work. I prefer simple, unixy tools that fail in boring ways :)

Re:Security by obscurity is underrated by Kalium on Saturday September 12, 2020 @12:17PM (#24453512)
Not to be That Guy, but what I'm reading is that you have the wonderful opportunity before you to learn about VPNs until they fail in boring ways!
Re:Security by obscurity is underrated by rsync on Saturday September 12, 2020 @09:35PM (#24457459)
That's not how that works.

Simple systems tend to fail in boring ways. Complex systems tend to fail in interesting ways. Learning more about a complex system, while rewarding in many ways, will not change that identity.

Re:Security by obscurity is underrated by Kalium on Sunday September 13, 2020 @04:44PM (#24463822)
It's been my experience that a system's complexity (basic or complex) is less an intrinsic trait and more a matter of subjective perception, familiarity, and experience. Your experience is clearly different.
Re:Security by obscurity is underrated by foxtrottbravo on Friday September 11, 2020 @08:18PM (#24448720)
My daily bread and butter is VPNs, but I must admit that I think there may be a truth here.

While I fully agree that portknocking doesn’t provide the same layer of protection or flexibility a VPN does - but with the original article in mind: if your reason for deploying a VPN is because you fear to expose unknown bugs in sshd to the Internet the same could be said about every vpn solution.

Therefore portknocking is / (would be*) indeed more elegant because

- it makes no promises to be secure (as in as secure as a VPN) - one could argue: if you use it you know that portknocking is just an additional security layer - and maybe don’t get lazy as in a VPN - a misconfiguration or bug or an attacker might expose sshd on your hosts - a misconfigured VPN at least in a somewhat sizeable deployment can lead to countless attack surfaces

Having said that, that only will work if the rest of the sshd security is in check and your password isn’t hunter2

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @08:59PM (#24448928)
I think get where you're coming from here, but I don't fully agree.

>f your reason for deploying a VPN is because you fear to expose unknown bugs in sshd to the Internet the same could be said about every vpn solution.

Yeah. You might have a VPN zero day - but then you still have to get into the other SSH servers. Two zero days simultaneously active for openssh and your VPN solution? Pretty unlikely, especially public ones. Someone burning two private zero days on you means you're an incredibly high value target and neither of these would suffice as your sole defense to begin with.

The rest of your argument, if I'm understanding it correctly, is that you think people will get more lax with securing SSH on a box only reachable via VPN than if it was reachable by port knocking? It's possible, but I don't know that the evidence really shows that - lots of comments on this article are along the lines of "i set up port knocking and I've never even seen a malicious ssh connection attempt since then!" - no details of the rest of the security measures they've got in place.

And yeah, going from 'I set up a VPN to connect to my web servers via ssh' to 'I have VPN access to a whole network with all sorts of things running on it' is a big step up, but I don't think it's really in the boundaries of this discussion. Port knocking was never going to be a replacement for a larger VPN deployment, and when you're opening up network access to a wider range of things then how you approach things definitely needs to change.

Re:Security by obscurity is underrated by foxtrottbravo on Friday September 11, 2020 @09:43PM (#24449152)
First of all I agree with you, that we should compare solutions in a comparable manner and I went overboard.

So yes, if we want to be fair we have to compare an in-host defense system like portknocking (which has one job: secure sshd) to a in-host vpn setup more alike to like the often mentioned wireguard.

And in this "configuration" I completely agree. I still think it may be more likely for a VPN to expose security critical bugs than a bug in knockd - but as you said this should only allow access to your next layer of defense (namely sshd) and maybe (if you're a really valuable target) a three-letter-agency might throw all their resources at you and are willing to throw every weaponized exploit they have at you - yeah than you're even more correct because than they would have a far easier time just intercepting your port knock sequence and throwing all their quantum computation power against your sshd keys.

> The rest of your argument, if I'm understanding it correctly, is that you think people will get more lax with securing SSH on a box only reachable via VPN

The argument I was trying to make is that while a VPN is in in every way a really good idea (the way we described it here - as an in-host security layer) but I have yet to see it being rolled out in that way.

I come from a more traditional sysadmin setting, and of most sysadmins I worked with would find implementing this "correctly" to tedious and would either

a) terminate the vpn connection at the rack or co-location "border" and shove a bunch of servers down a single VPN connection b) terminating every servers vpn connection at a single vpn concentration point

Regardless of which, in virtually all cases that I know of never was there any thought given about intra-VPN firewall rules or allowing only certain ports on the VPN. Most of the time you get the servers that are somewhat related, shove them in a subnet expose that subnet via VPN and you're golden.

And so from my practical experience, I would think that a compromised VPN in my reality would be worse than a exploited knockd, but only because it isn't scoped to the same level.

On a sidenote: I'll guess that modern orchestration tools make it pretty easy to roll out knockd and / or wireguard pretty easily in the discussed fashion - it's just I don't get to play with those.

That was a lot of text, just to say I agree with you - but hey, I guess agreeing on something on the internet is somewhat nice so have a great day.

Re:Security by obscurity is underrated by justinsaccount on Friday September 11, 2020 @04:30PM (#24447017)
Which vpn though?

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=openvpn

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=pulse+secur...

VPN doesn't magically fix all problems.

wireguard is good so far, but the kernel implementation is in C, so who knows.

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @04:39PM (#24447108)
No, a VPN isn't magic in and of itself. And yes, I would suggest wireguard for the simplicity and performance these days.

I do agree with the author of the original article that security should come in layers

Once something is secured with SSH and a VPN, you've got that many more actual layers - you now need a CVE that allows access or credential leak for both the VPN and SSH. (And many of those CVEs don't necessarily allow a random attacker to arbitrarily gain access)

https://news.ycombinator.com/item?id=24446919 has my list of what the bare minimum SSH protections should be for anything where you are storing customer/user data in my opinion, as well as additional best practices that I have employed.

Re:Security by obscurity is underrated by justinsaccount on Friday September 11, 2020 @04:33PM (#24447052)
Like you said.. "worry less"

Can a theoretical attacker intercept a port knocking sequence? maybe. Would a script kiddie running a new ssh 0day against the entire internet be able to do this? no.

Re:Security by obscurity is underrated by viraptor on Friday September 11, 2020 @06:38PM (#24448058)
> almost zero cost

If it's your private pet server - sure. In larger networks you have to document the access, manage the allowed ports on the network, configure security groups or equivalent on instances, provide alternative steps for people with unusual clients (for example database UI app proxying over SSH), etc. The cost suddenly becomes very non-trivial.

Re:Security by obscurity is underrated by crazygringo on Friday September 11, 2020 @05:04PM (#24447307)
> 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.

That's interesting, that's the first time I've heard a justification for port knocking that actually makes sense to me.

I'm curious for others' thoughts here -- are non-public vulnerabilities something you consciously try to mitigate? So that, for example, using 2 different 8-character passwords that are implemented with different technologies, is therefore fundamentally more secure than a single 16-character password? Precisely so that a vulnerability in one is still protected by the other?

To me this feels like it's really only applicable if you need to protect your data from hostile governments targeting you specifically, who might actually have zero-days they have weaponized.

However, if you're just trying to protect yourself from everyday hackers or even targeted corporate espionage, is unknown vulnerabilities really something that's realistically worth protecting oneself from? (Assuming you're always installing all security patches.)

Re:Security by obscurity is underrated by CobrastanJorji on Friday September 11, 2020 @08:09PM (#24448677)
I agree. I think this comes down to the Mickens Security Threat Model. Your adversaries come in basically two forms: Mossad and Not-Mossad. If your adversary is Mossad, you've already lost; if a governmental actor wants your data badly enough, they'll get it. If your adversary is not-Mossad, they almost certainly don't have access to any secret zero-day exploits; stay up to date on patches and use good passwords and you'll be fine. Port knocking will almost certainly protect you from not-Mossad, assuming your adversary doesn't know that you're using it.

Sure, a small percentage of adversaries are in neither category, and a random hacker dedicated to hitting your specific server may suspect port knocking and could try to circumvent it, but most companies don't have an adversary like that, and even if they do, you've made it harder for them for a small cost.

Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @09:19PM (#24449028)
I love that article, but this comment beautifully illustrates the problem with it, because unless you believe "19 year old with better-than-normal tooling" counts as "Mossad", it has totally screwed up your perception of the threat model.
Re:Security by obscurity is underrated by aschatten on Saturday September 12, 2020 @07:14AM (#24451594)
I understand how port knocking can throw off nmap and reduce brute force traffic.

Does it solve anything else?

> 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.

Wouldn't you need to worry about vulnerabilities in knockd?

Re:Security by obscurity is underrated by trishankdatadog on Friday September 11, 2020 @03:45PM (#24446577)
Agreed: adding port-knocking and fail2ban in addition to passwordless should not be and are not silly ideas.
Re:Security by obscurity is underrated by justinsaccount on Friday September 11, 2020 @01:20PM (#24445009)
> 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.

Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @06:48PM (#24448119)
I think the fact that you had to list the 20-year-old SSH CRC compensator vulnerability to establish the untrustworthiness of SSH is telling; very few pieces of software have OpenSSH's current track record. I would cite the same 2 vulnerabilities to suggest that SSH is as trustworthy as almost any other piece of software you can run.

Having said that: I don't like exposing SSH services either! Which is why I try to keep them behind WireGuard, at least on prod networks that I care about.

In contrast to an actual VPN, port-knocking and (heh) nonstandard SSH ports shield you only from casual attackers; both give a middlebox attacker all the access they need to launch the attack.

Re:Security by obscurity is underrated by acdha on Friday September 11, 2020 @01:29PM (#24445135)
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.

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.

Re:Security by obscurity is underrated by justinsaccount on Friday September 11, 2020 @01:57PM (#24445444)
> 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

Ubiquitous wireguard may change things.. we'll see.

Re:Security by obscurity is underrated by BlueTemplar on Saturday September 12, 2020 @10:14AM (#24452606)
What about entire /56s ? (Home user on IPv6.)
Re:Security by obscurity is underrated by pera on Friday September 11, 2020 @04:41PM (#24447125)
> you'll still see scans on a regular basis.

Not in my experience, I would even say that full range port scanning is extremely rare. Botnets (again, in my experience) seem to only be interested in vanilla installations and will test standard ports exclusively. But of course, if you are in charge of some very tempting target (eg a cryptocurrency exchange) your experience will be totally different than mine.

Re:Security by obscurity is underrated by Sebb767 on Friday September 11, 2020 @02:35PM (#24445900)
> * The boxes using port knocking would be safe.

No, safer. It is very well possible to brute-force port knocking or eavesdropping the ports since that information is not encrypted. Is it harder? Of course, a lot, but if you think scanning 65k ports on each host on the internet is reasonable, then evading a port knock is very much, too.

Re:Security by obscurity is underrated by GordonS on Friday September 11, 2020 @04:33PM (#24447046)
> It is very well possible to brute-force port knocking

It's incredibly unlikely - there is probably more chance of the sun imploding tomorrow. And if you're the type to install port knocking, you've almost certainly also installed something like LFD, which will temporarily block IPs for port scanning.

Also, without inside information, how would you even know that a server was using port knocking?

> unlike

Re:Security by obscurity is underrated by justinsaccount on Friday September 11, 2020 @02:55PM (#24446115)
eavesdropping, maybe. There are tools like https://github.com/mrash/fwknop that are not vulnerable to that or brute-forcing.

But brute forcing in general? not a chance. There are 18446744073709551616 4 port sequences.

Re:Security by obscurity is underrated by Sebb767 on Friday September 11, 2020 @03:11PM (#24446282)
And there are roughly 1267650600228229401496703205376 port 22's in the IPv6 space - I've substracted a few for reserved and unassigned spaces, but at this scale a few orders of magnitude hardly matter.

Here, for comparison:

  281474976710656 - total ports in IPv4 space
  18446744073709551616 - 4 port combinations
  1267650600228229401496703205376 - my estimation for 22 in IPv6
And if you don't block the knocking when receiving traffic on another port, brute forcing gets quite a bit easier. I mean, it's still unreasonable. But my point is, when we accept 0,001% chance as possible, I don't think we can say that 0,000001% is impossible - just a lot less possible ;)
Re:Security by obscurity is underrated by josalhor on Friday September 11, 2020 @05:49PM (#24447704)
18446744073709551616 is 65 bits. Let’s simplify, you're trying to guess a number in 2^64 You can’t guess in parallel. Reasonable constraints on the server side (i.e. limit tries on the combination/per hour before suspending ssh for a while) may have been implemented.

I’d say cracking that is… Unfeasible.

That also assumes you know the existence of a server on which there is ssh under an unknown combination of port knocking of length 4.

Re:Security by obscurity is underrated by gridlockd on Friday September 11, 2020 @04:11PM (#24446834)
The actual chances for guessing the 4 port combination are closer to 0.000000000000000000001%, about as likely as winning the lottery three times in a row. If you're trying to brute-force me with those odds, I'll take my chances.
Re:Security by obscurity is underrated by px43 on Friday September 11, 2020 @07:03PM (#24448243)
There is a vastly higher chance of there being exploitable bugs in port knocking tooling than there is of there being exploitable bugs in SSH. You are adding extra exposure and gaining nothing.
Re:Security by obscurity is underrated by wazoox on Friday September 11, 2020 @01:27PM (#24445107)
I 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.

Re:Security by obscurity is underrated by ufmace on Saturday September 12, 2020 @11:25AM (#24453171)
I 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.

Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @09:28PM (#24449075)
I 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?
Re:Security by obscurity is underrated by wazoox on Saturday September 12, 2020 @05:58AM (#24451260)
Actually 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.
Re:Security by obscurity is underrated by meowface on Friday September 11, 2020 @01:14PM (#24444936)
It'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.)

Re:Security by obscurity is underrated by yabones on Friday September 11, 2020 @02:15PM (#24445657)
I 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.

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @03:16PM (#24446326)
>* Change the default port from 22 to something in the 40k+ range, which will keep you from being scanned, and

I'm replying to these suggestions all over this item because I think it's important, so I apologize if you've since seen this comment elsewhere, but:

This introduces new security risks. Non-privileged users can bind on ports in the 40k+ range and cannot bind on 22. If you restart sshd for a software upgrade or some other reason, or the iptables rules you're using to remap the ports get flushed, the malicious non-privileged user can now bind to the port people were communicating with your sshd on, and if they ignore the host key mismatch, everything they send can be captured by the malicious user.

Older openssh clients have default configurations that can result in the leak of the whole private key, if you use password auth or 2FA they can outright steal those, perhaps their fake sshd will do more than just steal credentials and will actually mimic a shell and let them gain more understanding of how the system ticks, etc.

Is this level of attack something most people are going to run into? No. But neither is an attack more sophisticated than brute force password attempts. It's definitely information people should be keeping in mind when making these sorts of decisions, too.

Re:Security by obscurity is underrated by magicalhippo on Friday September 11, 2020 @05:58PM (#24447779)
> This introduces new security risks. Non-privileged users can bind on ports in the 40k+ range and cannot bind on 22.

My firewall does port mapping so externally it's not 22, but internally it is.

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @06:31PM (#24448015)
This is significantly better than just changing the port the daemon listens on, for sure.

There's still public access to SSH, so you're still at risk from a zero day, weak credentials, etc., so I don't think it's quite to ideal levels where you are employing a VPN, disallowing all public access, etc., but at least you're not introducing new potential attack vectors :)

Re:Security by obscurity is underrated by magicalhippo on Friday September 11, 2020 @06:34PM (#24448038)
What about VPN makes the VPN server software more secure than the SSH server software?
Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @06:50PM (#24448135)
The level of security is cumulative. You do not trust a connection just because it's connected to the VPN. So if your VPN concentrator is compromised via 0day, the only access they get is the same as if things were listening on the public internet.

To gain access to the server via SSH they now need both a way in to the VPN and a way in to SSH, vs. just needing a way in via SSH.

It doesn't do much if someone just gives up the keys for the VPN and SSH, but it would mean that you would need two simultaneous exploits for the VPN and SSH to gain access.

Re:Security by obscurity is underrated by magicalhippo on Friday September 11, 2020 @06:54PM (#24448163)
Yeah but if they compromise the VPN they potentially have access to a lot more than just the SSH server. At least in the setups I've seen deployed.
Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @07:13PM (#24448310)
I'm not sure I necessarily understand your argument, so my apologies if I'm off here.

In scenario 1, you do not gate access via VPN. Things are accessible via the public internet.

In scenario 2, you do gate access via VPN. Things are not accessible via the public internet. Someone compromises the VPN. They now have as much access as if there was no VPN and things were accessible to the public internet.

In scenario 2, you are more secure than in scenario 1 until the VPN is compromised. You are then just as secure as you were in scenario 1.

If you are not restricting access to a VPN in the first place, how would compromising a theoretical VPN result in greater access?

Re:Security by obscurity is underrated by magicalhippo on Friday September 11, 2020 @08:18PM (#24448722)
In the setups I've seen, once you've connected through VPN you're essentially on the LAN. If you compromise the SSH server, then you're also essentially on the LAN. Yes with the VPN you still have to compromise the server running the SSH service if that's the machine you want access to, but inside the LAN you now have a much greater attack surface.

Of course if the setup is VPN -> firewall -> SSH to make sure only the SSH is exposed through VPN, then I agree you'd be more secure with VPN+SSH.

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @08:45PM (#24448869)
But without the VPN, you're already the equivalent of on the LAN because all of these services are exposed to the public internet.

In the discussion we're having, we're going from a setup where there is no equivalent to a private network because everything is public, to having a private network that only allows you access to the things that were previously public.

Re:Security by obscurity is underrated by magicalhippo on Friday September 11, 2020 @09:01PM (#24448940)
No because I have a firewall in front of the SSH, as mentioned. I would assume a firewall is in front of the VPN as well of course.

So either only SSH is exposed to the public, or only VPN is exposed. Without an additional firewall after the VPN, how is my LAN more protected with the VPN vs SSH?

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @09:24PM (#24449051)
Your goal is to protect SSH, not the VPN network. The VPN network is just a tool for protecting SSH.

With your configuration, all that needs to exist is an SSH 0 day to gain access to the server. With a VPN, they need that AND a 0 day for the VPN software to gain access to the server.

You can have a more complex setup with a VPN, but that isn't the discussion here - the discussion is securing SSH. If you want to provide VPN access to an array of other services, or as access to a corporate LAN or similar, then that's another conversation that has to involve the specifics of those services and that configuration. It's not what is being recommended here.

Re:Security by obscurity is underrated by magicalhippo on Saturday September 12, 2020 @04:29AM (#24450888)
Fair enough, guess I was restricting my view to my bubble. For a single server sure defense in depth should work, assuming you're not running the VPN on the same box.
Re:Security by obscurity is underrated by pabs3 on Friday September 11, 2020 @11:15PM (#24449523)
I'd suggest using jump hosts (-J or ProxyJump) rather than agent forwarding to a bastion host. IIRC the latter gives the bastion host access to your keys.
Re:Security by obscurity is underrated by scarmig on Friday September 11, 2020 @02:36PM (#24445909)
Each 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.
Re:Security by obscurity is underrated by yabones on Friday September 11, 2020 @03:32PM (#24446462)
This 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

Re:Security by obscurity is underrated by somedude11 on Friday September 11, 2020 @05:31PM (#24447533)
>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!

Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @06:50PM (#24448133)
Neither changing the SSH port nor using IP source address filters constitute serious countermeasures; they complicate systems and offer little return on the investment. Don't bother. If you're worried enough to change the SSH configuration, set up WireGuard.
Re:Security by obscurity is underrated by p49k on Friday September 11, 2020 @01:15PM (#24444954)
Heartbleed 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.
Re:Security by obscurity is underrated by jjeaff on Friday September 11, 2020 @01:28PM (#24445122)
I 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.
Re:Security by obscurity is underrated by p49k on Friday September 11, 2020 @01:43PM (#24445287)
With 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
Re:Security by obscurity is underrated by yjftsjthsd-h on Friday September 11, 2020 @01:59PM (#24445468)
And 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.
Re:Security by obscurity is underrated by boredpenguin on Friday September 11, 2020 @04:50PM (#24447201)
> 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.

Re:Security by obscurity is underrated by daneel_w on Friday September 11, 2020 @01:39PM (#24445239)
Though 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.
[dead]
Re:Security by obscurity is underrated by tptacek on Friday September 11, 2020 @06:50PM (#24448139)
No, it's not, and it won't.
Re:Security by obscurity is underrated by xioxox on Friday September 11, 2020 @01:14PM (#24444941)
One 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.
Re:Security by obscurity is underrated by AmericanChopper on Saturday September 12, 2020 @03:13AM (#24450541)
> 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.

Re:Security by obscurity is underrated by cataflam on Friday September 11, 2020 @01:38PM (#24445232)
> 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.

Re:Security by obscurity is underrated by saagarjha on Friday September 11, 2020 @01:59PM (#24445465)
DRM has the problem that it is illegal to bypass, even if your intent is not malicious.
Re:Security by obscurity is underrated by speleding on Saturday September 12, 2020 @09:35AM (#24452306)
I 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.

Re:Security by obscurity is underrated by joelthelion on Friday September 11, 2020 @02:38PM (#24445935)
> Just use SSH keys, and disable passwords

Or even use a good password, if you don't have many untrusted users. It works perfectly.

Re:Security by obscurity is underrated by Avamander on Friday September 11, 2020 @03:14PM (#24446301)
> are all silly ideas.

Changing the port is not silly, it increases the SNR in logs, that's already a worthy goal.

[dead]
Re:Security by obscurity is underrated by dang on Friday September 11, 2020 @07:37PM (#24448481)
No personal attacks in HN comments, please.

https://news.ycombinator.com/newsguidelines.html

Re:Security by obscurity is underrated by cthalupa on Friday September 11, 2020 @08:51PM (#24448894)
>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/ 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"

[dead]
Re:Security by obscurity is underrated by cthalupa on Saturday September 12, 2020 @01:51AM (#24450178)
>Wrong. SPA does not suffer from any MITM attacks.

Care to elaborate? Not even fwknop documentation claims to be secure from all mitm attacks:

>Automatic resolution of external IP address via cipherdyne.org/cgi-bin/myip (this is useful when the fwknop client is run from behind a NAT device). Because the external IP address is encrypted within each SPA packet in this mode, Man-in-the-Middle (MITM) attacks where an inline device intercepts an SPA packet and only forwards it from a different IP in an effort to gain access are thwarted.

If I'm MITM'ing you from the same Starbucks or am otherwise behind the same NAT as you, I don't care if you've got the IP encrypted in the packet when I forward it on.

>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.

There's not enough billion dollar unicorns out there to actually have a lot of dollars, even if 100% of them lacked corporate VPNs :D

Regardless, you don't even need a full on corporate VPN. You can throw up a tiny VM for your VPN in the same private subnet as your servers, only listen on 22 on the private IPs for the servers. You can do this in less than an hour with Wireguard. Super easy.

Re:Security by obscurity is underrated by BlueTemplar on Saturday September 12, 2020 @10:25AM (#24452686)
How does this work on IPv6 ?
Re:Security by obscurity is underrated by tha0x4 on Sunday September 13, 2020 @02:19AM (#24458813)
>Care to elaborate? Not even fwknop documentation claims to be secure from all mitm attacks:

You made the claim. You prove it with documentation.

>If I'm MITM'ing you from the same Starbucks or am otherwise behind the same NAT as you, I don't care if you've got the IP encrypted in the packet when I forward it on.

That is by definition NOT a MITM attack.

>There's not enough billion dollar unicorns out there to actually have a lot of dollars, even if 100% of them lacked corporate VPNs :D

The example is only billion dollar ones. If I include +$10m+ ones, I'd have enough to dollars to buy a new laptop ;D!

>Regardless, you don't even need a full on corporate VPN. You can throw up a tiny VM for your VPN in the same private subnet as your servers, only listen on 22 on the private IPs for the servers. You can do this in less than an hour with Wireguard. Super easy.

You just described a bastion host, and port knocking makes sense on those as well LOL. Wireguard only currently supports UDP, which can and had been a limitation in the past.

Re:Security by obscurity is underrated by cthalupa on Sunday September 13, 2020 @03:23AM (#24459076)
>You made the claim. You prove it with documentation.

I... er, did?

>That is by definition NOT a MITM attack.

You're intercepting the packet and blocking it by being in the path.

>You just described a bastion host, and port knocking makes sense on those as well LOL. Wireguard only currently supports UDP, which can and had been a limitation in the past.

Bastion hosts are generally SSH/RDP/VNC type affairs. SSH in to the bastion and then you have access to the other servers. This is actually how I set things up in production environments - the VPN concentrator only allows access to the jumphosts, and then there's extensive logging and auditing there.

I'm not sure why Wireguard only supporting UDP would be a problem - you can pass whatever type of traffic inside of the tunnel.

Re:Security by obscurity is underrated by tha0x4 on Sunday September 13, 2020 @04:22AM (#24459341)
>I... er, did?

You... Ugh... Didn't? You claimed that it suffers from MITM attack. You are not able to prove that it suffers from any MITM attack (the docs specifically outline a way to mitigate a specific MITM attack, but do not outline any others). Unless you have a source that states otherwise, you're wrong.

>You're intercepting the packet and blocking it by being in the path.

Wrong, that is by definition not a MITM attack.

>Bastion hosts are generally SSH/RDP/VNC type affairs. SSH in to the bastion and then you have access to the other servers.

Correct, and you set up port knocking for these. Thanks for proving my point.

>This is actually how I set things up in production environments - the VPN concentrator only allows access to the jumphosts, and then there's extensive logging and auditing there.

There should be extensive logging and auditing on the bastion host. Port knocking reduces the noise to effectively 0.

>I'm not sure why Wireguard only supporting UDP would be a problem - you can pass whatever type of traffic inside of the tunnel.

There have been multiple instances where UDP has been block at sites in the past. Looks like you're ignorant to this. Look up why OpenVPN supports TCP.

Re:Security by obscurity is underrated by MiroF on Friday September 11, 2020 @01:05PM (#24444828)
The cost of not having SSH vulnerabilities is infinite because there is no way to ensure that.