[00:00.000 --> 00:05.100] Hey guys, uh, so we're gonna talk about SSH. And this has been probably the most exciting [00:05.100 --> 00:12.200] year in SSH since x2.cd got leaked, x2.cd got leaked by Teso. So, um, uh, props to anyone who [00:12.200 --> 00:17.340] used that. Uh, so, uh, SSH for folks who aren't aware, um, you probably, probably should be [00:17.340 --> 00:21.140] here if you don't know what SSH is, but, um, SSH, secure shell, port 22, the thing we've [00:21.140 --> 00:25.440] been using to admin the internet for many years, like almost 30 years. Um, there's really [00:25.440 --> 00:29.900] two flavors of SSH that we use the most. There's open SSH, which is like 80 something [00:29.900 --> 00:33.880] percent of all SSH installations. And then there's DropBear, which is like another like [00:33.880 --> 00:38.120] five to eight percent. And then this long tail of random weird stuff out there. So we [00:38.120 --> 00:42.360] decided to do some research into first looking into the XC backdoor. And then part of that, [00:42.360 --> 00:46.640] we just accidentally found a couple tens of thousands of shells and we're like, well, let's [00:46.640 --> 00:49.840] go figure out what all these random things, all these free shells were. Uh, and that led [00:49.840 --> 00:53.480] to this giant pile of work and this open source tool. Um, so if you want to play with the [00:53.480 --> 00:58.520] toolkit, you can get it right now. It's this, the shamble.com S S H A M B L E. And that [00:58.520 --> 01:01.640] goes to GitHub and you can go grab the stuff and play with it. And it's a big hot mess, but [01:01.640 --> 01:05.100] we're making it better. And it should be a lot of fun as we start cranking on, make polishing [01:05.100 --> 01:10.940] up, making it cool. Um, so with that, we'll go ahead and get started. Um, fortunately, we're [01:10.940 --> 01:16.960] only doing 67 slides in 45 minutes, not 100. So we had a little breathing room this time. Um, [01:16.960 --> 01:20.800] so I'm sure we're all very much aware of the XCUTLs backdoor. Well, step back a little bit. [01:20.800 --> 01:24.100] So there's, you know, four major events this year in SSH that were really important. [01:24.100 --> 01:29.600] Obviously, XCUTLs backdoor targeted SSH using the system vpatches and Debian and, uh, Red Hat [01:29.600 --> 01:34.700] builds of OpenSH. We also had the really cool Terrapin vulnerability, which affected pretty [01:34.700 --> 01:39.040] much everything because of the truncation attack. Um, we also had, uh, the regression [01:39.040 --> 01:42.960] vulnerabilities, the really fantastic work by the Qualys Threat Research Unit. Um, and then [01:42.960 --> 01:47.220] the other regression bug found by SolarDesigner that only affected Red Hat. And regression [01:47.220 --> 01:52.180] was amazing. It's a signal re-entrance bug that gets you remote route in OpenSH by default. [01:52.180 --> 01:57.140] It just takes six hours on a 32-bit machine or weeks or months on a 64-bit to compromise. So, [01:57.140 --> 02:00.880] but it's been a really cool year. Um, one of my favorite SSH bugs this year kind of flew under [02:00.880 --> 02:05.120] the radar. Um, the guys at Watchtower Labs did a really cool analysis of the move-it [02:05.120 --> 02:09.540] vulnerability that uses the SFTP server. And so they found a vulnerability where any public [02:09.540 --> 02:13.440] key being sent to the service, um, would be treated like a file path. Like the binary [02:13.440 --> 02:16.800] blog gets treated like a file path. And it just opened random UNC URLs and all kinds of fun [02:16.800 --> 02:20.080] stuff. They threaded like a million little needles to be able to get a shell remotely and [02:20.080 --> 02:23.680] boot it. But the really cool thing about that bug is it affected every other vendor also using [02:23.680 --> 02:28.300] IPWorks as the underlying library. So, they actually uncovered like a supply chain bug, if [02:28.300 --> 02:33.100] you will, which is really neat. So, going kind of back on topic again, um, the XEUtils [02:33.100 --> 02:38.980] vulnerability or backdoor was amazing. It was like its own little Netflix docu-series, right? [02:38.980 --> 02:43.720] We're going to see like the true crime of XEUtils for years. But like who is Gia Chan? Like [02:43.720 --> 02:47.600] it's going to, it's the most dramatic thing to happen to InfoSec in a very long time. Um, so [02:47.600 --> 02:51.300] the, this is a multi-year campaign where this person, um, contributed to open source for a long [02:51.300 --> 02:55.540] time, then eventually kind of twisted the knife and tried to backdoor the world. And I got [02:55.540 --> 02:59.900] caught at the very last minute by, uh, Anders Frond, who says, hey, my SSH is taking slightly [02:59.900 --> 03:03.380] too much longer than it should, and then unraveled the whole thing right before it got put [03:03.380 --> 03:07.580] into the stable distributions. So, we got really close to the whole internet being backdoored. [03:07.740 --> 03:11.320] Uh, but what was really important about that backdoor that it was a nobody but us backdoor, [03:11.320 --> 03:14.540] which is normally, you know, normally the US government is famous for those. But in this [03:14.540 --> 03:18.840] case, who knows who it was. Um, in fact, it was a encryption key controlled by the attacker [03:18.840 --> 03:22.780] that only people with a private key had access could abuse the backdoor. That was really a [03:22.780 --> 03:27.200] neat thing about it. So, we thought it'd be fun to go figure out who this Gia Chan person [03:27.200 --> 03:30.200] was. And we're like, hey, you know, everyone's looking for Gia Chan, we're going to go find [03:30.200 --> 03:34.940] some Gia Chan. Uh, and we're very happy, Alfredo, if you're out here, thank you so much for [03:34.940 --> 03:40.460] designing your graphics, they're amazing. Um, so we decided to go hunting. And, you know, [03:40.460 --> 03:43.880] before we go hunting for Gia specifically, we want to talk a little bit about SH protocol. [03:43.880 --> 03:49.860] So, uh, Gia Chan targeted SH, uh, with ex- with ex-utils backdoor. So, we're going to target [03:49.860 --> 03:55.700] Gia Chan using SH. But before we go there, we need to talk about how SH public key [03:55.700 --> 03:59.680] authentication works. So, SH public key authentication is two-stage. The first thing you do [03:59.680 --> 04:03.540] is say, hey server, would you accept this public key for this username on your machine? And [04:03.540 --> 04:07.320] it says, yeah, sure. And then you have to sign this big blob of data that proves that you [04:07.320 --> 04:10.940] have the private key. But you can do that first part without the private key at all. And it's [04:10.940 --> 04:14.480] really cool. There's been a module in Metasploit 4 since 2012, lets you take someone else's [04:14.480 --> 04:17.500] public key that you got, however you got, and then check a bunch of servers to see whether [04:17.500 --> 04:21.160] that public key has access to, uh, those servers for that username. So, you can kind of see [04:21.160 --> 04:25.040] where this is going. Um, it's, there's this great comment on OpenSH saying, is this a [04:25.040 --> 04:27.760] problem? I don't know. But it's been there forever. It's just kind of the protocol spec at [04:27.760 --> 04:31.400] this point. It is what it is. Maybe it's not a big security deal. So, we decided to create [04:31.400 --> 04:35.100] this thing called Shamble, which started off being a half-off scanner for SH. So, what we [04:35.100 --> 04:38.640] do is you take a bunch of public keys and then you'd like put them in Shamble and scan the [04:38.640 --> 04:43.240] whole internet saying, what on the internet can you access using these public keys? And the [04:43.240 --> 04:47.440] idea is like, well, if we had, let's say, Gia Tan's public key, we can find all the servers [04:47.440 --> 04:50.260] that they use and then from there we figure out who they are. So, that was, that was the [04:50.260 --> 04:54.620] idea. But it ended up evolving to this massive tool to find all kinds of other crap because of [04:54.620 --> 04:58.340] all the things that we found. So, you know, first thing you do say is, hey, my name's Gia Tan, [04:58.340 --> 05:01.460] we're gonna go download your GitHub keys. So, we grabbed our two GitHub keys, which are [05:01.460 --> 05:06.440] still present today, um, and basically took those two public keys, ran them into Shamble, [05:06.440 --> 05:10.040] and then, um, you know, threw that at the whole internet, all the, all the sh-demons we [05:10.040 --> 05:14.360] could find, let it grind out for a couple days. And what's, what's exciting about it is, [05:14.360 --> 05:16.960] like, we spent the whole week on this, we hadn't slept or anything like that, Rob and I were [05:16.960 --> 05:20.520] like working at four in the morning, like, we got one! We got a hit for Gia! It's really [05:20.520 --> 05:24.620] exciting. Um, in the meantime, we're melting all of our DigitalOcean nodes. So, this is this [05:24.620 --> 05:28.340] poor little DO droplet just like falling apart as we're like destroying it. It's, I think it's [05:28.340 --> 05:33.520] sent like a terabyte of traffic at this point. Like, we're, yeah, we made DO VMs very unhappy. [05:34.160 --> 05:39.320] Um, so, just heads up for law enforcement, um, we sent the public key for GiaTAN to every [05:39.320 --> 05:43.800] server on the internet from RIPs. We are not GiaTAN, we are not backdoor exe-utils, even [05:43.800 --> 05:47.720] though it very much looks like we did. So we sort of accidentally framed ourselves. Uh, we [05:47.720 --> 05:52.020] realized that after the fact that we probably might, I'm sure the long-arm law will catch up [05:52.020 --> 05:55.520] at some point, like, you guys, you're GiaTAN, like, ten years from now, and like, yeah, we [05:55.520 --> 06:00.680] are not, sorry. So, um, unfortunately, like, every single result we found that we thought was [06:00.680 --> 06:05.000] false positive. It was like a buggy server with, like, the memory was corrupted, or the service [06:05.000 --> 06:09.000] would accept every fifth public key, or every third public key. So we had to say, okay, let's [06:09.000 --> 06:12.780] try a bunch of random public keys, and if you reject all those, now try the Gia key. And let's [06:12.780 --> 06:17.800] try, like, an RSA key, RSA 1024, 2048. We've still found devices that just randomly accept or [06:17.800 --> 06:21.260] randomly not accept keys, and it just drove us crazy. So we finally fixed all these bugs, [06:21.260 --> 06:25.800] re-scanned, re-scanned, re-scanned, uh, you know, clicked all those digital ocean abuse [06:25.800 --> 06:29.740] notices, says, yeah, we're good, our server's not compromised, we're cool. Um, and we still [06:29.740 --> 06:33.460] found no Gia 10. So, whoever this, you know, actor was, they had really good OPSEC, we found [06:33.460 --> 06:37.660] nothing, so good job them. Um, but we did find, like, thousands of free shells. So, we're [06:37.660 --> 06:40.500] like, how come we're getting all these random shells and all these random machines? And that's [06:40.500 --> 06:46.020] really what this talk is, is about. Uh, so with that, um, a little bit of a detour. So, an [06:46.020 --> 06:50.040] SH, um, public keys used to not be something that you actually made public. They used to be [06:50.040 --> 06:52.920] something you kind of kept privately, and you were .SH directly, and you copied to a server [06:52.920 --> 06:57.880] here and there. But, um, in the last five or six years, we've seen people using, uh, SH keys [06:57.880 --> 07:02.200] like identities. So, just like people used PGP back in the day, you can now use SH keys as your [07:02.200 --> 07:05.020] identity when you're installing a bunch of server. You can tell it to grab your key from [07:05.020 --> 07:08.340] GitHub or from Launchpad and automatically give you access to your server during installation [07:08.340 --> 07:14.660] by username. Um, you can also, uh, um, use these keys for things like, uh, OJ encryption. So, [07:14.660 --> 07:18.380] if you use the OJ tool or H tool, you can use it almost like a PGP key now these days as [07:18.380 --> 07:21.880] well. So, it's all kinds of cool stuff you can do with, uh, SH keys you didn't before. But the [07:21.880 --> 07:24.860] key thing here is, like, keys are effectively public if you use any of these major [07:24.860 --> 07:28.900] platforms. And literally public. So, there's this great little, uh, daemon by Filippo where [07:28.900 --> 07:32.780] if you SSH into it, it'll say who you are. It'll use the public key you send to the server, [07:32.780 --> 07:36.460] dock to you based on the GitHub database and say, oh, you're so and so, welcome. So, it's [07:36.460 --> 07:39.700] kind of a fun little trick. And effectively, we're doing that, but at scale for the whole [07:39.700 --> 07:43.800] internet. So, if you want to link a user to a particular key on a particular server, you need, [07:43.800 --> 07:47.700] um, one, a list of all the SH servers out there. So, ZMap, Mascan, dump it, show it in, [07:47.700 --> 07:50.400] whatever you want to do to get the list. You want a list of all the public keys, so you go [07:50.400 --> 07:54.200] grind all those out of GitHub through their BigQuery API, about 117 million users as of [07:54.200 --> 07:57.560] about a month ago. Launchpad's got a bunch of users, too. You get all their keys, too. Why [07:57.560 --> 08:02.180] not? And then Bad Keys is a great project by, uh, Hanno Bach, um, that allows you to, that [08:02.180 --> 08:04.860] keeps track of all the compromised keys out there. So, you can look for keys that give you [08:04.860 --> 08:08.540] access to the system. And then lastly, you need a list of common usernames the user might [08:08.540 --> 08:12.380] have, like root, ec2 user for cloud, Ubuntu, et cetera, or whatever the comment is in the [08:12.380 --> 08:15.980] key. So, one of the nice things about GitHub is that when you upload your public key to [08:15.980 --> 08:19.400] there, they actually preserve the comment field, which is typically your, your username [08:19.400 --> 08:22.160] when you uploaded the key. So, you know what their default username is. So, if you're [08:22.160 --> 08:24.840] trying to find, like, their server someplace, you can pull it out the comment, use that to [08:24.840 --> 08:28.200] talk to the user, and so on. So, you, you take this nice little recipe and you throw it in [08:28.200 --> 08:33.460] the oven. And, um, it gives you a nice little primitive to take a one key and check lots of [08:33.460 --> 08:36.260] servers really fast. Like, you can grind through all the servers on the internet in, like, an [08:36.260 --> 08:40.160] hour or something like that on a single box. It's pretty quickly. Just for one key. Um, but [08:40.160 --> 08:43.220] if you want to test, um, so that works great if you're looking for, like, a geotan everywhere. [08:43.240 --> 08:47.100] But what if you want to say, for this server on the internet that's acting fishy, which [08:47.100 --> 08:51.220] GitHub user has access to it and do the other way, to check all 117 million keys on one [08:51.220 --> 08:54.620] server. Well, that's a very different attack. That's like, you know, duck-sized horse or [08:54.620 --> 08:58.500] horse-sized ducks, you know, kind of approach. So if we want to test a million keys against, [08:58.500 --> 09:02.800] uh, a single server, it's a little bit tougher because, uh, SH will slow you down. Uh, they [09:02.800 --> 09:06.160] have, uh, this thing called max auth limit, which is how many tries you can authenticate [09:06.160 --> 09:09.220] before it kicks you off of that connection. And there's a max connection limit, so you can [09:09.220 --> 09:12.820] only do so many of those at once, right? So the idea is that with OpenSH, if you try to [09:12.820 --> 09:16.440] brute force keys, you get four into it and it knocks you out and you can't auth anymore. So [09:16.440 --> 09:19.700] if you ever had more than four keys in your SH, uh, agent, and you try to shell out a [09:19.700 --> 09:22.700] machine and it just immediately says, you know, too many tries, that's why. It's because [09:22.700 --> 09:27.840] you're hitting the max auth limit of OpenSH. However, um, OpenSH is the only one that does [09:27.840 --> 09:31.640] that. Everything else lets you just bang keys all day long. So DropBear lets you just [09:31.640 --> 09:35.540] grind keys as fast as that little device can, can test them. Um, also a lot of commercial [09:35.540 --> 09:39.180] products like Bitbuys, GlobalScape, Maverick, LanCom, all this stuff, all their SH daemons [09:39.180 --> 09:42.260] do not care. They'll let you just try every possible key in the world until, until you're [09:42.260 --> 09:45.220] done. It's great. Uh, we emailed the DropBear folks, they didn't care, they didn't even [09:45.220 --> 09:48.400] bother replying, so we're like, it's not really a bug, it's a feature. So, we like that [09:48.400 --> 09:53.160] feature. So, uh, with the shamble code you mentioned before, we tested the GitHub, like [09:53.160 --> 09:57.660] 4.6 million key database at the time, and you can do about 10,000 keys per second on a [09:57.660 --> 10:01.500] DropBear box on an embedded node without it spiking the CPU on the target device at all. It [10:01.500 --> 10:04.880] just doesn't even care. It's like super fast. So it doesn't even murder the machine. And [10:04.880 --> 10:08.800] this is 10,000 keys per second per connection, and DropBear is typically configured with 15 [10:08.800 --> 10:13.700] connections. So you can do 150,000 keys per second on a machine for pub key testing to [10:13.700 --> 10:16.660] dock someone's server. So if you see someone like hitting you on a random box and SH is [10:16.660 --> 10:19.760] open, just go take all the keys and get it. I'd be like, yeah, you jerk, stop that. And [10:19.760 --> 10:24.020] just email him, like quit it. Like, it's really, really easy to dock to your hackers. And if [10:24.020 --> 10:27.800] you're running an SH honeypot and your SH honeypot collects the public key being sent to [10:27.800 --> 10:30.440] you, you can turn around and flip that on them again and immediately figure out who they [10:30.440 --> 10:34.280] are. Like, people forget all the time that their SH agent's configured and they're sending [10:34.280 --> 10:37.180] their public key to every server they connect to. Even if their agent is not authenticating [10:37.180 --> 10:40.320] to it, they're still automatically sending that public key as a task whenever you touch [10:40.320 --> 10:44.240] anything. So if you're a, a lead hacker and you've been just SHing at random machines on [10:44.240 --> 10:47.400] the internet, you're also sending your public key identity to all those machines and if [10:47.400 --> 10:52.740] they're logging at your host. So, um, by contrast, if you try the same attack against open [10:52.740 --> 10:56.980] SH, you can do 132 keys per second. So it'll take you 10 hours to do the same 4.8 million [10:56.980 --> 11:02.100] keys with a single connection. So, um, obviously the open SH approach is much nicer, um, but [11:02.100 --> 11:05.900] it's great if you're trying to, um, adapt, docks people. So, uh, with that, I'll hand it to [11:05.900 --> 11:13.940] Rob to talk about shaking out shells. Testing, testing, testing. Testing, testing. Hey, [11:13.940 --> 11:21.060] all right. So shaking out shells, say that five times fast. Um, what we did with shamble is it [11:21.060 --> 11:27.820] resulted in, uh, around 27 million devices on the public internet that are listening on port [11:27.820 --> 11:33.900] 22. We got another, you know, 14 million or so that actually negotiated, uh, SSH off and we [11:33.900 --> 11:40.620] ended up with about 110,000 sessions. Um, what's really interesting about SSH, so SSH, uh, [11:40.620 --> 11:49.940] especially open SSH has done an immense amount of work in, do what? Oh, sorry, front mics are [11:49.940 --> 11:58.320] hot. Uh, so, sorry. So, uh, we ended up with, um, about 110,000, uh, that are actually [11:58.320 --> 12:03.080] listening and we were able to get sessions. What's fascinating about open SSH is, or SSH, is [12:03.080 --> 12:08.880] that there's a fairly large post-authentication attack surface. So SSH does lots of things. [12:08.880 --> 12:12.580] You can create tunnels, you, uh, can create pseudo-terminals, there's subsystems, there's all [12:12.580 --> 12:18.580] sorts of things that are running on, uh, SSH once you're inside. Uh, it kind of assumes that [12:18.580 --> 12:22.400] once you've authenticated, you're okay, but there's an immense, uh, an immense amount of [12:22.400 --> 12:29.920] systems out there that actually will do this interesting post-auth-auth. So you authenticate, [12:29.920 --> 12:34.980] uh, non-authentication with left beef and you get in and then it actually gives you a [12:34.980 --> 12:38.480] secondary authentication mechanism. It'll prompt you for a username and then a password, but [12:38.480 --> 12:42.500] you're inside the session at that point. So you can start doing some interesting things. This is [12:42.500 --> 12:47.620] one of the, the interesting cool things that, that Shamble will do. Um, you can say, oh, okay, [12:47.620 --> 12:52.960] uh, I can send signals, I can send, uh, SIGWINCH, I can, uh, forward X11, things like that. [12:53.340 --> 12:59.200] And you can see there's a fair amount of large, uh, devices, uh, popular devices out there [12:59.760 --> 13:06.100] that do this post-auth-auth. So you can see you've got, uh, SonicWall firewalls, um, Juniper [13:06.100 --> 13:10.120] network devices, you can SSH in with auth none, and then it'll give you the secondary one. [13:10.120 --> 13:14.160] That, uh, that smaller one, the please login, that's, uh, a ruckus one that HD's gonna talk [13:14.160 --> 13:19.080] about here in a minute. That's super, uh, super fascinating. But it's worth noting that there [13:19.080 --> 13:26.880] is this post-auth attack surface that is kind of not considered, but is exposed. So, uh, and [13:26.880 --> 13:30.300] with that, with sort of the first one that you can talk about is signal injection. I'm gonna [13:30.300 --> 13:33.600] pass it back to HD for that. Did we get the second mic working? [13:34.360 --> 13:37.140] Cool, thank you. Sorry, just trying to stay away from the front mic so we don't get feedback [13:37.140 --> 13:42.380] here. Um, so, uh, Rob mentioned that one of the things you can do to a post-auth session is, [13:42.380 --> 13:47.000] uh, inject signals into the process before you've fully authenticated. So if actually you [13:47.000 --> 13:51.700] can connect to a machine, it'll pass through the authentication from SH auth equal none, and [13:51.700 --> 13:55.440] then drop you to a real login shell, and it'll say, please login. And you can just say, signal [13:55.440 --> 13:59.800] seg v, and it goes, ah, and dies. Which is a lot of fun. So effectively you can just, you know, [13:59.800 --> 14:02.860] we talk about regression being signal re-entrance, this is just signal entrance. You just [14:02.860 --> 14:05.620] bang signals all day long into whatever process you want and see what terrible things fall [14:05.620 --> 14:09.940] back out of it. So, uh, we didn't get too far into this testing, but we, there's all kinds of [14:09.940 --> 14:12.900] fun things that come out of it. You can send a SIGINT request, you can pass Python scripts [14:12.900 --> 14:16.920] that are part of the login shell to crash, uh, you can do SIG alarms, SIG childs, SIG ills, [14:16.920 --> 14:20.060] SIG aborts, you can pass core dumps, uh, all kinds of crazy stuff you can just do with [14:20.060 --> 14:24.720] signals. And OpenSH tries to protect you a little bit by limiting things like sig seg v, [14:24.720 --> 14:28.160] sig abort, and so on, uh, but DropBear does not. DropBear is like, anything that you can [14:28.160 --> 14:31.440] possibly send me, I'll treat as a signal and deliver to the process, thank you. Um, so [14:31.440 --> 14:33.620] there's a lot of really cool attacks that we think you can do there, and we're gonna start [14:33.620 --> 14:37.520] working on expanding the shamble code to then basically just mash symbols into random [14:37.520 --> 14:41.180] processes so you get a shell. And, yeah, um, with that, hand it back to Rob to talk about [14:41.180 --> 14:47.100] TSP forwarding. I, I do always love that, uh, DropBear is like, I, you know, it's like if it [14:47.100 --> 14:50.020] were dying, it wouldn't be dictating, right? It wouldn't be writing it out, it would just [14:50.020 --> 14:56.340] say IEE, but no. Um, but another part of this post-auth, uh, uh, attack surface is [14:56.340 --> 15:02.100] forwarding, right? So SSH allows you to generate or create tunnels, uh, you know, through [15:02.100 --> 15:05.820] channels and create encrypted tunnels. It's almost like a little miniature VPN thing, and [15:05.820 --> 15:10.120] this is a pretty popular and common, uh, feature. But once you po-, once you're in this [15:10.120 --> 15:13.360] post-auth situation, you can start doing that. You can start creating these things on a lot [15:13.360 --> 15:18.020] of these systems. Um, many of them will administratively restrict you from doing it or [15:18.020 --> 15:23.460] they'll only let you go to certain things, but for example, uh, uh, you can say, okay, well [15:23.460 --> 15:27.640] I'm gonna try to forward to this particular host, or I'm gonna try to forward to a local host [15:27.640 --> 15:32.460] and do a loopback, um, and we actually found, uh, this is an ION, yeah, okay, good, the [15:32.460 --> 15:37.640] chip's playing, uh, this is, uh, an ION network's access point, and you can see that it's [15:37.640 --> 15:45.800] trying to, uh, forward to google.com, and it, it gets rejected, and then it's gonna try, oh, and [15:45.800 --> 15:50.360] by the way, this is the shambles shell, uh, which I love. Um, and it'd say, oh, I'm gonna [15:50.360 --> 15:55.340] try to get to 88888, but then you can actually forward back to local host, so you can actually [15:55.340 --> 16:00.340] use that to get around restrictions and things like that once you're in this sort of, uh, uh, [16:00.340 --> 16:07.460] mystery, uh, uh, post-auth shell. But, the big, the big one is shell injection, I'm gonna let [16:07.460 --> 16:11.820] you take this one, cause this is super cool. So one thing that was kind of fun about this is [16:11.820 --> 16:15.340] that we found bugs that, like, we shouldn't have found. Like, because of this post-auth [16:15.340 --> 16:19.420] sequence, effectively you SH to the machine, and instead of asking for a password, you just, [16:19.420 --> 16:22.320] it drops you straight in, but it drops you straight into a secondary shell. And that [16:22.320 --> 16:25.460] secondary shell has its own bugs. So we kept finding these vulnerabilities in these [16:25.460 --> 16:28.940] secondary shells that no one had found before, even though they were, like, stupid. Like, [16:28.940 --> 16:32.960] we found so many dumb bugs just because no one really tested that level of the protocol. So [16:32.960 --> 16:38.500] in this case, um, we're right across these, like, ruckus access points, and you SH them, [16:38.500 --> 16:41.880] there's about 36,000 of these suckers exposed to the internet, about 900 are vulnerable to [16:41.880 --> 16:46.360] this particular attack, still right now, today, and it asks you for a username, you type [16:46.360 --> 16:49.200] in root, you type in, you start entering your password, and for your password, you just type [16:49.200 --> 16:52.060] in, like, dollar, parenthesis, whatever command you want to run, right? And just redirect it [16:52.060 --> 16:55.200] back out to standard error so you can see the result, and it just runs this root, pre-auth, [16:55.200 --> 16:59.220] it's great. Um, so we'll, we reached out to ruckus, of course, like, hey, what's up? Like, [16:59.220 --> 17:02.900] you guys, is this a new bug? Is this a fixed bug? We can't really tell what's patched. Like, [17:02.900 --> 17:06.060] oh yeah, we patched that already. I'm like, did you tell anyone? Nope, they didn't tell [17:06.060 --> 17:09.100] anyone. There's no CV, no security note whatsoever. So of course no one's applying [17:09.100 --> 17:12.480] patches because they didn't know they had to apply a patch. Um, so they've got two [17:12.480 --> 17:16.080] different tracks, the 521 and the 621, those both fix it, but there's, you know, still [17:16.080 --> 17:19.340] about, you know, almost a thousand folks out there still running unpatched up. But the [17:19.340 --> 17:21.940] question was, like, why did this bug live so long? How did we end up with this, like, [17:22.080 --> 17:26.220] a stupid login prompt, like, password character injection, and it's because it was behind [17:26.220 --> 17:29.840] this SSH auth layer that no one really bothered to test it. Like, all your folks who normally [17:29.840 --> 17:34.240] hit a telnet prompt, something like that, just hadn't tried this SSH post auth attack. [17:34.240 --> 17:37.100] So we uncovered this whole, like, layer of bugs that really should have been found 20 [17:37.100 --> 17:41.420] years ago, but they were just hiding behind this extra SSH layer. Uh, and that's one of [17:41.420 --> 17:44.720] the interesting kind of side effects of this work. So here's an example of us, uh, rooting [17:44.720 --> 17:49.360] one of these random ruckus boxes. SSH in with all the, I don't care about my cipher stuff, [17:49.360 --> 17:55.000] please log in, R-O-O-O-O-T, and then for the password, we're just typing in $PSAOX-W and [17:55.000 --> 17:59.140] getting a big process listing. And the funny thing about it is you can actually see the echo [17:59.140 --> 18:03.160] command in the PS listing showing that it's going to shop 256 sum, that's how they check [18:03.160 --> 18:06.420] your password. So they fixed it just by putting in proper quotes, but the whole thing is [18:06.420 --> 18:09.860] ridiculous. So it's amazing, like, how many dumb bugs are out there if you just go a little [18:09.860 --> 18:13.680] bit further into the protocol stack. And back to Rob for the permit. [18:15.500 --> 18:20.180] So SSH, you know, is the secure shell, it's designed to talk as your shell, it replaces [18:20.180 --> 18:25.380] Telnet and RSH and all that, and it lets you set environment variables. Um, environment [18:25.380 --> 18:29.280] variables are used to control the execution of things and, you know, keep track of the [18:29.280 --> 18:34.120] environment and all that. And a lot of, uh, SSH implementations will limit what you can [18:34.120 --> 18:39.800] send, but a lot won't. Um, there's been a, uh, and it's configurable, of course, some will, [18:39.800 --> 18:43.020] uh, accept these environment variables, some don't accept these. So there's been this [18:43.980 --> 18:48.900] renaissance in, uh, Gitforges lately, there's a ton, there's, there's GITI, there's GOGS, [18:48.900 --> 18:52.900] there's, uh, I always pronounce this wrong, FORGEHO, tell me if I'm saying that right, [18:52.900 --> 18:58.180] GARET, things like that. And they are using these embedded SSH libraries that speak the [18:58.180 --> 19:01.520] SSH protocol, and these libraries, because they're, you know, designed for general use, [19:01.520 --> 19:05.800] they will accept, you know, any environment variable you send, and they rely on the client, [19:05.800 --> 19:13.280] the user of the library, to, uh, limit what is going on. Um, and so that's generally okay, [19:13.280 --> 19:17.620] like a lot of them do it correctly, uh, for example, GitLab, GITI, FORGEHO, they will [19:17.620 --> 19:22.560] only accept Git protocol as, uh, an environment variable, and that's, uh, something that's [19:22.560 --> 19:25.960] looked at by Git to negotiate protocol versions, so you can say, oh, I want to use Git protocol [19:25.960 --> 19:29.760] version 2 or whatever. But, for example, there's still some vulnerabilities there, if you were [19:29.760 --> 19:33.480] using a version of one of these, these are all written in Go, and it was compiled using [19:33.600 --> 19:39.300] a version of Go prior to 1.19.3, which is a year or two old, um, on Windows systems, [19:39.300 --> 19:42.880] they don't properly sanitize the, uh, the value of the environment variable, so if you [19:42.880 --> 19:45.860] put a null in there, you can actually just inject arbitrary environment variables, which [19:45.860 --> 19:52.980] is, uh, super fun. But, um, there was another one that was really interesting in, uh, GOGS, [19:52.980 --> 19:57.420] where whenever it gets an environment variable, it actually runs the env command, and so the [19:57.420 --> 20:02.060] point of the env command is to start a new process, um, with a new environment, with, [20:02.060 --> 20:06.760] you know, setting certain environment variables or whatever. And it starts a new process, [20:06.760 --> 20:12.280] it doesn't affect the environment that you're in, right? It, it, that's not how POSIX works. [20:12.360 --> 20:17.220] So you could just say, okay, well, I want to set an environment variable with, you know, [20:17.220 --> 20:24.000] dash, dash S A equals B, and then, you know, bash, or, you know, touch temp foo, or whatever, [20:24.000 --> 20:28.320] and you are just executing arbitrary commands. And we, we did reach out, there's, there's [20:28.320 --> 20:34.520] no patch for this, uh, it's, seems moribund, so maybe don't use it. Um. [20:34.680 --> 20:39.600] This is a great example of, like, parallel discovery, so, not in, not in the court sense, [20:39.600 --> 20:44.100] but in the, uh, we reported this vulnerability on, like, April 24th, and Sonar Research had [20:44.100 --> 20:47.880] reported the same bug to the same maintainer on the 22nd, and they scooped us on the advisory, [20:47.880 --> 20:50.900] and we both had our own separate GitHub advisories, but it's just hilarious that we both [20:50.900 --> 20:54.040] managed to look at the same bug at the same time, so, it's funny, like, how often that [20:54.040 --> 20:57.280] happens, and this is a great example. So props to the Sonar source folks for beating us by [20:57.280 --> 21:00.980] two days, uh, and they did a really great blog post about how the bug works, but it, [21:00.980 --> 21:03.600] it almost looks like a backdoor, because it doesn't actually influence the environment [21:03.600 --> 21:08.160] of the subprocess, it's just a straight command exec pre-auth, so it's a, it's a funky bug. [21:08.180 --> 21:08.740] Yeah. [21:09.060 --> 21:14.380] Yeah, exactly, thank you, HG. Um, so going back to these, uh, these libraries, so, for [21:14.380 --> 21:19.140] example, uh, Apache Nino, which is a Java, uh, implementation of SSH, will accept any [21:19.140 --> 21:24.820] variable you want, um, and most of the time, uh, it doesn't really run into anything, but [21:24.820 --> 21:29.280] this is, this is maybe my whole, this is maybe my favorite thing that we found, uh, personally. [21:29.420 --> 21:34.260] Uh, so there's this piece of software called SoftServe, and it's designed to build, um, [21:34.260 --> 21:39.540] Git repos, and it gives you this beautiful, uh, SSH, or, you know, CLI, you SSH in, you [21:39.540 --> 21:44.920] control it, you can do whatever, and it uses, um, the Charm Bracelet SSH, uh, library, which [21:44.920 --> 21:49.960] is built on top of Go's SSH, um, and it will accept any environment variable, or it did, [21:49.960 --> 21:55.600] we reported it, they fixed it, this is our CVE, Go us, um, but what's fun is you can, first [21:55.600 --> 22:01.640] off, watch how slow I am when I'm typing in, uh, in GIF form, but, um, you can, uh, we just [22:01.640 --> 22:06.480] basically created some shellcode, and we checked it into LFS, and you can actually do this in [22:06.480 --> 22:10.600] lots of different ways, LFS just, uh, Git LFS is large file storage, it, it just makes it [22:10.600 --> 22:13.720] to where it's not compressed, and, uh, the file name is predictable, so we don't have to [22:13.720 --> 22:19.820] worry about it too much, uh, makes it easier to exploit, we push it up to, uh, to SoftServe, [22:19.820 --> 22:25.140] and then, uh, doing the SHA 256 sum of our shellcode, because that gives us the, uh, the [22:25.140 --> 22:29.300] file name that we can, you know, guess, and then we just set LD preload to our shellcode, and [22:30.400 --> 22:35.600] we now have, you know, shell on that system. So, that was super fun, uh, I, I always love [22:35.600 --> 22:39.120] when I get a shell, and I'm just like, oh, this is great, you know, uh, so that made me [22:39.120 --> 22:42.940] really happy, and these, uh, these folks were really super cool to work with, um, we, uh, [22:42.940 --> 22:48.400] we disclosed that, they were very, very nice. Um, but now moving on to, uh, Broken States, [22:48.400 --> 22:52.020] which is the SSH state machine to HD. [22:52.040 --> 22:56.320] Thanks, um, another fun thing about the, the SoftServe side, so that particular exploit, um, [22:56.320 --> 22:59.920] because it's using git LFS, you can, you can reference a raw file on disk, and you don't have [22:59.920 --> 23:03.400] to know your file location, you can use relative paths and stuff, but this works just fine for [23:03.400 --> 23:07.060] unauthenticated git access too, so if you're running SoftServe for read-only access, you can [23:07.060 --> 23:10.040] still exploit it, it just requires jumping through more hoops, because you can specify LD [23:10.040 --> 23:14.160] preload, LD load library, you can set LD library debug out in the past, there's a million ways [23:14.160 --> 23:18.020] you can, like, eventually get a file onto disk to then load, or to trigger a shell script, but [23:18.020 --> 23:21.840] just LFS was the quickest way, but like, yes, we're loading arbitrary code, so, it, write access [23:21.840 --> 23:25.300] to the repo is not a requirement to exploit SoftServe, and there's still about ten of those [23:25.300 --> 23:28.360] suckers hanging out on the internet right now that are exploitable, so, if you're quick, they're [23:28.360 --> 23:34.200] yours, um, kidding, but, um, so, I'll talk a little bit about the SSH state engine. So, SSH is [23:34.200 --> 23:37.500] like, incredibly complicated in terms of how it makes you go through these different states to [23:37.500 --> 23:40.520] get to each phase of the protocol. The stuff you're mostly familiar with is like, when you [23:40.520 --> 23:45.540] first connect to the port 22, you'll see like, SSH-2.0, uh, server banner, things like that. [23:45.540 --> 23:48.600] If you happen to send the same manner back to it, or you connect to dropper, then you'll get [23:48.600 --> 23:52.100] this big blob of stuff with null delimited strings, which have like, ciphers, and max, and [23:52.100 --> 23:56.180] algorithms, things like that inside of it. So, all that's kind of during the, uh, server version [23:56.180 --> 24:00.460] exchange, and the key exchange, um, the SSH daemons are very clear that they will only accept [24:00.580 --> 24:05.100] a certain range of message values for each state. So, before you've done the, uh, version [24:05.100 --> 24:07.940] exchange, you can't do the key exchange, before you do the key exchange, you can't do [24:07.940 --> 24:12.460] authentication exchange, and this is enforced two ways. The protocol itself has a range of [24:12.460 --> 24:17.340] values allowed for each state. So, values 1 through 49 are allowed in state 1, 0 to 49 in [24:17.340 --> 24:20.880] state 2, and so on. So, if you're trying to like, just open a channel, or open a shell, [24:20.880 --> 24:23.580] technically there's no even message handler for it, because it hasn't even configured the [24:23.580 --> 24:26.960] state handler to even accept that type of message yet. But that depends very much on the [24:26.960 --> 24:30.860] implementation. Uh, DropBear and OpenSH are really good at keeping a big command table, [24:30.860 --> 24:34.520] and when they go to another state, they just remove that command table handler for the [24:34.520 --> 24:37.240] previous state. So, there's really no way to like, accidentally call the wrong function [24:37.240 --> 24:41.600] pointer. Um, and that mostly works the way you expect. What's also interesting here is [24:41.600 --> 24:45.840] everything after the key exchange, of course, is encrypted. So, SH is kind of like TLS in a lot [24:45.840 --> 24:49.080] of ways, in that you have your normal, like, version exchange, key exchange, algorithm, [24:49.080 --> 24:52.060] Diffie-Hellman type thing, and then you have, like, your encrypted transport, and that's [24:52.060 --> 24:55.260] where all the fun stuff happens, like authentication, your banner, if you will. Like, [24:55.260 --> 24:57.920] have you ever seen a pre-auth banner in SH? It's actually being sent over the encrypted [24:57.920 --> 25:01.140] connection, not over the unauth connection. So, typically when you're talking about an [25:01.140 --> 25:03.820] SH banner, you're not talking about the version string, you're talking about the pre-auth [25:03.820 --> 25:07.340] big blob of data that it sends you when you try to authenticate. Um, so lots of cool stuff [25:07.340 --> 25:10.900] happening there, but you can see the state engine is pretty complicated. Um, what's also [25:10.900 --> 25:14.200] worth pointing out here is there's something called a larval session. So, that means you've [25:14.200 --> 25:19.000] successfully authenticated, or maybe not, and it's the state of your shell before there's a [25:19.000 --> 25:22.000] shell. So, effectively, if you haven't created a sub-process yet, you're in this kind of, [25:22.000 --> 25:25.240] like, larval state, and that's how the code generally references it. And that's important [25:25.240 --> 25:29.260] when we start getting into some of these other exploits. So, a historic example of where [25:29.260 --> 25:33.800] this has gone wrong is libsh. In 2018, uh, someone reported vulnerability where this [25:33.800 --> 25:36.960] library is used for both client and server side, same with OpenSH, same with DropBear, [25:36.960 --> 25:40.400] they kind of share the same code base for both halves of the protocol. Um, and if you sent [25:40.400 --> 25:43.760] the user-authenticated succeeded message from the client to the server, the server's like, [25:43.760 --> 25:47.080] oh, okay, cool, you're in, and that's fine. Um, there's still a bunch of these libsh [25:47.080 --> 25:50.320] informations out there that'll just drop you to a shell if you send user auth success, and [25:50.320 --> 25:54.620] of course, you know, shamble test for that and makes it easy for you to use it. Um, so we [25:54.620 --> 25:58.140] decided to take this up another level. Instead of just saying, let's just send a fake [25:58.140 --> 26:02.200] success message, let's just try to get a shell everywhere. Let's take every single part of [26:02.200 --> 26:05.700] the protocol transition and say, let's do half auth, let's do full auth, let's do a fake [26:05.700 --> 26:09.860] pubkey, let's do a password, let's do a password none, let's do, even before sh user auth [26:09.860 --> 26:12.920] command at all, and between every one of those attempts, we're going to ask you for a [26:12.920 --> 26:15.240] shell. We're just going to be like, how about a shell now? How about a shell now? How [26:15.320 --> 26:18.600] about a shell now? And how about now? Um, and it worked. Like, we got crap loads of [26:18.600 --> 26:22.100] shells from random devices because we asked them in weird states to give us a shell. So [26:22.100 --> 26:25.200] there's some out there where you don't even bother even starting the authentication [26:25.200 --> 26:27.520] process and it gives you a shell. There's some out there where you start the [26:27.520 --> 26:30.000] authentication process but don't finish, it gives you a shell. Like, it's all over the [26:30.000 --> 26:34.640] map. So, um, there's three good examples we talk about here. The first one is the digi [26:34.640 --> 26:37.500] transport, uh, gateways. They're mostly using like ICS environments, they're kind of [26:37.500 --> 26:40.800] like out in the field with hardened stuff. They act as like kind of the VPN router, if you [26:40.800 --> 26:45.900] will, for all the, all the juicy OT stuff you want to hack behind it. Um, so having remote [26:45.900 --> 26:48.800] admin to these means you basically have serial port access to all the stuff behind it, [26:48.800 --> 26:51.520] which is great. So if you want to like blow up pipelines, things like that, that's how you do [26:51.520 --> 26:55.620] it. Um, so the digi team was really cool. They were great to work with. Um, this device [26:55.620 --> 26:58.740] had already been like basically effectively legacy and retired, but it's still up for [26:58.740 --> 27:01.920] maintenance on screen patches. But they had to go find like the one developer who hadn't [27:01.920 --> 27:04.820] looked at this thing in five years and dust off their compiler and try to figure out how to [27:04.820 --> 27:07.700] build the damn thing and all that. And the funny thing about this is it ended up being an [27:07.700 --> 27:13.100] un, uh, an uninitialized variable in the SH engine. So it took us forever to repro, because [27:13.100 --> 27:16.320] we'd say, hey, we can get shells in like all these machines on the internet. Like here's a [27:16.320 --> 27:19.800] bunch of them, here's the serial numbers, like it's bad, go fix it. Like we can't repro it. I'm [27:19.800 --> 27:22.940] like, you got to be kidding me. Like just run the command. Like what are you doing wrong? [27:22.940 --> 27:26.920] Like it's run command, what's doing, it was not their fault of course. It's that when they [27:26.920 --> 27:30.160] were setting up the machine to test, they were logging in for the rest of the H first and [27:30.160 --> 27:32.400] setting up their monitoring on it. And then they'd run our exploit and it wouldn't work [27:32.980 --> 27:36.220] because the uninitialized variable had been set. So just one of those things was like [27:36.220 --> 27:39.380] freaking Heisenbug to repro. It took forever to fix. Anyways, so we finally got to the end of [27:39.380 --> 27:41.940] it, but the team was really cool. They're great to work with. They got a patch out even for [27:41.940 --> 27:45.900] this legacy hardware. So awesome to see them actually supporting older systems. Uh, then we [27:45.900 --> 27:49.920] found these real tech devices that are like branded all kinds of things. Netterbit, um, [27:49.920 --> 27:53.680] Netis, there's probably a good dozen vendors out there and they all have like different flavors [27:53.680 --> 27:57.560] of firmware from 2018 to 2023. And it's just like free shells everywhere. We don't even know [27:57.560 --> 28:02.080] who to report it to. So that's, there's a bunch out there. Um, yeah, have fun with that. Uh, we [28:02.080 --> 28:05.820] also ran across a bunch of Panasonic switches, but also a really weird set. And we had no idea [28:05.820 --> 28:09.160] who to report that one to either. Like the normal Panasonic thing wasn't the right fit. And so [28:09.160 --> 28:12.780] all the docs were in Japanese. We kind of gave up on that too. So we'll eventually figure out [28:12.780 --> 28:15.780] how to disclose that one. But there's a bunch of random Panasonic switches that'll just give [28:15.780 --> 28:19.000] you a shell pre-op as well through the same mechanism. Um, and this is just kind of the tip [28:19.000 --> 28:21.980] of the iceberg. We found another like 70 odd devices. We just haven't figured out where they [28:21.980 --> 28:25.580] are yet. Um, so, you know, basically take Shamble, throw it in your home network, throw it [28:25.580 --> 28:28.580] in your work network and you might just get random free shells out of crap through this stage [28:28.580 --> 28:32.000] transition. The only tricky bit here is you may have to specify a username that's not [28:32.000 --> 28:35.700] the default username. So if the device typically has like an admin or manager username, [28:35.700 --> 28:39.840] specify all the default admin usernames for the products and you'll be more likely to shake [28:39.840 --> 28:45.700] out some shells. So here's an example of the Netterbit NSL224s. These are really popular [28:45.700 --> 28:50.120] in Iran. So a huge portion of Iran uses these things and you just basically log in as, you [28:50.120 --> 28:54.840] know, whatever you like. Um, so in this case we're using the Shamble shell for it. We're [28:54.840 --> 28:58.880] just saying like brute force all the different session states and it logs us directly into [28:58.880 --> 29:02.340] it and it shows data, here's the firmware, all the info, things like that. So super [29:02.340 --> 29:07.380] straightforward. And here's an example of the Digitransport ICS gateways. Same thing. What I [29:07.380 --> 29:12.080] love about this is when you log in it says, welcome, your access is super. So I also have [29:12.080 --> 29:16.640] the, you know, the South Park voice in my head when I see that. So it's amazing. Um, with [29:16.640 --> 29:21.200] that, I would like to talk a little bit about the OpenSH landscape. So, you know, typically [29:21.200 --> 29:26.560] we think about like SSH being OpenSH and sure it's like 90% of us, it's 87% of all SSH in [29:26.560 --> 29:30.360] the world, but OpenSH isn't just OpenSH either. There's a lot of different flavors of [29:30.360 --> 29:35.840] OpenSH. So for folks who aren't super familiar, uh, OpenSH was forked from OSSH, which was [29:35.840 --> 29:42.800] forked from the original V1, um, you know, tattoo, um, version of SH back in the day. Um, [29:42.800 --> 29:48.080] but OpenSH wasn't designed for Linux. OpenSH was hardcoded for OpenBSD. Like they didn't [29:48.080 --> 29:52.440] want our dirty Linux paws all over their beautiful SH daemon. So eventually they conceded [29:52.440 --> 29:55.720] and said, you know what, you guys can, all you plebs can actually touch our beautiful SH [29:55.720 --> 29:59.520] code, but we're going to create a version of OpenSH just for you called OpenSH portable. So [29:59.520 --> 30:02.140] when you talk about OpenSH, you're really talking about the portable version of OpenSH, [30:02.140 --> 30:06.240] which has a compatibility layer that makes, um, all of us heathens be able to use the nice [30:06.240 --> 30:10.560] functions of VSD basically, uh, without all the pledge and cool things like that. But if you [30:10.560 --> 30:14.000] look at OpenSH portable, there's actually a bunch of variants of that too. So if you look at [30:14.000 --> 30:18.600] like who is molested OpenSH the most, we're going to start off with Apple. Apple was just [30:18.600 --> 30:22.140] light touch. They just gave a little hug. They didn't really do much to it. Uh, they did not [30:22.140 --> 30:27.540] do terrible things to OpenSH. They, um, added some changes for, um, let's see the key login, [30:27.540 --> 30:31.380] the endpoint event logging, uh, PKCS helper and keychain, things like that. Really [30:31.380 --> 30:36.600] straightforward, not terrible at all. Very happy that they did not destroy OpenSH. Um, they [30:36.600 --> 30:40.320] start looking at Debian and Ubuntu. They've got about 36 different patches on top of the [30:40.320 --> 30:46.300] core OpenSH code. Uh, and those patches make it libXE utils backdoor compatible. Um, among [30:46.300 --> 30:48.820] other things, right? But there's a lot of changes and those changes aren't getting the same [30:48.820 --> 30:51.920] scrutiny that let's say the rest of OpenSH code is getting. It's, it's basically linking it [30:51.920 --> 30:55.420] to all kinds of other libraries. It's the reason why it linked to system D. Um, there's a lot [30:55.420 --> 30:59.980] more attack service because of all those changes they put into the, those system patches. Now [30:59.980 --> 31:04.580] moving up to Red Hat, now you're like 60 plus different patches. So even, even bigger attack [31:04.580 --> 31:07.200] service. And, you know, hopefully they're auditing this stuff and everyone's looking at it [31:07.200 --> 31:09.800] because it's important because if you're hacking a Linux server, it's probably going to be [31:09.800 --> 31:14.140] either Debian, Ubuntu, or Red Hat based these days, right? Unless you're like, I use ARC, you [31:14.140 --> 31:18.580] know, you know, there's only a few of those out there. Um, so, um, if you're using, uh, you [31:18.580 --> 31:22.480] know, Debian, Ubuntu, Red Hat, Linux, et cetera, um, you probably have a ton of different [31:22.480 --> 31:27.280] patches on top of OpenSH that are not pure OpenSH, if you will. Uh, you may go pretty well. [31:27.280 --> 31:30.860] And then there's a thing called PKIX SSH, which I think probably a lot of folks haven't heard [31:30.860 --> 31:35.860] about. It was forked from OpenSH back in 2002 to support X.509 certificates and then FIPS [31:35.860 --> 31:40.140] code. So because it supports X.509 and FIPS, a lot of the networking vendors decided to use [31:40.140 --> 31:43.700] that instead of regular SSH, uh, to build out their products because they want to sell to the [31:43.700 --> 31:47.480] federal government and they want to use crusty old crypto protocols. Um, so there's a thing [31:47.480 --> 31:52.100] called PKI SSH. It forked in 2002. It mostly, it's almost like they hate each other. If you do, [31:52.100 --> 31:56.480] like, so, put it this way, we diffed all of it. We looked at, like, OpenSH mainline to every one [31:56.480 --> 32:00.240] of these forks and just read every single line of code for days and weeks. Well, that was my [32:00.240 --> 32:05.400] vacation. I just did that for hours a day. Um, but PKIX one is really funny because you'll see a [32:05.400 --> 32:10.340] change in OpenSH and then a change is written slightly differently in PKIX SSH and they [32:10.820 --> 32:14.560] oftentimes disagree. Like, once in a while they mostly match, like, if one equal this, if that [32:14.560 --> 32:18.560] equal that. But occasionally it's like, if not, one equal this. And it's like, so, there's [32:18.560 --> 32:22.120] probably some weird compatibility bugs because the changes weren't followed entirely. They [32:22.120 --> 32:25.420] obviously don't want to look like they're copying OpenSH, but they also can't not copy it and [32:25.420 --> 32:28.780] stay compatible. So, you can just, you can feel the rage between the two teams there. It's [32:28.780 --> 32:34.220] great. Um, I've never felt so much, like, animosity in a code diff before. Um, but finally, [32:34.220 --> 32:39.380] the, the really fun one here is Windows. So, Microsoft Windows, um, shipped OpenSH on Windows [32:39.380 --> 32:42.700] 10. Everyone's like, oh my god, I can actually type SSH and curl. I don't have to do all these [32:42.700 --> 32:46.100] stupid commands anymore to back to my Windows box. I can use the built-in, I did nice native [32:46.100 --> 32:49.720] Linux commands to back to my, my Linux boxes. And that was great. So, we love the fact that [32:49.720 --> 32:53.460] SSH clients on Windows, we can use them on all kinds of stuff. Um, there's also SSH server for [32:53.460 --> 32:58.300] Windows. And so, there's a fork for, uh, of OpenSH portable called OpenSH, um, under the [32:58.300 --> 33:03.780] PowerShell GitHub repo. And they just massacred it. There's like 350 files were changed. They [33:03.780 --> 33:07.220] ripped out everything. All those secure parts of SSH kind of just got put into the corner [33:07.220 --> 33:11.020] over there, uh, and, and deleted. And then it's like, if Windows do something totally [33:11.020 --> 33:14.620] different. So, they ripped out your support. They ripped out, um, the PrivSep stuff works [33:14.620 --> 33:18.040] totally different through a sub-process versus the fork, because there's no forks on Windows. [33:18.040 --> 33:22.820] Um, they, uh, logged to Windows Event Viewer. They logged, uh, they sent telemetry back to [33:22.820 --> 33:27.440] Microsoft for everything you do. Um, they still haven't bothered fixing Terrapin. Like, it [33:27.440 --> 33:31.040] just, it's a very different fork. So, if you're using Windows and SSH, either a client or a [33:31.040 --> 33:34.820] server, you probably want to pay attention to this next slide, which is, uh, let's see, this [33:34.820 --> 33:38.300] is what it looks like. Not super exciting. But, if you start looking through the OpenSH for [33:38.300 --> 33:41.540] Windows code, you can start looking at the telemetry callback. You can't disable this crap, [33:41.540 --> 33:45.860] unless you disable telemetry total on your machine. Every single connection going to your [33:45.860 --> 33:50.300] Windows, your SSH server on Windows, is sending your client version and server version back to [33:50.300 --> 33:54.140] Microsoft in the telemetry. So, every time you port scan your system, every time you run a [33:54.140 --> 33:57.660] Nessus scan against your Windows server, it's sending that info back. Every time you SSH [33:57.660 --> 34:00.880] directly from your Mac OS client or whatever it is to a Windows server, it's sending your [34:00.880 --> 34:04.300] version string back to them. So, Microsoft knows who you talk to, who knows who you shell [34:04.300 --> 34:08.080] into, it collects all those craps for default telemetry. It even collects telemetry for things [34:08.080 --> 34:11.200] that are part of an encrypted session, like things like authentication methods that are [34:11.200 --> 34:16.120] negotiated over the secure channel, that's also shipped off to telemetry. So, uh, you know, I [34:16.120 --> 34:19.780] know we're all good, you know, cool kids here and we disable telemetry in VS code, but like, [34:19.780 --> 34:23.740] have you done so in OpenSH? Probably not, right? Um, so it's worth digging out the [34:23.740 --> 34:26.640] diagnostics viewer where you can look at the telemetry data on Windows and seeing like all [34:26.640 --> 34:31.320] your SH stuff being shipped off to the cloud. Um, so, yeah. But the next thing we'll talk [34:31.320 --> 34:36.500] about is even worse. Uh, so there's this really key function, we talked about OpenSH [34:36.500 --> 34:42.040] portal being a, a compatibility layer to make it, um, work not on OpenBSD. So the pure [34:42.040 --> 34:46.240] OpenBSD people, you know, can, can give us their code. Um, one of the functions that they [34:46.240 --> 34:50.020] implemented was timing safe B comp, which is like you expect. It compares two binary [34:50.020 --> 34:54.180] blobs, are these identical, in a way that doesn't change based on how long the strings are, [34:54.180 --> 34:57.620] what contents they have. They, it can be consistent either way. This is to prevent side [34:57.620 --> 35:01.120] channel attacks, it's really clean, really code, it's only like four lines of code. Maybe [35:01.120 --> 35:04.960] take out the return in the int, in the variable, it's only three lines of code. It's really [35:04.960 --> 35:09.540] hard to, to break this, right? This is a super nice, great piece of code by, uh, you know, [35:09.540 --> 35:13.380] Damian, uh, Miller. It's great, it's perfect, it's beautiful. And then OpenSH for Windows [35:13.380 --> 35:20.100] comes along. And they made it Windows compatible. So, uh, Windows compatible means, uh, [35:20.100 --> 35:24.680] first they look for a back R and a back N, and they scrub out the back R, and so they [35:24.680 --> 35:28.020] said, they allied the fact that there's a back R back N, they treated it as if it was equal [35:28.020 --> 35:32.640] to a back N. But you can probably see there's some problems here. Um, we'll kind of [35:32.640 --> 35:35.840] highlight those real quick. First off, there's only two lines of code they added, and they [35:35.840 --> 35:40.180] introduced a ton of bugs. It's no longer timing safe, because they look one byte ahead. It's [35:40.180 --> 35:44.240] no longer, uh, secure, because they read one byte out of, out of band memory. They're [35:44.240 --> 35:47.540] actually reading the, the pointer plus one, not the pointer, which could be beyond the end [35:47.540 --> 35:51.340] of that particular variable. So for every back R back N sequence you have in the source [35:51.340 --> 35:54.820] buffer called by this function, you're actually going one byte out of the memory buffer and [35:54.820 --> 35:59.620] moving forward. And that, and then that value's being compared for your byte comparison. So [35:59.620 --> 36:03.100] if you know there's a lot of data at the end of your buffer, you can now just tell SH to not [36:03.100 --> 36:05.760] compare the bytes you thought you were comparing and now compare the bytes at the end of the [36:05.760 --> 36:08.780] buffer, which are typically a bunch of nulls or something more predictable. So there's a [36:08.780 --> 36:12.000] bunch of like really gnarly bugs that happen just because somebody decided their config [36:12.000 --> 36:15.140] parser didn't work with this function that wasn't designed to parse configs in the first [36:15.420 --> 36:19.980] place. Um, so it's, it's about as bad as it gets. So this function's used in every single [36:19.980 --> 36:24.060] packet that gets processed by SH. So every crypto buffer coming into it gets the SH comp [36:24.060 --> 36:29.440] or comp buff check on it. And, and basically it, it gets buggy really quick. Um, it's used [36:29.440 --> 36:32.280] for RSA signature validation, all this stuff. But the question was like, can we actually [36:32.280 --> 36:36.020] exploit it? And that's where it gets tricky. It's like the buffer that you can, that triggers [36:36.020 --> 36:40.020] the bug is the first buffer, first parameter, and the attacker doesn't control it directly. [36:40.160 --> 36:42.900] But if you do enough signing operations, you know, packets, eventually you get a buffer [36:42.900 --> 36:45.560] that has at least one back or back end in it. If you get to two, you get a little more [36:45.560 --> 36:48.360] interesting, but it's been really tough to actually get an exploit out of it. So of course, [36:48.360 --> 36:52.560] when we report to Microsoft, uh, their take is, you know, even though we've got $1 billion [36:52.560 --> 36:56.820] annual security budget, we've got 3,500 security professionals, and we backdoor your timing [36:56.820 --> 37:01.640] safe B comp code, you do not get a banana. So, we got nothing. They said, no, no, you guys [37:01.640 --> 37:04.180] don't get anything. We're not going to fix it. Have fun. Like, all right, well, we're going to [37:04.180 --> 37:09.880] talk about it at DEF CON. See you guys. Uh, so we did. Cool. Um, so that's the end of the, [37:09.880 --> 37:12.700] most of the content about SH. We're getting a little close to time. I want to make sure you [37:12.700 --> 37:15.640] have time for a little bit of questions here. Uh, we're going to talk a little about the [37:15.640 --> 37:20.440] shamble tool. So, uh, this tool is a research tool for SH limitations. It's a combination of [37:20.440 --> 37:23.700] like, a thing you can use today to scan your network, but a thing you can extend to find even [37:23.700 --> 37:28.140] more horrible bugs in SH and then share them with the world. So, uh, we, we'd like you to, uh, [37:28.140 --> 37:33.320] play with it, make it better, and, and rain hell upon vendors that do it wrong. Um, there's a [37:33.320 --> 37:37.180] lot of really cool interesting attacks against authentication, off-bypass, null-bytes, uh, ends [37:37.180 --> 37:41.820] up when you send a, uh, uh, SH password authentication, there's a, if you send a second [37:41.820 --> 37:45.180] parameter in addition to your password, that tells SH server that you want to change your [37:45.180 --> 37:48.260] password to that new value. So, you can imagine that when we're developing this tool, we might [37:48.260 --> 37:53.300] have accidentally changed a lot of passwords. Uh, so, be careful about that part. Uh, other [37:53.300 --> 37:56.160] than that, and it's kind of funny, it's like, oh, I got into all these machines, and then you [37:56.160 --> 37:59.000] scan them again, like, now I can't get into all those machines, what happened? Well, we [37:59.000 --> 38:02.340] accidentally sent all the passwords to a null-byte. Uh, there's also a lot of systems out [38:02.340 --> 38:06.940] there that will, uh, accept a null-byte as a password, and specifically a lot of honeypots. So, [38:06.940 --> 38:09.960] we doxed like 5,000 honeypots by accident because they accept null-byte passwords where [38:09.960 --> 38:12.300] nothing else does. It's like, oh, here's all the honeypots, that makes our lives a lot [38:12.300 --> 38:15.860] easier. Uh, a lot of the pre-auth state transition stuff, so you can extend those, make [38:15.860 --> 38:18.520] your own. It's kind of modular. It's not as cool as menisplate, but it does a lot of stuff [38:18.520 --> 38:21.680] like that. You can kind of add your own checks to register them. Uh, and then all the post [38:21.680 --> 38:25.340] session stuff, too. If you get a session, but you don't get a shell, you can use shamble to, [38:25.340 --> 38:28.960] like, bang on that session, try signals, jam keystrokes into it, generally do all the crap [38:28.960 --> 38:31.880] you don't want to do by hand that's really annoying, and eventually, um, do that. Plus, we [38:31.880 --> 38:34.740] added some timing analysis stuff, too. So, if you think there's, like, timing leak in a [38:34.740 --> 38:38.220] username, we've got some built-in functions that'll tell you, like, what's the, what's the [38:38.620 --> 38:40.800] statistical probability of this username being different than this other one based on a [38:40.800 --> 38:45.660] timing tag with really tight, uh, timing. So, shamble.com gets you all that stuff, and [38:45.660 --> 38:48.780] there's a whole bunch of stuff it does. So, I think, first off, I'll hand it to Rob to talk [38:48.780 --> 38:53.580] about all the vulnerability checks we do. So, uh, shamble will actually check for all the [38:53.580 --> 38:57.540] vulnerabilities we talked about, uh, over this, and they will not only check for you, it will [38:57.540 --> 39:02.000] give you proof, so you can run through, uh, it'll check for TCP forwarding, see if it can [39:02.000 --> 39:05.740] forward anywhere, it'll try different, uh, destinations, see what it can find, see if it's, [39:05.740 --> 39:10.040] uh, administratively prohibited for some. Uh, it will do generic environment injection, so [39:10.040 --> 39:13.780] it'll take, uh, environment variables, it'll control execution of processes, and we'll check [39:13.780 --> 39:17.620] to see if the output changes and things like that, uh, LD preload, stuff like that. Super [39:17.620 --> 39:20.760] useful, we'll say, oh, this is actually how it's vulnerable, this is what it can do, it'll tell [39:20.760 --> 39:24.580] you what to do next. Um, the software vulnerability that we talked about, it will, uh, it [39:24.580 --> 39:28.940] will give you the exact, uh, version and exactly the repo that it used and everything to get [39:28.940 --> 39:34.540] into there. Um, it will check the GOGS thing, that's the, uh, that's the, uh, ENV thing that [39:34.540 --> 39:38.560] looks vaguely like a backdoor, um, where it's executing ENV, and it'll try to give you [39:38.560 --> 39:42.620] commands, uh, command execution there. And, uh, it will check the ruckus password escape, [39:42.620 --> 39:47.220] that's the one where you can, uh, you can put backticks or, uh, dollar parens in the [39:47.220 --> 39:51.000] password, and, uh, it'll just give that to you and it'll say, and the report, you can [39:51.000 --> 39:54.280] actually see, uh, in the report, it'll say, okay, here's what I found, here's the [39:54.280 --> 39:58.160] references, and here's the proof, it'll actually give you the output that it found. Um, and [39:58.160 --> 40:01.800] you can just run that, they're automatically, it will automatically detect it, and it will [40:01.800 --> 40:05.900] continue, we're continually adding more vulnerabilities here, so, uh, stay tuned and run [40:05.900 --> 40:10.040] that on all your systems and tell us what you find. Well, thanks, Rob. And even in the last [40:10.040 --> 40:13.080] 24 hours since the code's gone live, we've got a lot of great feedback, feature requests, [40:13.080 --> 40:16.600] things like that, so we're really excited to keep expanding it, adding things like the, you [40:16.600 --> 40:19.240] know, keystroke masher, where it just, like, hits every possible keystroke trying to break [40:19.240 --> 40:21.700] out of the shell, like, the things you usually put your toddler in front of to make them [40:21.700 --> 40:26.260] give you shells, like, we'll just do that for you here, so, uh, who needs AI, right? Um, but [40:26.260 --> 40:30.120] in that sense, um, lots of cool stuff's already built in today, uh, to get started, you just [40:30.120 --> 40:35.880] run shamblescan-o, it generates a gigantic JSON file, um, if you run this across the [40:35.880 --> 40:39.720] whole internet, you get about 60 gigs of data, I don't know why I know that, but it's a lot [40:39.720 --> 40:42.580] of fun and you have millions of shells to go play with, uh, and then you can run the [40:42.580 --> 40:45.260] analyze command, it'll try to, like, bucket your results based on what cool things you [40:45.260 --> 40:49.220] found, so if it, if it's, like, a known backdoor, a known, uh, bug, it'll hopefully stick [40:49.220 --> 40:52.040] into its own little file and you can track them that way. We also report, like, [40:52.040 --> 40:55.540] vulnerabilities in the JSON, you can scrape out and import, uh, of course all this stuff's [40:55.540 --> 40:58.680] been, a lot of this has been linked into the run zero tool that we work on at, at our day [40:58.680 --> 41:01.600] job, and so it does a lot of these checks for you automatically, including grabbing all [41:01.600 --> 41:05.060] your keys, stuff like that. We're also looking at integrating it with, uh, honobox, [41:05.600 --> 41:09.060] a bad keys project to automatically identify host keys that have been compromised, and [41:09.060 --> 41:12.460] shambles is unique in that it's one of the very few tools that test all of your host keys, [41:12.460 --> 41:17.320] not just your first host key. So if your machine has an RSA key, an ECDSA, an ED25519, [41:17.320 --> 41:20.120] et cetera, we'll actually grab all the different host keys by grabbing them all and then [41:20.120 --> 41:23.860] test all those keys for weak keys and, uh, things like that. So we're still a little bit [41:23.860 --> 41:27.560] early for the bad key stuff, but we're, we're making progress. Uh, so an example, one of [41:27.560 --> 41:30.820] the neat things about shamble is that you can tell it to get into that larval session [41:30.820 --> 41:34.440] state without actually opening the process, which is a pain in the butt to do otherwise [41:34.440 --> 41:38.660] with the message client. So essentially you say, um, you know, shamble scan dash dash [41:38.660 --> 41:42.300] interact equal first. So interact with the first session you get and the interact auto [41:42.300 --> 41:45.780] equal nothing. Do not do any, do not do anything at all and just drop you straight to the [41:45.780 --> 41:48.860] interpreter shell instead. And then from that interpreter shell, you can like set any [41:48.860 --> 41:52.920] environment variables you want. LD debug equal all, LD preload, whatever you like. Uh, you [41:52.920 --> 41:56.940] can start sending signals to it even pre shell. And then when you want to drop a shell, [41:56.940 --> 42:00.360] you either type exec to run a command or you can do shell to get interactive shell. And at [42:00.360 --> 42:03.120] that point you can then mess with the shell itself. So it gives you kind of all the tools [42:03.120 --> 42:06.580] you need to manually mess with it and control E is how you open the shamble shell, uh, from [42:06.580 --> 42:10.040] the prompt there. Just so we don't conflict with SSH escape codes. And there's a million [42:10.040 --> 42:12.300] other things we can talk about, but we're going to keep kind of hammering on the code a [42:12.300 --> 42:17.040] little bit. And of course, happy scanning. And, uh, here's us just throwing out a slash 24 [42:17.040 --> 42:20.860] real quick, but it is pretty fast too. It'll just, it'll eat all your CPU and RAM just [42:20.860 --> 42:26.740] grinding away all your things. Um, and yeah, here's a bunch of bones we found. Thanks. [42:26.740 --> 42:29.740] We've got a couple of minutes, I think for questions, looks like. Uh, if you have a [42:29.740 --> 42:46.990] question, please come up to the middle standy thing and the mic so that everyone else can hear you. [42:48.850 --> 42:53.090] Um, the mic may not be on, I'm not sure. You want to grab this one instead? Yeah. [42:56.810 --> 43:02.430] Oh, sorry. You're still on mic. All right. So out of all the implementations that you have, [43:03.230 --> 43:06.870] that you've scanned, what is in your opinion, the most secure? [43:08.090 --> 43:11.830] Uh, the most seeker or the most insecure? The most secure. [43:11.830 --> 43:16.550] Okay. Yeah. The, yeah, two, you know, the, the TLDR of this entire talk is just use [43:16.550 --> 43:20.610] openness H98P1 and don't do anything else. Just don't roll your own. That's basically [43:20.610 --> 43:23.610] all you found. Just like any other crypto. Anytime you try to mess with it, you break it. [43:24.390 --> 43:27.190] Oh, thank you. Uh, any other questions? [43:29.190 --> 43:33.210] Does anybody recognize my shirt? It's, it's particularly nerdy. [43:34.710 --> 43:36.230] I'll be your friend if you know. [43:36.230 --> 43:41.830] Okay. Anybody? One more question? [43:42.250 --> 43:48.070] Yes. Did you guys try anything with Putty? Putty, P-U-T-T-Y client? [43:49.210 --> 43:57.470] Sorry. Yeah. It's a TTY client for windows called Putty SSH. [43:57.490 --> 44:00.610] Yeah. We didn't look at the code for it, but it's mostly client side. We really focused on all the, [44:00.610 --> 44:04.130] just the server side of invitations. I know Putty does a bunch of weird things with the keys. Like [44:04.130 --> 44:07.750] it has a weird preferences in which E-D-S-A keys uses, but we didn't get the chance to test Putty [44:07.750 --> 44:12.310] itself. There, there was an interesting, uh, not volume per se, but there was an interesting, uh, [44:12.310 --> 44:14.930] key generation issue with Putty this year. I need to go back and look at that. Yeah. [44:14.930 --> 44:15.890] Sorry. Another question? [44:15.930 --> 44:22.550] Does Shamble detects honeypots? Like how do you guys are detecting honeypots? And like, [44:22.550 --> 44:24.370] how Shamble detects honeypots? [44:28.130 --> 44:32.710] Okay. Yeah. So the short version is you, it just makes the TCP connection to whatever port [44:32.710 --> 44:36.190] and range you tell it to. And then it looks for that stage version, does the handshake, all that. [44:36.190 --> 44:38.890] So, um, that's about it. Unless I missed your question. [44:39.450 --> 44:41.510] How is it detecting honeypots? [44:41.530 --> 44:46.250] Oh, honeypots. Yeah. Um, so the funny thing is most honeypots, uh, have a bug where they accept [44:46.390 --> 44:50.370] a null-byte password and they just drop and they accept that where a real machine will never accept [44:50.370 --> 44:54.410] the null-byte password. So in a, in a, in an open-stage implementation, by default, if you put [44:54.510 --> 44:58.490] a null into the password field, it'll kick you back out. But most honeypots will accept you with [44:58.570 --> 45:02.250] a null-byte password. And that's an easy way to find like 5,000 of them. Um, we found a bunch of [45:02.250 --> 45:05.910] other ones through, uh, some of them accept any public key, no matter what key you give it. [45:05.910 --> 45:09.310] Other ones will take, uh, passwords that are, uh, outside the spec otherwise or [45:09.310 --> 45:12.770] m-mangled password requests. So you just throw a garbage item and it accepts it. [45:12.770 --> 45:14.270] You know it's not open-stage. [45:15.990 --> 45:18.270] Cool. All right. And that's it. Thank you very much. [45:18.290 --> 45:21.490] Thanks everybody. Look for us if you have any questions. We're happy to talk to y'all.