SSH is supposed to keep attackers out, not let them in. But router vendor MikroT...
Paul Ducklin @pducklin@infosec.exchange
SSH is supposed to keep attackers out, not let them in. But router vendor MikroTik has patched a bug that did just that…
CERT Polska found a bunch of bugs in MikroTik’s SSH server, which seems to be a home-made or home-modded version, rather than a regular build of trusted source code such as OpenSSH. Two of these bugs could be chained together to let anyone in by default, and then promote them to root-level superpowers.
Apparently, the key bug in all of this, if you will pardon the pun, is that if you use RSA cryptographic keys for authentication, the server doesn’t properly verify that the client really possesses the private key it’s supposed to have.
An attacker doesn’t need to break into your laptop first and steal your private key in order then to break into the router… it seems that attackers can concoct their own key *that the server will accept as if it were yours*.
Trusted code such as OpenSSH does have bugs from time to time, but blatant key verification blunders of this sort are unlikely, because trusted core crypto algorithms are generally under continued scrutiny by experts in the community.
Ironically, if you had turned off RSA and switched to Ed25519 (based on Elliptic Curve crypto, not RSA), this bug wouldn’t work, because it’s specific to RSA. Also, Ed25519 has shorter keys, runs faster, especially on modest routers, and is considered much easier to use correctly when writing code that relies on it. Every SSH client supports Ed25519 these days, so there is no need to enable the older, more cumbersome RSA algorithm on SSH servers at all.
Anyway, patch any Mikrotiks you have right away, even if you have RSA turned off or SSH available only on your LAN.
CERT Polska found five other bugs, including the aforementioned “let regular users grab admin superpowers” bug. This sort of bug makes insider threats much worse, for obvious reasons, as well as helping remote attackers who have already broken in.
PS. Please don’t knit your own crypto. It’s harder than it looks to get all the details right.