9 ms·
Trivial authentication bypass in libssh leaves servers wide open
- kevin_b_er 8y agoFrom the reading, the "hack" is pretty embarrassing. The server->client message that announces you're authenticated is instead sent client->server and the server just sets its mode to that. Abracadabra, you're logged in!
- wepple 8y agoThe fix implements a basic state machine to ensure protocol state transitions are sane. Prior to this, attacker-supplied data was used in calculating the offset inside an array of callbacks. So you could just tell the server to call into the “auth success” handler.
- westmeal 8y agoHow on earth did this get past the developer dear god
- zaroth 8y agoThis is the state of libssh. As if it wasn’t already, “many eyeballs theory” is turning over in it’s grave. Contrast this level of insanity to a proposed standard of “developers should be liable for the damage caused by their negligent code”. Just, wow.
- Sir_Cmpwn 8y agolibssh is pretty niche. This isn't openssh.
- kevingadd 8y agoSo "niche" it was used by github, albeit in a configuration that protected them from this
- akvadrako 8y agolibssh is used because openssh isn't suited to be used as a library. So it's one of the most popular ways to automate the most popular remote shell protocol. It's not really niche - I'd say it's an average popularity library and likely used by a bunch of internal projects.
- duskwuff 8y agoThe libssh client code is used pretty commonly for that sort of thing. The libssh server code, on the other hand, is pretty niche.
- throwaway2048 8y agoExcept for github, its unlikely you use any software that uses libssh. Just because it has that name dosen't make it some kind of official SSH library that tons of software uses.
- heavenlyblue 8y ago>> developers should be liable for the damage caused by their negligent code To be fair, at this point I would rather see developers not writing code; rather than writing buggy one. I had a friend on FB who's just completed a security course and wrote a password generator in Go. The random was seeded from a current date in nanoseconds. The issue is that while no one will probably ever reverse his passwords, but the guy open-sourced his script. How many people will be influenced by that piece of code? Lawyers have that: if you can't be liable - you're not a lawyer. GTFO.
- lrvick 8y agoI found that same exact issue in Terraform Go code where it generates passwords for AWS IAM users: https://www.cvedetails.com/cve/CVE-2018-9057/ https://www.cvedetails.com/cve/CVE-2018-9057/ We need to find out who is teaching this stupidity and make them stop.
- informatimago 8y agoEasy: it's implemented in C. While the brain cells of the C programmers are busy handling errors, managing memory, and avoiding buffer overflow, they forget about sound software engineering rules and proper design. While the code of libssh looks cleaner than eg. FreeBSD, there are still quite a number of functions that are bigger than a screen height.
- vbezhenar 8y agoI don't see how different language would protect you from this kind of vulnerability. Array of callbacks looks identical everywhere. Rust or Java would protect from out-of-bounds memory access (and that is a very good thing in that case), but this particular bug would be present.
- XCabbage 8y agoYou're assuming there would even be an array of callbacks if the code had been written in a different language, rather than the other language offering some nicer abstraction that eliminated the array. Having not seen the code, I can't be sure of this, but I know that, for instance, I rarely need to write array index arithmetic in the languages I usually work with (Python, JavaScript) whereas on the occasions I've dabbled with C such arithmetic came up constantly. If I introduced a nasty bug in some C code due to an array arithmetic error, arguing "Python wouldn't be any better because it doesn't do anything to make manually writing array index manipulations easier" would be missing the point.
- vbezhenar 8y agoArray of callbacks (or long switch which is essentially the same) is a standard method to implement state machine.
- kaoD 8y agoAnd that's why you should use a thoroughly tested implementation instead of implementing a bug-ridden ad-hoc square wheel. "Whoopsies, I forgot to ban some state transitions" won't happen if all you're writing is a state machine spec, and not a state machine spec and its ad-hoc implementation. Don't roll your own crypto? Extend it to "don't roll your own low-level constructs".
- ploxiln 8y agoWhat makes this a bit more understandable is: almost nothing uses libssh server functionality. So most development was only focused on client functionality. (The only notable exception, github.com backends, were not using the auth logic code in question, so again just not used and not given attention...)
- bigiain 8y agoSuspicious-me wonders who wrote/committed that code... Is it a "plausibly deniable mistake"?
- wepple 8y agoI guess you could say that about absolutely any bug though? This isn’t particularly underhanded, and it’s more of a broad design flaw than a subtle change. If you wanted a “backdoor” you could absolutely do 10x better than this.
- bigiain 8y agoPretty sure it's not insane to wonder that about any bugs _that give you a remote authentication bypass_...
- wepple 8y agoSure, you can wonder, but when I break it down, it’s either highly unlikely or highly clumsy. If I were to put a backdoor into this code, I’d want the following properties: - tricky to spot in code review - virtually undiscoverable via current best-of-breed fuzzing - tricky to spot in network captures or any type of IDS This bug passes #2 (unless you’ve got a state-aware network fuzzer and panic() in the right places), but fails on the other two. But who knows, maybe this was a low-investment effort and it paid off for some time, with a trivial-to-exploit (IE no mem corruption) bug they knew would eventually be retired?
- lozenge 8y agoHow could you do 10x better? Because it's a broad design flaw there is no suspicious LOC or suspiciously overcomplicated code needed to hide the backdoor. You have to understand the whole context to notice the bug.
- foota 8y agoI mean, a backdoor can just be flipping an if somewhere from && to ||, not exactly suspicious if it's mixed in with other stuff.
- flukus 8y agoThis is the code equivalent of being allowed to wander around in a restricted area because you're carrying a clipboard.
- analogyexpert 8y agoor like the code equivalent of walking up to a locked door, shouting "let him in!" and being let in
- twtw 8y ago> the vulnerability literally works like this: > me: "can i log in?" > server: "no. you need a password." > me: "hacker voice i'm in" > server: "login successful. you're in" https://mobile.twitter.com/FioraAeterna/status/1052294419607506944 https://mobile.twitter.com/FioraAeterna/status/1052294419607...
- Sir_Cmpwn 8y agoNote that libssh != openssh, which is what's probably running on your server.
- stephenr 8y agoI tried to find what it is used in. The site claims that it's used server-side by GitHub: https://www.libssh.org/#text-5 https://www.libssh.org/#text-5
- torstenvl 8y agoGitHub says that the way they're using libssh isn't affected. They apparently use in-house code for the authentication. https://twitter.com/GitHubSecurity/status/1052317333379723265 https://twitter.com/GitHubSecurity/status/105231733337972326...
- throwaway2048 8y ago$ apt-cache rdepends libssh-4 libssh-4 Reverse Depends: libpam-x2go yafc x2goclient tmate remmina-plugin-nx remmina openvas-nasl libopenvas9 libssh-dev cockpit-bridge kio-extras hydra This is all of the packages that depend on libssh in Debian Testing, doesn't seem to be very problematic, I've only heard of one thing on this list, and that doesn't use the server code anyways.
- pronoiac 8y agoDependents in Homebrew: Csync, Hydra, Sshtrix, Yafc. [1] http://brewformulas.org/Libssh http://brewformulas.org/Libssh
- anon49124 8y agoI never heard of this library before. Most projects seem to use libssh2. https://github.com/libssh2/libssh2 https://github.com/libssh2/libssh2
- tedunangst 8y agolibssh2 doesn't have server support.
- netheril96 8y agoWell, if there is libssh2, most likely there is libssh.
- justincormack 8y agoThey are unrelated. I think libssh2 is named that as it implements the v2 ssh protocol.
- writepub 8y agoIs this a code error or a protocol error? If a protocol relies on a message from the client side to allow access, it's a protocol error! It's unlikely that ssh - a protocol that powers large swaths of software, has such an error, but always good to hear from the experts that this is indeed a coding error.
- dbt00 8y agoIt's an incorrect implementation of the protocol, yes. That message should only be sent from the server to the client, and the server should not take any action (besides dropping the connection) when it's received.
- jzwinck 8y ago"GitHub isn’t vulnerable [...] my guess is you’ll be left with a small handful of random sftp servers or IoT devices and little else!” That sounds reassuring. It's not as if hacking some random IoT device is going to win the jackpot. Oh wait, it totally can: https://www.washingtonpost.com/news/innovations/wp/2017/07/21/how-a-fish-tank-helped-hack-a-casino/ https://www.washingtonpost.com/news/innovations/wp/2017/07/2...
- ploxiln 8y agoMost embedded devices which have ssh server functionality use Dropbear. You'll have to look really hard to find anything which uses this "libssh" server functionality (which, again, is _not openssh_).
- makomk 8y agoApparently there was an almost identical vulnerability in the Python SSH library Paramiko too: https://github.com/paramiko/paramiko/issues/1283 https://github.com/paramiko/paramiko/issues/1283
- deleted 8y ago[deleted]
- Nr7 8y agoEarlier discussion: https://news.ycombinator.com/item?id=18236372 https://news.ycombinator.com/item?id=18236372 https://news.ycombinator.com/item?id=18230610 https://news.ycombinator.com/item?id=18230610
- OliverJones 8y agoMove along. This isn't the exploit you're looking for. (Unless your server uses the relatively uncommon libssh on your server. If you use openssl you're not vulnerable. Github's not vulnerable either.)
- stephen82 8y agoWhat a strange coincidence :/ First we had the YouTube outage and a bit later, this issue appeared...