WEBVTT

00:00.000 --> 00:03.180
Hey guys, uh, so we're gonna talk about SSH.

00:03.180 --> 00:10.200
And this has been probably the most exciting year in SSH since x2.cd got leaked, x2.cd got leaked by Teso.

00:10.260 --> 00:12.720
So, um, uh, props to anyone who used that.

00:12.720 --> 00:24.140
Uh, so, uh, SSH for folks who aren't aware, um, you probably, probably should be here if you don't know what SSH is, but, um, SSH, secure shell, port 22, the thing we've been using to admin the internet for many years, like almost 30 years.

00:24.220 --> 00:28.140
Um, there's really two flavors of SSH that we use the most.

00:28.140 --> 00:31.720
There's open SSH, which is like 80 something percent of all SSH installations.

00:31.720 --> 00:34.880
And then there's DropBear, which is like another like five to eight percent.

00:34.880 --> 00:37.500
And then this long tail of random weird stuff out there.

00:37.680 --> 00:41.620
So we decided to do some research into first looking into the XC backdoor.

00:41.620 --> 00:49.120
And then part of that, we just accidentally found a couple tens of thousands of shells and we're like, well, let's go figure out what all these random things, all these free shells were.

00:49.120 --> 00:52.160
Uh, and that led to this giant pile of work and this open source tool.

00:52.500 --> 00:54.740
Um, so if you want to play with the toolkit, you can get it right now.

00:54.740 --> 00:58.080
It's this, the shamble.com S S H A M B L E.

00:58.080 --> 01:00.500
And that goes to GitHub and you can go grab the stuff and play with it.

01:00.500 --> 01:02.540
And it's a big hot mess, but we're making it better.

01:02.660 --> 01:06.040
And it should be a lot of fun as we start cranking on, make polishing up, making it cool.

01:06.580 --> 01:09.040
Um, so with that, we'll go ahead and get started.

01:09.580 --> 01:13.400
Um, fortunately, we're only doing 67 slides in 45 minutes, not 100.

01:13.400 --> 01:15.260
So we had a little breathing room this time.

01:15.820 --> 01:19.760
Um, so I'm sure we're all very much aware of the XCUTLs backdoor.

01:19.760 --> 01:20.800
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:31.580
Obviously, XCUTLs backdoor targeted SSH using the system vpatches and Debian and, uh, Red Hat builds of OpenSH.

01:31.680 --> 01:36.740
We also had the really cool Terrapin vulnerability, which affected pretty much everything because of the truncation attack.

01:36.760 --> 01:42.180
Um, we also had, uh, the regression vulnerabilities, the really fantastic work by the Qualys Threat Research Unit.

01:42.180 --> 01:46.780
Um, and then the other regression bug found by SolarDesigner that only affected Red Hat.

01:46.780 --> 01:47.880
And regression was amazing.

01:47.880 --> 01:52.180
It's a signal re-entrance bug that gets you remote route in OpenSH by default.

01:52.180 --> 01:56.780
It just takes six hours on a 32-bit machine or weeks or months on a 64-bit to compromise.

01:57.020 --> 01:58.340
So, but it's been a really cool year.

01:58.560 --> 02:01.640
Um, one of my favorite SSH bugs this year kind of flew under the radar.

02:01.760 --> 02:07.720
Um, the guys at Watchtower Labs did a really cool analysis of the move-it vulnerability that uses the SFTP server.

02:07.740 --> 02:12.780
And so they found a vulnerability where any public key being sent to the service, um, would be treated like a file path.

02:12.780 --> 02:14.640
Like the binary blog gets treated like a file path.

02:14.640 --> 02:17.380
And it just opened random UNC URLs and all kinds of fun stuff.

02:17.380 --> 02:20.540
They threaded like a million little needles to be able to get a shell remotely and boot it.

02:20.540 --> 02:25.600
But the really cool thing about that bug is it affected every other vendor also using IPWorks as the underlying library.

02:25.600 --> 02:29.500
So, they actually uncovered like a supply chain bug, if you will, which is really neat.

02:29.880 --> 02:36.020
So, going kind of back on topic again, um, the XEUtils vulnerability or backdoor was amazing.

02:36.020 --> 02:38.980
It was like its own little Netflix docu-series, right?

02:38.980 --> 02:42.180
We're going to see like the true crime of XEUtils for years.

02:42.180 --> 02:43.560
But like who is Gia Chan?

02:43.560 --> 02:46.920
Like it's going to, it's the most dramatic thing to happen to InfoSec in a very long time.

02:47.180 --> 02:55.100
Um, so the, this is a multi-year campaign where this person, um, contributed to open source for a long time, then eventually kind of twisted the knife and tried to backdoor the world.

02:55.160 --> 03:05.060
And I got caught at the very last minute by, uh, Anders Frond, who says, hey, my SSH is taking slightly too much longer than it should, and then unraveled the whole thing right before it got put into the stable distributions.

03:05.300 --> 03:07.580
So, we got really close to the whole internet being backdoored.

03:07.740 --> 03:13.920
Uh, but what was really important about that backdoor that it was a nobody but us backdoor, which is normally, you know, normally the US government is famous for those.

03:13.920 --> 03:15.920
But in this case, who knows who it was.

03:16.080 --> 03:21.800
Um, in fact, it was a encryption key controlled by the attacker that only people with a private key had access could abuse the backdoor.

03:21.800 --> 03:23.500
That was really a neat thing about it.

03:24.300 --> 03:27.360
So, we thought it'd be fun to go figure out who this Gia Chan person was .

03:27.360 --> 03:30.900
And we're like, hey, you know, everyone's looking for Gia Chan, we're going to go find some Gia Chan.

03:31.480 --> 03:36.200
Uh, and we're very happy, Alfredo, if you're out here, thank you so much for designing your graphics, they're amazing.

03:37.940 --> 03:39.380
Um, so we decided to go hunting.

03:39.420 --> 03:43.880
And, you know, before we go hunting for Gia specifically, we want to talk a little bit about SH protocol.

03:43.880 --> 03:48.900
So, uh, Gia Chan targeted SH, uh, with ex- with ex-utils backdoor.

03:49.040 --> 03:51.240
So, we're going to target Gia Chan using SH.

03:53.220 --> 03:56.800
But before we go there, we need to talk about how SH public key authentication works.

03:56.900 --> 03:59.020
So, SH public key authentication is two-stage.

03:59.020 --> 04:03.360
The first thing you do is say, hey server, would you accept this public key for this username on your machine?

04:03.360 --> 04:04.660
And it says, yeah, sure.

04:04.660 --> 04:08.420
And then you have to sign this big blob of data that proves that you have the private key.

04:08.640 --> 04:10.740
But you can do that first part without the private key at all.

04:10.740 --> 04:11.320
And it's really cool.

04:11.320 --> 04:20.540
There's been a module in Metasploit 4 since 2012, lets you take someone else's public key that you got, however you got, and then check a bunch of servers to see whether that public key has access to, uh, those servers for that username.

04:20.540 --> 04:21.940
So, you can kind of see where this is going.

04:22.300 --> 04:25.160
Um, it's, there's this great comment on OpenSH saying, is this a problem ?

04:25.160 --> 04:25.680
I don't know.

04:25.680 --> 04:26.480
But it's been there forever.

04:26.480 --> 04:28.260
It's just kind of the protocol spec at this point.

04:28.300 --> 04:28.840
It is what it is.

04:28.840 --> 04:30.060
Maybe it's not a big security deal.

04:30.480 --> 04:34.440
So, we decided to create this thing called Shamble, which started off being a half-off scanner for SH.

04:34.480 --> 04:42.860
So, what we do is you take a bunch of public keys and then you'd like put them in Shamble and scan the whole internet saying, what on the internet can you access using these public keys?

04:42.980 --> 04:49.620
And the idea is like, well, if we had, let's say, Gia Tan's public key, we can find all the servers that they use and then from there we figure out who they are.

04:49.620 --> 04:50.760
So, that was, that was the idea.

04:50.860 --> 04:55.360
But it ended up evolving to this massive tool to find all kinds of other crap because of all the things that we found.

04:55.360 --> 04:59.900
So, you know, first thing you do say is, hey, my name's Gia Tan, we're gonna go download your GitHub keys.

04:59.900 --> 05:12.060
So, we grabbed our two GitHub keys, which are still present today, um, and basically took those two public keys, ran them into Shamble, and then, um, you know, threw that at the whole internet, all the, all the sh-demons we could find, let it grind out for a couple days.

05:12.880 --> 05:18.740
And what's, what's exciting about it is, like, we spent the whole week on this, we hadn't slept or anything like that, Rob and I were like working at four in the morning, like, we got one!

05:18.740 --> 05:20.060
We got a hit for Gia!

05:20.120 --> 05:21.060
It's really exciting.

05:21.560 --> 05:24.060
Um, in the meantime, we're melting all of our DigitalOcean nodes.

05:24.060 --> 05:27.920
So, this is this poor little DO droplet just like falling apart as we're like destroying it.

05:27.920 --> 05:29.920
It's, I think it's sent like a terabyte of traffic at this point.

05:29.920 --> 05:33.520
Like, we're, yeah, we made DO VMs very unhappy.

05:34.160 --> 05:41.080
Um, so, just heads up for law enforcement, um, we sent the public key for GiaTAN to every server on the internet from RIPs.

05:41.180 --> 05:45.140
We are not GiaTAN, we are not backdoor exe-utils, even though it very much looks like we did.

05:45.140 --> 05:47.300
So we sort of accidentally framed ourselves.

05:47.300 --> 05:56.360
Uh, we realized that after the fact that we probably might, I'm sure the long-arm law will catch up at some point, like, you guys, you're GiaTAN, like, ten years from now, and like, yeah, we are not, sorry.

05:57.720 --> 06:01.980
So, um, unfortunately, like, every single result we found that we thought was false positive.

06:01.980 --> 06:07.920
It was like a buggy server with, like, the memory was corrupted, or the service would accept every fifth public key, or every third public key.

06:08.020 --> 06:12.480
So we had to say, okay, let's try a bunch of random public keys, and if you reject all those, now try the Gia key.

06:12.480 --> 06:15.620
And let's try, like, an RSA key, RSA 1024, 2048.

06:15.620 --> 06:20.020
We've still found devices that just randomly accept or randomly not accept keys, and it just drove us crazy.

06:20.020 --> 06:28.480
So we finally fixed all these bugs, re-scanned, re-scanned, re-scanned, uh, you know, clicked all those digital ocean abuse notices, says, yeah, we're good, our server's not compromised, we're cool.

06:28.560 --> 06:30.680
Um, and we still found no Gia 10.

06:30.680 --> 06:34.860
So, whoever this, you know, actor was, they had really good OPSEC, we found nothing, so good job them.

06:34.980 --> 06:36.880
Um, but we did find, like, thousands of free shells.

06:36.880 --> 06:40.260
So, we're like, how come we're getting all these random shells and all these random machines?

06:40.260 --> 06:42.080
And that's really what this talk is, is about.

06:42.740 --> 06:45.300
Uh, so with that, um, a little bit of a detour.

06:45.300 --> 06:49.660
So, an SH, um, public keys used to not be something that you actually made public.

06:49.660 --> 06:53.560
They used to be something you kind of kept privately, and you were .SH directly, and you copied to a server here and there.

06:53.640 --> 06:58.960
But, um, in the last five or six years, we've seen people using, uh, SH keys like identities.

06:59.260 --> 07:03.960
So, just like people used PGP back in the day, you can now use SH keys as your identity when you're installing a bunch of server.

07:03.980 --> 07:09.140
You can tell it to grab your key from GitHub or from Launchpad and automatically give you access to your server during installation by username.

07:09.520 --> 07:14.560
Um, you can also, uh, um, use these keys for things like, uh, OJ encryption.

07:14.560 --> 07:18.620
So, if you use the OJ tool or H tool, you can use it almost like a PGP key now these days as well.

07:18.620 --> 07:21.660
So, it's all kinds of cool stuff you can do with, uh, SH keys you didn't before.

07:21.660 --> 07:25.540
But the key thing here is, like, keys are effectively public if you use any of these major platforms.

07:25.880 --> 07:26.780
And literally public.

07:26.840 --> 07:30.740
So, there's this great little, uh, daemon by Filippo where if you SSH into it, it'll say who you are.

07:30.740 --> 07:36.060
It'll use the public key you send to the server, dock to you based on the GitHub database and say, oh, you're so and so, welcome.

07:36.180 --> 07:37.380
So, it's kind of a fun little trick.

07:37.680 --> 07:40.160
And effectively, we're doing that, but at scale for the whole internet.

07:40.500 --> 07:45.740
So, if you want to link a user to a particular key on a particular server, you need, um, one, a list of all the SH servers out there.

07:45.740 --> 07:48.940
So, ZMap, Mascan, dump it, show it in, whatever you want to do to get the list.

07:48.940 --> 07:55.100
You want a list of all the public keys, so you go grind all those out of GitHub through their BigQuery API, about 117 million users as of about a month ago.

07:55.540 --> 07:56.700
Launchpad's got a bunch of users, too.

07:56.700 --> 07:57.460
You get all their keys, too.

07:57.460 --> 07:58.200
Why not?

07:58.220 --> 08:03.920
And then Bad Keys is a great project by, uh, Hanno Bach, um, that allows you to, that keeps track of all the compromised keys out there.

08:03.920 --> 08:06.200
So, you can look for keys that give you access to the system.

08:06.200 --> 08:12.880
And then lastly, you need a list of common usernames the user might have, like root, ec2 user for cloud, Ubuntu, et cetera, or whatever the comment is in the key.

08:13.000 --> 08:20.680
So, one of the nice things about GitHub is that when you upload your public key to there, they actually preserve the comment field, which is typically your, your username when you uploaded the key.

08:20.700 --> 08:21.920
So, you know what their default username is.

08:21.920 --> 08:25.940
So, if you're trying to find, like, their server someplace, you can pull it out the comment, use that to talk to the user, and so on.

08:26.240 --> 08:28.640
So, you, you take this nice little recipe and you throw it in the oven.

08:29.440 --> 08:34.260
And, um, it gives you a nice little primitive to take a one key and check lots of servers really fast.

08:34.260 --> 08:37.620
Like, you can grind through all the servers on the internet in, like, an hour or something like that on a single box.

08:37.620 --> 08:38.300
It's pretty quickly.

08:38.440 --> 08:39.540
Just for one key.

08:39.780 --> 08:43.220
Um, but if you want to test, um, so that works great if you're looking for, like, a geotan everywhere.

08:43.240 --> 08:51.720
But what if you want to say, for this server on the internet that's acting fishy, which GitHub user has access to it and do the other way, to check all 117 million keys on one server.

08:51.960 --> 08:53.100
Well, that's a very different attack.

08:53.100 --> 08:56.360
That's like, you know, duck-sized horse or horse-sized ducks, you know, kind of approach.

08:56.440 --> 09:02.360
So if we want to test a million keys against, uh, a single server, it's a little bit tougher because, uh, SH will slow you down.

09:02.460 --> 09:07.680
Uh, they have, uh, this thing called max auth limit, which is how many tries you can authenticate before it kicks you off of that connection.

09:07.700 --> 09:10.720
And there's a max connection limit, so you can only do so many of those at once, right?

09:10.880 --> 09:16.240
So the idea is that with OpenSH, if you try to brute force keys, you get four into it and it knocks you out and you can't auth anymore.

09:16.320 --> 09:22.520
So if you ever had more than four keys in your SH, uh, agent, and you try to shell out a machine and it just immediately says, you know, too many tries, that's why.

09:22.520 --> 09:25.020
It's because you're hitting the max auth limit of OpenSH.

09:25.540 --> 09:28.060
However, um, OpenSH is the only one that does that.

09:28.060 --> 09:30.160
Everything else lets you just bang keys all day long.

09:30.320 --> 09:34.360
So DropBear lets you just grind keys as fast as that little device can, can test them.

09:34.380 --> 09:39.840
Um, also a lot of commercial products like Bitbuys, GlobalScape, Maverick, LanCom, all this stuff, all their SH daemons do not care.

09:39.840 --> 09:42.560
They'll let you just try every possible key in the world until, until you're done.

09:42.560 --> 09:43.200
It's great.

09:43.400 --> 09:47.580
Uh, we emailed the DropBear folks, they didn't care, they didn't even bother replying, so we're like, it's not really a bug, it's a feature.

09:47.580 --> 09:48.960
So, we like that feature.

09:50.060 --> 10:01.200
So, uh, with the shamble code you mentioned before, we tested the GitHub, like 4.6 million key database at the time, and you can do about 10,000 keys per second on a DropBear box on an embedded node without it spiking the CPU on the target device at all.

10:01.200 --> 10:01.980
It just doesn't even care.

10:01.980 --> 10:03.080
It's like super fast.

10:03.080 --> 10:04.340
So it doesn't even murder the machine.

10:04.340 --> 10:08.700
And this is 10 ,000 keys per second per connection, and DropBear is typically configured with 15 connections.

10:08.700 --> 10:14.260
So you can do 150,000 keys per second on a machine for pub key testing to dock someone's server.

10:14.340 --> 10:18.420
So if you see someone like hitting you on a random box and SH is open, just go take all the keys and get it.

10:18.420 --> 10:19.680
I'd be like, yeah, you jerk, stop that.

10:19.680 --> 10:21.000
And just email him, like quit it.

10:21.020 --> 10:23.620
Like, it's really, really easy to dock to your hackers.

10:23.800 --> 10:30.840
And if you're running an SH honeypot and your SH honeypot collects the public key being sent to you, you can turn around and flip that on them again and immediately figure out who they are.

10:30.860 --> 10:35.780
Like, people forget all the time that their SH agent's configured and they're sending their public key to every server they connect to.

10:35.780 --> 10:40.740
Even if their agent is not authenticating to it, they're still automatically sending that public key as a task whenever you touch anything.

10:40.980 --> 10:48.600
So if you're a, a lead hacker and you've been just SHing at random machines on the internet, you're also sending your public key identity to all those machines and if they're logging at your host.

10:50.040 --> 10:54.780
So, um, by contrast, if you try the same attack against open SH, you can do 132 keys per second.

10:54.780 --> 10:58.640
So it'll take you 10 hours to do the same 4.8 million keys with a single connection.

10:58.760 --> 11:04.780
So, um, obviously the open SH approach is much nicer, um, but it's great if you're trying to, um, adapt, docks people.

11:04.860 --> 11:07.700
So, uh, with that, I'll hand it to Rob to talk about shaking out shells.

11:08.700 --> 11:10.200
Testing, testing, testing.

11:12.700 --> 11:13.620
Testing, testing.

11:13.620 --> 11:14.920
Hey, all right.

11:15.000 --> 11:18.460
So shaking out shells, say that five times fast.

11:18.780 --> 11:28.600
Um, what we did with shamble is it resulted in, uh, around 27 million devices on the public internet that are listening on port 22.

11:28.600 --> 11:36.800
We got another, you know, 14 million or so that actually negotiated, uh, SSH off and we ended up with about 110,000 sessions.

11:37.040 --> 11:47.440
Um, what's really interesting about SSH, so SSH, uh, especially open SSH has done an immense amount of work in, do what?

11:48.520 --> 11:50.560
Oh, sorry, front mics are hot.

11:50.980 --> 11:52.700
Uh, so, sorry.

11:52.740 --> 11:59.980
So, uh, we ended up with, um, about 110,000, uh, that are actually listening and we were able to get sessions.

11:59.980 --> 12:06.900
What's fascinating about open SSH is, or SSH, is that there's a fairly large post-authentication attack surface.

12:07.080 --> 12:08.880
So SSH does lots of things.

12:08.880 --> 12:17.320
You can create tunnels, you, uh, can create pseudo-terminals, there's subsystems, there's all sorts of things that are running on, uh, SSH once you're inside.

12:17.480 --> 12:27.460
Uh, it kind of assumes that once you've authenticated, you're okay, but there's an immense, uh, an immense amount of systems out there that actually will do this interesting post-auth-auth.

12:27.500 --> 12:36.280
So you authenticate, uh, non-authentication with left beef and you get in and then it actually gives you a secondary authentication mechanism.

12:36.280 --> 12:40.800
It'll prompt you for a username and then a password, but you're inside the session at that point.

12:40.800 --> 12:42.340
So you can start doing some interesting things.

12:42.340 --> 12:45.660
This is one of the, the interesting cool things that, that Shamble will do.

12:46.020 --> 12:52.960
Um, you can say, oh, okay, uh, I can send signals, I can send, uh, SIGWINCH, I can, uh, forward X11, things like that.

12:53.340 --> 13:01.740
And you can see there's a fair amount of large, uh, devices, uh, popular devices out there that do this post-auth-auth.

13:01.740 --> 13:10.120
So you can see you've got, uh, SonicWall firewalls, um, Juniper network devices, you can SSH in with auth none, and then it'll give you the secondary one.

13:10.120 --> 13:14.820
That, uh, that smaller one, the please login, that's, uh, a ruckus one that HD's gonna talk about here in a minute.

13:14.820 --> 13:16.960
That's super, uh, super fascinating.

13:16.980 --> 13:26.000
But it's worth noting that there is this post-auth attack surface that is kind of not considered, but is exposed.

13:26.100 --> 13:30.140
So, uh, and with that, with sort of the first one that you can talk about is signal injection.

13:30.140 --> 13:32.060
I'm gonna pass it back to HD for that.

13:32.480 --> 13:33.600
Did we get the second mic working?

13:34.360 --> 13:35.260
Cool, thank you.

13:35.260 --> 13:37.680
Sorry, just trying to stay away from the front mic so we don't get feedback here.

13:38.260 --> 13:46.040
Um, so, uh, Rob mentioned that one of the things you can do to a post-auth session is, uh, inject signals into the process before you've fully authenticated.

13:46.160 --> 13:54.200
So if actually you can connect to a machine, it'll pass through the authentication from SH auth equal none, and then drop you to a real login shell, and it'll say, please login.

13:54.340 --> 13:57.260
And you can just say, signal seg v, and it goes, ah, and dies.

13:57.360 --> 13:58.380
Which is a lot of fun.

13:58.440 --> 14:02.640
So effectively you can just, you know, we talk about regression being signal re-entrance, this is just signal entrance.

14:02.640 --> 14:06.440
You just bang signals all day long into whatever process you want and see what terrible things fall back out of it.

14:06.600 --> 14:10.600
So, uh, we didn't get too far into this testing, but we, there's all kinds of fun things that come out of it.

14:10.600 --> 14:20.560
You can send a SIGINT request, you can pass Python scripts that are part of the login shell to crash, uh, you can do SIG alarms, SIG childs, SIG ills, SIG aborts, you can pass core dumps, uh, all kinds of crazy stuff you can just do with signals.

14:20.560 --> 14:27.040
And OpenSH tries to protect you a little bit by limiting things like sig seg v, sig abort, and so on, uh, but DropBear does not.

14:27.040 --> 14:30.840
DropBear is like, anything that you can possibly send me, I'll treat as a signal and deliver to the process, thank you.

14:30.960 --> 14:38.780
Um, so there's a lot of really cool attacks that we think you can do there, and we're gonna start working on expanding the shamble code to then basically just mash symbols into random processes so you get a shell.

14:39.040 --> 14:42.020
And, yeah, um, with that, hand it back to Rob to talk about TSP forwarding.

14:43.300 --> 14:48.860
I, I do always love that, uh, DropBear is like, I, you know, it's like if it were dying, it wouldn't be dictating, right?

14:48.860 --> 14:51.420
It wouldn't be writing it out, it would just say IEE, but no.

14:51.620 --> 14:57.160
Um, but another part of this post-auth, uh, uh, attack surface is forwarding, right?

14:57.160 --> 15:03.620
So SSH allows you to generate or create tunnels, uh, you know, through channels and create encrypted tunnels.

15:03.960 --> 15:08.460
It's almost like a little miniature VPN thing, and this is a pretty popular and common, uh, feature.

15:08.460 --> 15:11.920
But once you po-, once you're in this post-auth situation, you can start doing that.

15:11.920 --> 15:14.340
You can start creating these things on a lot of these systems.

15:14.500 --> 15:28.880
Um, many of them will administratively restrict you from doing it or they'll only let you go to certain things, but for example, uh, uh, you can say, okay, well I'm gonna try to forward to this particular host, or I'm gonna try to forward to a local host and do a loopback,

15:28.880 --> 15:45.740
um, and we actually found, uh, this is an ION, yeah, okay, good, the chip's playing, uh, this is, uh, an ION network's access point, and you can see that it's trying to, uh, forward to google.com, and it, it gets rejected, and then it's gonna try, oh,

15:45.740 --> 15:48.440
and by the way, this is the shambles shell, uh, which I love.

15:48.740 --> 16:03.440
Um, and it'd say, oh, I'm gonna try to get to 88888, but then you can actually forward back to local host, so you can actually use that to get around restrictions and things like that once you're in this sort of, uh, uh, mystery, uh, uh, post-auth shell.

16:03.580 --> 16:09.280
But, the big, the big one is shell injection, I'm gonna let you take this one, cause this is super cool.

16:10.080 --> 16:14.040
So one thing that was kind of fun about this is that we found bugs that, like, we shouldn't have found.

16:14.040 --> 16:22.040
Like, because of this post-auth sequence, effectively you SH to the machine, and instead of asking for a password, you just, it drops you straight in, but it drops you straight into a secondary shell.

16:22.040 --> 16:23.960
And that secondary shell has its own bugs.

16:23.960 --> 16:28.720
So we kept finding these vulnerabilities in these secondary shells that no one had found before, even though they were, like, stupid.

16:28.720 --> 16:32.740
Like, we found so many dumb bugs just because no one really tested that level of the protocol.

16:32.860 --> 16:46.160
So in this case, um, we're right across these, like, ruckus access points, and you SH them, there's about 36,000 of these suckers exposed to the internet, about 900 are vulnerable to this particular attack, still right now, today, and it asks you for a username,

16:46.160 --> 16:51.400
you type in root, you type in, you start entering your password, and for your password, you just type in, like, dollar, parenthesis, whatever command you want to run, right?

16:51.440 --> 16:55.800
And just redirect it back out to standard error so you can see the result, and it just runs this root, pre-auth, it's great.

16:56.100 --> 16:59.040
Um, so we'll, we reached out to ruckus, of course, like, hey, what's up?

16:59.040 --> 17:00.440
Like, you guys, is this a new bug?

17:00.440 --> 17:01.220
Is this a fixed bug?

17:01.220 --> 17:02.700
We can't really tell what's patched.

17:02.700 --> 17:03.840
Like, oh yeah, we patched that already.

17:03.840 --> 17:05.200
I'm like, did you tell anyone?

17:05.220 --> 17:06.300
Nope, they didn't tell anyone.

17:06.300 --> 17:08.080
There's no CV, no security note whatsoever.

17:08.240 --> 17:11.220
So of course no one's applying patches because they didn't know they had to apply a patch.

17:11.560 --> 17:18.920
Um, so they've got two different tracks, the 521 and the 621, those both fix it, but there's, you know, still about, you know, almost a thousand folks out there still running unpatched up.

17:18.920 --> 17:21.180
But the question was, like, why did this bug live so long?

17:21.180 --> 17:28.640
How did we end up with this, like, a stupid login prompt, like, password character injection, and it's because it was behind this SSH auth layer that no one really bothered to test it.

17:28.640 --> 17:34.240
Like, all your folks who normally hit a telnet prompt, something like that, just hadn't tried this SSH post auth attack.

17:34.240 --> 17:40.420
So we uncovered this whole, like, layer of bugs that really should have been found 20 years ago, but they were just hiding behind this extra SSH layer.

17:40.500 --> 17:43.040
Uh, and that's one of the interesting kind of side effects of this work.

17:43.040 --> 17:46.620
So here's an example of us, uh, rooting one of these random ruckus boxes.

17:46.820 --> 17:56.360
SSH in with all the, I don't care about my cipher stuff, please log in, R-O-O-O-O-T, and then for the password, we're just typing in $PSAOX-W and getting a big process listing.

17:56.500 --> 18:03.800
And the funny thing about it is you can actually see the echo command in the PS listing showing that it's going to shop 256 sum, that's how they check your password.

18:03.820 --> 18:06.880
So they fixed it just by putting in proper quotes, but the whole thing is ridiculous.

18:06.880 --> 18:11.560
So it's amazing, like, how many dumb bugs are out there if you just go a little bit further into the protocol stack.

18:11.660 --> 18:13.680
And back to Rob for the permit.

18:15.500 --> 18:24.560
So SSH, you know, is the secure shell, it's designed to talk as your shell, it replaces Telnet and RSH and all that, and it lets you set environment variables.

18:24.660 --> 18:30.380
Um, environment variables are used to control the execution of things and, you know, keep track of the environment and all that.

18:30.380 --> 18:35.660
And a lot of, uh, SSH implementations will limit what you can send, but a lot won't.

18:35.660 --> 18:41.920
Um, there's been a, uh, and it's configurable, of course, some will, uh, accept these environment variables, some don't accept these.

18:41.960 --> 18:54.140
So there's been this renaissance in, uh, Gitforges lately, there's a ton, there's, there's GITI, there's GOGS, there's, uh, I always pronounce this wrong, FORGEHO, tell me if I'm saying that right, GARET, things like that.

18:54.440 --> 19:07.320
And they are using these embedded SSH libraries that speak the SSH protocol, and these libraries, because they're, you know, designed for general use, they will accept, you know, any environment variable you send, and they rely on the client, the user of the library,

19:07.320 --> 19:09.840
to, uh, limit what is going on.

19:10.380 --> 19:24.820
Um, and so that's generally okay, like a lot of them do it correctly, uh, for example, GitLab, GITI, FORGEHO, they will only accept Git protocol as, uh, an environment variable, and that's, uh, something that's looked at by Git to negotiate protocol versions,

19:24.820 --> 19:27.120
so you can say, oh, I want to use Git protocol version 2 or whatever.

19:27.160 --> 19:40.840
But, for example, there's still some vulnerabilities there, if you were using a version of one of these, these are all written in Go, and it was compiled using a version of Go prior to 1.19.3, which is a year or two old, um, on Windows systems, they don't properly sanitize the,

19:40.840 --> 19:47.180
uh, the value of the environment variable, so if you put a null in there, you can actually just inject arbitrary environment variables, which is, uh, super fun.

19:47.500 --> 20:02.060
But, um, there was another one that was really interesting in, uh, GOGS, where whenever it gets an environment variable, it actually runs the env command, and so the point of the env command is to start a new process, um, with a new environment, with,

20:02.060 --> 20:04.320
you know, setting certain environment variables or whatever.

20:04.760 --> 20:09.700
And it starts a new process, it doesn't affect the environment that you're in, right?

20:09.700 --> 20:12.280
It, it, that's not how POSIX works.

20:12.360 --> 20:26.460
So you could just say, okay, well, I want to set an environment variable with, you know, dash, dash S A equals B, and then, you know, bash, or, you know, touch temp foo, or whatever, and you are just executing arbitrary commands.

20:26.460 --> 20:32.840
And we, we did reach out, there's, there's no patch for this, uh, it's, seems moribund, so maybe don't use it.

20:33.960 --> 20:34.520
Um.

20:34.680 --> 20:47.880
This is a great example of, like, parallel discovery, so, not in, not in the court sense, but in the, uh, we reported this vulnerability on, like, April 24th, and Sonar Research had reported the same bug to the same maintainer on the 22nd, and they scooped us on the advisory,

20:47.880 --> 20:55.360
and we both had our own separate GitHub advisories, but it's just hilarious that we both managed to look at the same bug at the same time, so, it's funny, like, how often that happens, and this is a great example.

20:55.360 --> 21:06.500
So props to the Sonar source folks for beating us by two days, uh, and they did a really great blog post about how the bug works, but it, it almost looks like a backdoor, because it doesn't actually influence the environment of the subprocess, it's just a straight command exec pre-auth,

21:06.500 --> 21:08.160
so it's a, it's a funky bug.

21:08.180 --> 21:08.740
Yeah.

21:09.060 --> 21:10.700
Yeah, exactly, thank you, HG.

21:10.920 --> 21:26.500
Um, so going back to these, uh, these libraries, so, for example, uh, Apache Nino, which is a Java, uh, implementation of SSH, will accept any variable you want, um, and most of the time, uh, it doesn't really run into anything, but this is, this is maybe my whole,

21:26.500 --> 21:29.280
this is maybe my favorite thing that we found, uh, personally.

21:29.420 --> 21:44.280
Uh, so there's this piece of software called SoftServe, and it's designed to build, um, Git repos, and it gives you this beautiful, uh, SSH, or, you know, CLI, you SSH in, you control it, you can do whatever, and it uses, um, the Charm Bracelet SSH, uh,

21:44.280 --> 21:58.860
library, which is built on top of Go's SSH, um, and it will accept any environment variable, or it did, we reported it, they fixed it, this is our CVE, Go us, um, but what's fun is you can, first off, watch how slow I am when I'm typing in, uh, in GIF form,

21:58.860 --> 22:12.320
but, um, you can, uh, we just basically created some shellcode, and we checked it into LFS, and you can actually do this in lots of different ways, LFS just, uh, Git LFS is large file storage, it, it just makes it to where it's not compressed, and, uh,

22:12.320 --> 22:26.240
the file name is predictable, so we don't have to worry about it too much, uh, makes it easier to exploit, we push it up to, uh, to SoftServe, and then, uh, doing the SHA 256 sum of our shellcode, because that gives us the, uh, the file name that we can,

22:26.240 --> 22:33.280
you know, guess, and then we just set LD preload to our shellcode, and we now have, you know, shell on that system.

22:33.280 --> 22:44.120
So, that was super fun, uh, I, I always love when I get a shell, and I'm just like, oh, this is great, you know, uh, so that made me really happy, and these, uh, these folks were really super cool to work with, um, we, uh, we disclosed that, they were very,

22:44.120 --> 22:45.000
very nice.

22:45.180 --> 22:52.020
Um, but now moving on to, uh, Broken States, which is the SSH state machine to HD.

22:52.040 --> 23:02.020
Thanks, um, another fun thing about the, the SoftServe side, so that particular exploit, um, because it's using git LFS, you can, you can reference a raw file on disk, and you don't have to know your file location, you can use relative paths and stuff,

23:02.020 --> 23:13.600
but this works just fine for unauthenticated git access too, so if you're running SoftServe for read-only access, you can still exploit it, it just requires jumping through more hoops, because you can specify LD preload, LD load library, you can set LD library debug out in the past,

23:13.600 --> 23:24.360
there's a million ways you can, like, eventually get a file onto disk to then load, or to trigger a shell script, but just LFS was the quickest way, but like, yes, we're loading arbitrary code, so, it, write access to the repo is not a requirement to exploit SoftServe,

23:24.360 --> 23:33.060
and there's still about ten of those suckers hanging out on the internet right now that are exploitable, so, if you're quick, they're yours, um, kidding, but, um, so, I'll talk a little bit about the SSH state engine.

23:33.300 --> 23:38.720
So, SSH is like, incredibly complicated in terms of how it makes you go through these different states to get to each phase of the protocol.

23:38.900 --> 23:45.540
The stuff you're mostly familiar with is like, when you first connect to the port 22, you'll see like, SSH-2.0, uh, server banner, things like that.

23:45.540 --> 23:53.740
If you happen to send the same manner back to it, or you connect to dropper, then you'll get this big blob of stuff with null delimited strings, which have like, ciphers, and max, and algorithms, things like that inside of it.

23:53.820 --> 24:02.840
So, all that's kind of during the, uh, server version exchange, and the key exchange, um, the SSH daemons are very clear that they will only accept a certain range of message values for each state.

24:02.860 --> 24:10.760
So, before you've done the, uh, version exchange, you can't do the key exchange, before you do the key exchange, you can't do authentication exchange, and this is enforced two ways.

24:10.760 --> 24:13.760
The protocol itself has a range of values allowed for each state.

24:13.760 --> 24:18.560
So, values 1 through 49 are allowed in state 1, 0 to 49 in state 2, and so on.

24:18.560 --> 24:25.920
So, if you're trying to like, just open a channel, or open a shell, technically there's no even message handler for it, because it hasn't even configured the state handler to even accept that type of message yet.

24:25.920 --> 24:27.900
But that depends very much on the implementation.

24:28.280 --> 24:35.100
Uh, DropBear and OpenSH are really good at keeping a big command table, and when they go to another state, they just remove that command table handler for the previous state.

24:35.100 --> 24:37.860
So, there's really no way to like, accidentally call the wrong function pointer.

24:37.940 --> 24:40.280
Um, and that mostly works the way you expect.

24:40.640 --> 24:43.840
What's also interesting here is everything after the key exchange, of course, is encrypted.

24:44.160 --> 24:53.960
So, SH is kind of like TLS in a lot of ways, in that you have your normal, like, version exchange, key exchange, algorithm, Diffie-Hellman type thing, and then you have, like, your encrypted transport, and that's where all the fun stuff happens, like authentication,

24:53.960 --> 24:55.140
your banner, if you will.

24:55.140 --> 24:56.700
Like, have you ever seen a pre-auth banner in SH?

24:56.700 --> 24:59.960
It's actually being sent over the encrypted connection, not over the unauth connection.

25:00.160 --> 25:06.180
So, typically when you're talking about an SH banner, you're not talking about the version string, you're talking about the pre-auth big blob of data that it sends you when you try to authenticate.

25:06.460 --> 25:09.800
Um, so lots of cool stuff happening there, but you can see the state engine is pretty complicated.

25:10.260 --> 25:13.260
Um, what's also worth pointing out here is there's something called a larval session.

25:13.460 --> 25:19.320
So, that means you've successfully authenticated, or maybe not, and it's the state of your shell before there's a shell .

25:19.440 --> 25:24.520
So, effectively, if you haven't created a sub-process yet, you're in this kind of, like , larval state, and that's how the code generally references it.

25:24.520 --> 25:27.000
And that's important when we start getting into some of these other exploits.

25:27.440 --> 25:30.620
So, a historic example of where this has gone wrong is libsh.

25:30.740 --> 25:39.380
In 2018, uh, someone reported vulnerability where this library is used for both client and server side, same with OpenSH, same with DropBear, they kind of share the same code base for both halves of the protocol.

25:39.520 --> 25:45.780
Um, and if you sent the user-authenticated succeeded message from the client to the server, the server's like, oh, okay, cool, you're in, and that's fine.

25:46.080 --> 25:53.300
Um, there's still a bunch of these libsh informations out there that'll just drop you to a shell if you send user auth success, and of course, you know, shamble test for that and makes it easy for you to use it.

25:53.600 --> 25:56.260
Um, so we decided to take this up another level.

25:56.260 --> 26:00.600
Instead of just saying, let's just send a fake success message, let's just try to get a shell everywhere.

26:00.600 --> 26:12.040
Let's take every single part of the protocol transition and say, let's do half auth, let's do full auth, let's do a fake pubkey, let's do a password, let's do a password none, let's do, even before sh user auth command at all, and between every one of those attempts,

26:12.040 --> 26:13.200
we're going to ask you for a shell .

26:13.380 --> 26:14.480
We're just going to be like, how about a shell now?

26:14.480 --> 26:15.120
How about a shell now?

26:15.120 --> 26:15.600
How about a shell now?

26:15.600 --> 26:16.380
And how about now?

26:16.520 --> 26:17.520
Um, and it worked.

26:17.520 --> 26:21.580
Like, we got crap loads of shells from random devices because we asked them in weird states to give us a shell.

26:21.720 --> 26:25.840
So there's some out there where you don't even bother even starting the authentication process and it gives you a shell.

26:25.840 --> 26:28.840
There's some out there where you start the authentication process but don't finish, it gives you a shell.

26:28.840 --> 26:30.000
Like, it's all over the map.

26:30.000 --> 26:32.480
So, um, there's three good examples we talk about here.

26:32.480 --> 26:35.480
The first one is the digi transport, uh, gateways.

26:35.480 --> 26:39.240
They're mostly using like ICS environments, they're kind of like out in the field with hardened stuff.

26:39.240 --> 26:44.460
They act as like kind of the VPN router, if you will, for all the, all the juicy OT stuff you want to hack behind it.

26:44.600 --> 26:49.280
Um, so having remote admin to these means you basically have serial port access to all the stuff behind it, which is great.

26:49.280 --> 26:51.920
So if you want to like blow up pipelines, things like that, that's how you do it.

26:52.100 --> 26:53.840
Um, so the digi team was really cool.

26:53.840 --> 26:54.920
They were great to work with.

26:54.920 --> 27:00.120
Um, this device had already been like basically effectively legacy and retired, but it's still up for maintenance on screen patches.

27:00.160 --> 27:06.080
But they had to go find like the one developer who hadn't looked at this thing in five years and dust off their compiler and try to figure out how to build the damn thing and all that.

27:06.080 --> 27:10.380
And the funny thing about this is it ended up being an un, uh, an uninitialized variable in the SH engine.

27:10.900 --> 27:15.860
So it took us forever to repro, because we'd say, hey, we can get shells in like all these machines on the internet.

27:15.860 --> 27:18.560
Like here's a bunch of them, here's the serial numbers, like it's bad, go fix it.

27:18.560 --> 27:19.540
Like we can't repro it.

27:19.540 --> 27:20.600
I'm like , you got to be kidding me.

27:20.600 --> 27:21.660
Like just run the command.

27:21.660 --> 27:22.780
Like what are you doing wrong?

27:22.780 --> 27:25.840
Like it's run command, what's doing, it was not their fault of course.

27:25.840 --> 27:30.980
It's that when they were setting up the machine to test, they were logging in for the rest of the H first and setting up their monitoring on it.

27:30.980 --> 27:35.200
And then they'd run our exploit and it wouldn't work because the uninitialized variable had been set.

27:35.340 --> 27:37.440
So just one of those things was like freaking Heisenbug to repro.

27:37.440 --> 27:38.080
It took forever to fix.

27:38.080 --> 27:40.320
Anyways, so we finally got to the end of it, but the team was really cool.

27:40.320 --> 27:40.920
They're great to work with.

27:40.920 --> 27:42.780
They got a patch out even for this legacy hardware.

27:42.780 --> 27:45.140
So awesome to see them actually supporting older systems.

27:45.440 --> 27:48.560
Uh, then we found these real tech devices that are like branded all kinds of things.

27:48.740 --> 27:55.540
Netterbit, um, Netis, there's probably a good dozen vendors out there and they all have like different flavors of firmware from 2018 to 2023.

27:55.840 --> 27:57.240
And it's just like free shells everywhere.

27:57.240 --> 27:58.200
We don't even know who to report it to.

27:58.200 --> 27:59.480
So that's, there's a bunch out there.

27:59.620 --> 28:01.180
Um, yeah, have fun with that.

28:01.340 --> 28:05.340
Uh, we also ran across a bunch of Panasonic switches, but also a really weird set.

28:05.340 --> 28:07.060
And we had no idea who to report that one to either.

28:07.060 --> 28:09.000
Like the normal Panasonic thing wasn't the right fit.

28:09.000 --> 28:10.680
And so all the docs were in Japanese.

28:10.680 --> 28:11.740
We kind of gave up on that too.

28:11.740 --> 28:13.580
So we'll eventually figure out how to disclose that one.

28:13.580 --> 28:17.720
But there's a bunch of random Panasonic switches that'll just give you a shell pre-op as well through the same mechanism.

28:17.940 --> 28:19.400
Um, and this is just kind of the tip of the iceberg.

28:19.400 --> 28:21.240
We found another like 70 odd devices.

28:21.240 --> 28:22.540
We just haven't figured out where they are yet.

28:22.760 --> 28:29.140
Um, so, you know, basically take Shamble, throw it in your home network, throw it in your work network and you might just get random free shells out of crap through this stage transition.

28:29.280 --> 28:33.000
The only tricky bit here is you may have to specify a username that's not the default username.

28:33.000 --> 28:40.720
So if the device typically has like an admin or manager username, specify all the default admin usernames for the products and you'll be more likely to shake out some shells.

28:41.960 --> 28:44.780
So here's an example of the Netterbit NSL224s.

28:44.780 --> 28:46.320
These are really popular in Iran.

28:46.320 --> 28:51.120
So a huge portion of Iran uses these things and you just basically log in as, you know, whatever you like.

28:51.380 --> 28:54.600
Um, so in this case we're using the Shamble shell for it.

28:54.600 --> 29:01.900
We're just saying like brute force all the different session states and it logs us directly into it and it shows data, here's the firmware, all the info, things like that.

29:01.960 --> 29:03.000
So super straightforward.

29:03.420 --> 29:06.540
And here's an example of the Digitransport ICS gateways.

29:06.580 --> 29:07.220
Same thing.

29:07.220 --> 29:10.880
What I love about this is when you log in it says, welcome, your access is super.

29:11.060 --> 29:14.280
So I also have the, you know, the South Park voice in my head when I see that.

29:14.280 --> 29:15.260
So it's amazing.

29:15.960 --> 29:19.640
Um, with that, I would like to talk a little bit about the OpenSH landscape.

29:19.760 --> 29:28.980
So, you know, typically we think about like SSH being OpenSH and sure it's like 90% of us, it's 87% of all SSH in the world, but OpenSH isn't just OpenSH either.

29:28.980 --> 29:31.100
There's a lot of different flavors of OpenSH.

29:31.340 --> 29:41.840
So for folks who aren't super familiar, uh, OpenSH was forked from OSSH, which was forked from the original V1, um, you know, tattoo, um, version of SH back in the day.

29:41.980 --> 29:44.860
Um, but OpenSH wasn't designed for Linux.

29:44.860 --> 29:47.300
OpenSH was hardcoded for OpenBSD.

29:47.300 --> 29:50.840
Like they didn't want our dirty Linux paws all over their beautiful SH daemon.

29:50.840 --> 29:59.160
So eventually they conceded and said, you know what, you guys can, all you plebs can actually touch our beautiful SH code, but we're going to create a version of OpenSH just for you called OpenSH portable.

29:59.360 --> 30:09.960
So when you talk about OpenSH, you're really talking about the portable version of OpenSH, which has a compatibility layer that makes, um, all of us heathens be able to use the nice functions of VSD basically, uh, without all the pledge and cool things like that.

30:10.000 --> 30:13.240
But if you look at OpenSH portable, there's actually a bunch of variants of that too.

30:13.420 --> 30:17.860
So if you look at like who is molested OpenSH the most, we're going to start off with Apple.

30:17.880 --> 30:19.260
Apple was just light touch.

30:19.260 --> 30:20.120
They just gave a little hug.

30:20.120 --> 30:21.360
They didn't really do much to it.

30:21.420 --> 30:23.440
Uh, they did not do terrible things to OpenSH.

30:23.440 --> 30:31.240
They, um, added some changes for, um, let's see the key login, the endpoint event logging, uh, PKCS helper and keychain, things like that.

30:31.240 --> 30:33.040
Really straightforward, not terrible at all.

30:33.040 --> 30:35.920
Very happy that they did not destroy OpenSH.

30:36.080 --> 30:38.300
Um, they start looking at Debian and Ubuntu.

30:38.300 --> 30:41.740
They've got about 36 different patches on top of the core OpenSH code.

30:41.900 --> 30:45.260
Uh, and those patches make it libXE utils backdoor compatible.

30:45.620 --> 30:46.940
Um, among other things, right?

30:46.940 --> 30:51.040
But there's a lot of changes and those changes aren't getting the same scrutiny that let's say the rest of OpenSH code is getting.

30:51.040 --> 30:53.100
It's, it's basically linking it to all kinds of other libraries.

30:53.160 --> 30:54.820
It's the reason why it linked to system D.

30:54.940 --> 30:59.580
Um, there's a lot more attack service because of all those changes they put into the, those system patches.

30:59.840 --> 31:02.920
Now moving up to Red Hat, now you're like 60 plus different patches.

31:02.920 --> 31:05.020
So even, even bigger attack service.

31:05.020 --> 31:12.600
And, you know, hopefully they're auditing this stuff and everyone's looking at it because it's important because if you're hacking a Linux server, it's probably going to be either Debian, Ubuntu, or Red Hat based these days, right?

31:12.600 --> 31:15.800
Unless you're like, I use ARC, you know, you know, there's only a few of those out there.

31:15.920 --> 31:25.900
Um, so, um, if you're using, uh, you know, Debian, Ubuntu, Red Hat, Linux, et cetera, um, you probably have a ton of different patches on top of OpenSH that are not pure OpenSH, if you will.

31:26.060 --> 31:27.280
Uh, you may go pretty well.

31:27.280 --> 31:31.240
And then there's a thing called PKIX SSH, which I think probably a lot of folks haven't heard about.

31:31.240 --> 31:36.240
It was forked from OpenSH back in 2002 to support X.509 certificates and then FIPS code.

31:36.400 --> 31:46.480
So because it supports X.509 and FIPS, a lot of the networking vendors decided to use that instead of regular SSH, uh, to build out their products because they want to sell to the federal government and they want to use crusty old crypto protocols.

31:46.740 --> 31:48.520
Um, so there's a thing called PKI SSH.

31:48.520 --> 31:49.580
It forked in 2002.

31:49.620 --> 31:51.760
It mostly, it's almost like they hate each other.

31:51.760 --> 31:54.360
If you do, like, so, put it this way, we diffed all of it.

31:54.360 --> 31:59.580
We looked at, like, OpenSH mainline to every one of these forks and just read every single line of code for days and weeks.

31:59.580 --> 32:00.700
Well, that was my vacation.

32:00.700 --> 32:02.300
I just did that for hours a day.

32:02.460 --> 32:11.440
Um, but PKIX one is really funny because you'll see a change in OpenSH and then a change is written slightly differently in PKIX SSH and they oftentimes disagree.

32:11.640 --> 32:15.080
Like, once in a while they mostly match, like, if one equal this, if that equal that.

32:15.080 --> 32:17.120
But occasionally it's like, if not, one equal this.

32:17.120 --> 32:21.960
And it's like, so, there's probably some weird compatibility bugs because the changes weren't followed entirely.

32:22.020 --> 32:26.100
They obviously don't want to look like they're copying OpenSH, but they also can't not copy it and stay compatible.

32:26.100 --> 32:28.660
So, you can just, you can feel the rage between the two teams there.

32:28.660 --> 32:29.340
It's great.

32:29.420 --> 32:32.660
Um, I've never felt so much, like, animosity in a code diff before.

32:32.900 --> 32:36.220
Um, but finally, the, the really fun one here is Windows.

32:36.440 --> 32:39.700
So, Microsoft Windows, um, shipped OpenSH on Windows 10.

32:39.700 --> 32:41.980
Everyone's like, oh my god, I can actually type SSH and curl.

32:41.980 --> 32:44.580
I don't have to do all these stupid commands anymore to back to my Windows box.

32:44.580 --> 32:48.000
I can use the built-in, I did nice native Linux commands to back to my, my Linux boxes.

32:48.020 --> 32:48.940
And that was great.

32:48.940 --> 32:51.920
So, we love the fact that SSH clients on Windows, we can use them on all kinds of stuff.

32:52.120 --> 32:53.840
Um, there's also SSH server for Windows.

32:53.840 --> 32:59.800
And so, there's a fork for, uh, of OpenSH portable called OpenSH, um, under the PowerShell GitHub repo.

32:59.980 --> 33:01.740
And they just massacred it.

33:01.740 --> 33:03.660
There's like 350 files were changed.

33:03.660 --> 33:04.600
They ripped out everything.

33:04.600 --> 33:09.220
All those secure parts of SSH kind of just got put into the corner over there, uh, and, and deleted.

33:09.220 --> 33:11.460
And then it's like, if Windows do something totally different.

33:11.480 --> 33:12.940
So, they ripped out your support.

33:12.940 --> 33:18.040
They ripped out, um, the PrivSep stuff works totally different through a sub-process versus the fork, because there's no forks on Windows.

33:18.040 --> 33:21.180
Um, they, uh, logged to Windows Event Viewer.

33:21.180 --> 33:24.220
They logged, uh, they sent telemetry back to Microsoft for everything you do.

33:24.640 --> 33:26.900
Um, they still haven't bothered fixing Terrapin.

33:26.940 --> 33:28.780
Like, it just, it's a very different fork.

33:28.780 --> 33:35.340
So, if you're using Windows and SSH, either a client or a server , you probably want to pay attention to this next slide, which is, uh, let's see, this is what it looks like.

33:35.340 --> 33:36.400
Not super exciting.

33:36.460 --> 33:40.400
But, if you start looking through the OpenSH for Windows code, you can start looking at the telemetry callback.

33:40.400 --> 33:44.580
You can't disable this crap, unless you disable telemetry total on your machine.

33:44.640 --> 33:51.480
Every single connection going to your Windows, your SSH server on Windows, is sending your client version and server version back to Microsoft in the telemetry.

33:51.580 --> 33:56.260
So, every time you port scan your system, every time you run a Nessus scan against your Windows server, it's sending that info back.

33:56.260 --> 34:01.540
Every time you SSH directly from your Mac OS client or whatever it is to a Windows server, it's sending your version string back to them.

34:01.580 --> 34:06.560
So, Microsoft knows who you talk to, who knows who you shell into, it collects all those craps for default telemetry.

34:06.700 --> 34:14.920
It even collects telemetry for things that are part of an encrypted session, like things like authentication methods that are negotiated over the secure channel, that's also shipped off to telemetry.

34:15.120 --> 34:20.920
So, uh, you know, I know we're all good, you know, cool kids here and we disable telemetry in VS code, but like, have you done so in OpenSH?

34:20.920 --> 34:21.940
Probably not, right?

34:22.100 --> 34:28.480
Um, so it's worth digging out the diagnostics viewer where you can look at the telemetry data on Windows and seeing like all your SH stuff being shipped off to the cloud.

34:28.560 --> 34:29.880
Um, so, yeah.

34:30.420 --> 34:32.720
But the next thing we'll talk about is even worse.

34:32.860 --> 34:41.220
Uh, so there's this really key function, we talked about OpenSH portal being a, a compatibility layer to make it, um, work not on OpenBSD.

34:41.360 --> 34:44.680
So the pure OpenBSD people, you know, can, can give us their code.

34:44.860 --> 34:49.120
Um, one of the functions that they implemented was timing safe B comp, which is like you expect.

34:49.120 --> 34:55.120
It compares two binary blobs, are these identical, in a way that doesn't change based on how long the strings are, what contents they have.

34:55.120 --> 34:56.780
They, it can be consistent either way.

34:56.800 --> 35:00.960
This is to prevent side channel attacks, it's really clean, really code, it's only like four lines of code.

35:00.960 --> 35:04.520
Maybe take out the return in the int, in the variable, it's only three lines of code.

35:04.560 --> 35:06.500
It's really hard to, to break this, right?

35:06.500 --> 35:10.600
This is a super nice, great piece of code by, uh, you know, Damian, uh, Miller.

35:10.600 --> 35:12.000
It's great, it's perfect, it's beautiful.

35:12.100 --> 35:13.960
And then OpenSH for Windows comes along.

35:13.960 --> 35:15.760
And they made it Windows compatible.

35:16.860 --> 35:29.040
So, uh, Windows compatible means, uh, first they look for a back R and a back N, and they scrub out the back R, and so they said, they allied the fact that there's a back R back N, they treated it as if it was equal to a back N.

35:29.060 --> 35:31.060
But you can probably see there's some problems here.

35:31.600 --> 35:33.580
Um, we'll kind of highlight those real quick.

35:33.580 --> 35:37.120
First off, there's only two lines of code they added, and they introduced a ton of bugs.

35:37.120 --> 35:39.680
It's no longer timing safe, because they look one byte ahead.

35:39.920 --> 35:44.140
It's no longer, uh, secure, because they read one byte out of, out of band memory.

35:44.140 --> 35:48.640
They're actually reading the, the pointer plus one, not the pointer, which could be beyond the end of that particular variable.

35:48.680 --> 35:55.520
So for every back R back N sequence you have in the source buffer called by this function, you're actually going one byte out of the memory buffer and moving forward.

35:55.740 --> 35:59.240
And that, and then that value's being compared for your byte comparison.

35:59.420 --> 36:08.140
So if you know there's a lot of data at the end of your buffer, you can now just tell SH to not compare the bytes you thought you were comparing and now compare the bytes at the end of the buffer, which are typically a bunch of nulls or something more predictable.

36:08.340 --> 36:15.140
So there's a bunch of like really gnarly bugs that happen just because somebody decided their config parser didn't work with this function that wasn't designed to parse configs in the first place.

36:15.420 --> 36:17.240
Um, so it's, it's about as bad as it gets.

36:17.620 --> 36:21.060
So this function's used in every single packet that gets processed by SH.

36:21.140 --> 36:25.500
So every crypto buffer coming into it gets the SH comp or comp buff check on it.

36:25.620 --> 36:28.520
And, and basically it, it gets buggy really quick.

36:28.740 --> 36:30.960
Um, it's used for RSA signature validation, all this stuff.

36:30.960 --> 36:32.820
But the question was like, can we actually exploit it?

36:32.820 --> 36:33.600
And that's where it gets tricky.

36:33.600 --> 36:40.020
It's like the buffer that you can, that triggers the bug is the first buffer, first parameter, and the attacker doesn't control it directly.

36:40.160 --> 36:44.540
But if you do enough signing operations, you know, packets, eventually you get a buffer that has at least one back or back end in it.

36:44.540 --> 36:47.980
If you get to two, you get a little more interesting, but it's been really tough to actually get an exploit out of it.

36:47.980 --> 36:59.160
So of course, when we report to Microsoft, uh, their take is, you know, even though we've got $1 billion annual security budget, we've got 3,500 security professionals, and we backdoor your timing safe B comp code, you do not get a banana.

36:59.480 --> 37:00.560
So, we got nothing.

37:00.560 --> 37:02.220
They said, no, no, you guys don't get anything.

37:02.220 --> 37:02.880
We're not going to fix it.

37:02.880 --> 37:03.360
Have fun.

37:03.360 --> 37:04.960
Like, all right, well, we're going to talk about it at DEF CON.

37:04.960 --> 37:05.640
See you guys.

37:05.880 --> 37:06.680
Uh, so we did.

37:07.300 --> 37:07.800
Cool.

37:08.100 --> 37:10.920
Um, so that's the end of the, most of the content about SH.

37:10.920 --> 37:12.340
We're getting a little close to time.

37:12.340 --> 37:14.000
I want to make sure you have time for a little bit of questions here.

37:14.200 --> 37:16.640
Uh, we're going to talk a little about the shamble tool.

37:16.640 --> 37:19.820
So, uh, this tool is a research tool for SH limitations.

37:19.820 --> 37:26.020
It's a combination of like, a thing you can use today to scan your network, but a thing you can extend to find even more horrible bugs in SH and then share them with the world.

37:26.020 --> 37:31.620
So, uh, we, we'd like you to, uh, play with it, make it better, and, and rain hell upon vendors that do it wrong.

37:31.760 --> 37:46.180
Um, there's a lot of really cool interesting attacks against authentication, off-bypass, null-bytes, uh, ends up when you send a, uh, uh, SH password authentication, there's a, if you send a second parameter in addition to your password, that tells SH server that you want to change your password to that new value.

37:46.280 --> 37:49.940
So, you can imagine that when we're developing this tool, we might have accidentally changed a lot of passwords.

37:50.160 --> 37:52.560
Uh, so, be careful about that part.

37:52.560 --> 37:58.700
Uh, other than that, and it's kind of funny, it's like, oh, I got into all these machines, and then you scan them again, like, now I can't get into all those machines, what happened?

37:58.700 --> 38:00.820
Well, we accidentally sent all the passwords to a null-byte.

38:01.040 --> 38:06.620
Uh, there's also a lot of systems out there that will, uh, accept a null-byte as a password, and specifically a lot of honeypots.

38:06.620 --> 38:10.560
So, we doxed like 5,000 honeypots by accident because they accept null-byte passwords where nothing else does.

38:10.560 --> 38:12.840
It's like, oh, here's all the honeypots, that makes our lives a lot easier.

38:13.060 --> 38:16.300
Uh, a lot of the pre-auth state transition stuff, so you can extend those, make your own.

38:16.300 --> 38:17.000
It's kind of modular.

38:17.000 --> 38:18.980
It's not as cool as menisplate, but it does a lot of stuff like that.

38:18.980 --> 38:20.500
You can kind of add your own checks to register them.

38:20.860 --> 38:22.340
Uh, and then all the post session stuff, too.

38:22.340 --> 38:31.660
If you get a session, but you don't get a shell, you can use shamble to, like , bang on that session, try signals, jam keystrokes into it, generally do all the crap you don't want to do by hand that's really annoying, and eventually, um, do that.

38:31.660 --> 38:33.160
Plus, we added some timing analysis stuff, too.

38:33.160 --> 38:42.200
So, if you think there's, like, timing leak in a username , we've got some built-in functions that'll tell you, like, what's the, what's the statistical probability of this username being different than this other one based on a timing tag with really tight,

38:42.200 --> 38:43.340
uh, timing.

38:43.360 --> 38:47.000
So, shamble.com gets you all that stuff, and there's a whole bunch of stuff it does.

38:47.000 --> 38:50.300
So, I think, first off, I'll hand it to Rob to talk about all the vulnerability checks we do.

38:50.880 --> 39:03.340
So, uh, shamble will actually check for all the vulnerabilities we talked about, uh, over this, and they will not only check for you, it will give you proof, so you can run through, uh, it'll check for TCP forwarding, see if it can forward anywhere, it'll try different,

39:03.340 --> 39:07.760
uh, destinations, see what it can find, see if it's, uh , administratively prohibited for some.

39:07.940 --> 39:17.360
Uh, it will do generic environment injection, so it'll take, uh, environment variables, it'll control execution of processes, and we'll check to see if the output changes and things like that, uh, LD preload, stuff like that.

39:17.360 --> 39:21.900
Super useful, we'll say, oh, this is actually how it's vulnerable, this is what it can do, it'll tell you what to do next.

39:21.960 --> 39:29.700
Um, the software vulnerability that we talked about, it will, uh, it will give you the exact, uh, version and exactly the repo that it used and everything to get into there.

39:29.860 --> 39:40.040
Um, it will check the GOGS thing, that's the, uh, that's the, uh, ENV thing that looks vaguely like a backdoor, um, where it's executing ENV, and it'll try to give you commands, uh, command execution there.

39:40.460 --> 39:52.620
And, uh, it will check the ruckus password escape, that's the one where you can, uh, you can put backticks or, uh, dollar parens in the password, and, uh, it'll just give that to you and it'll say, and the report, you can actually see, uh, in the report,

39:52.620 --> 39:57.340
it'll say, okay, here's what I found, here's the references, and here's the proof, it'll actually give you the output that it found.

39:57.480 --> 40:07.960
Um, and you can just run that, they're automatically, it will automatically detect it, and it will continue, we're continually adding more vulnerabilities here, so, uh, stay tuned and run that on all your systems and tell us what you find.

40:08.580 --> 40:09.440
Well, thanks, Rob.

40:09.520 --> 40:19.760
And even in the last 24 hours since the code's gone live, we've got a lot of great feedback, feature requests, things like that, so we're really excited to keep expanding it, adding things like the, you know, keystroke masher, where it just, like, hits every possible keystroke trying to break out of the shell,

40:19.760 --> 40:25.380
like, the things you usually put your toddler in front of to make them give you shells, like, we'll just do that for you here, so, uh, who needs AI, right?

40:25.380 --> 40:39.020
Um, but in that sense, um, lots of cool stuff's already built in today, uh, to get started, you just run shamblescan-o, it generates a gigantic JSON file, um, if you run this across the whole internet, you get about 60 gigs of data, I don't know why I know that,

40:39.020 --> 40:48.640
but it's a lot of fun and you have millions of shells to go play with, uh, and then you can run the analyze command, it'll try to, like, bucket your results based on what cool things you found, so if it, if it's, like, a known backdoor, a known, uh, bug,

40:48.640 --> 40:51.260
it'll hopefully stick into its own little file and you can track them that way.

40:51.280 --> 41:00.940
We also report, like, vulnerabilities in the JSON, you can scrape out and import, uh, of course all this stuff's been, a lot of this has been linked into the run zero tool that we work on at, at our day job, and so it does a lot of these checks for you automatically,

41:00.940 --> 41:02.780
including grabbing all your keys, stuff like that.

41:02.800 --> 41:13.880
We're also looking at integrating it with, uh, honobox, a bad keys project to automatically identify host keys that have been compromised, and shambles is unique in that it's one of the very few tools that test all of your host keys, not just your first host key.

41:14.000 --> 41:22.900
So if your machine has an RSA key, an ECDSA, an ED25519, et cetera, we'll actually grab all the different host keys by grabbing them all and then test all those keys for weak keys and, uh, things like that.

41:22.900 --> 41:26.380
So we're still a little bit early for the bad key stuff, but we're, we're making progress.

41:26.580 --> 41:35.580
Uh, so an example, one of the neat things about shamble is that you can tell it to get into that larval session state without actually opening the process, which is a pain in the butt to do otherwise with the message client.

41:35.780 --> 41:39.700
So essentially you say, um, you know, shamble scan dash dash interact equal first.

41:39.700 --> 41:43.020
So interact with the first session you get and the interact auto equal nothing.

41:43.020 --> 41:46.920
Do not do any, do not do anything at all and just drop you straight to the interpreter shell instead.

41:47.000 --> 41:49.980
And then from that interpreter shell, you can like set any environment variables you want.

41:49.980 --> 41:52.580
LD debug equal all, LD preload, whatever you like.

41:52.600 --> 41:55.400
Uh, you can start sending signals to it even pre shell.

41:55.440 --> 42:00.100
And then when you want to drop a shell, you either type exec to run a command or you can do shell to get interactive shell.

42:00.100 --> 42:01.860
And at that point you can then mess with the shell itself.

42:01.860 --> 42:07.400
So it gives you kind of all the tools you need to manually mess with it and control E is how you open the shamble shell, uh, from the prompt there.

42:07.400 --> 42:09.420
Just so we don't conflict with SSH escape codes.

42:09.540 --> 42:12.740
And there's a million other things we can talk about, but we're going to keep kind of hammering on the code a little bit.

42:12.740 --> 42:14.600
And of course, happy scanning.

42:14.640 --> 42:18.340
And, uh, here's us just throwing out a slash 24 real quick, but it is pretty fast too.

42:18.340 --> 42:21.900
It'll just, it'll eat all your CPU and RAM just grinding away all your things.

42:22.200 --> 42:24.380
Um, and yeah, here's a bunch of bones we found.

42:24.420 --> 42:24.940
Thanks.

42:26.460 --> 42:28.880
We've got a couple of minutes, I think for questions, looks like.

42:29.100 --> 42:34.540
Uh, if you have a question, please come up to the middle standy thing and the mic so that everyone else can hear you

42:46.950 --> 42:46.990
.

42:48.850 --> 42:51.510
Um, the mic may not be on, I'm not sure.

42:51.810 --> 42:52.630
You want to grab this one instead?

42:52.630 --> 42:53.090
Yeah.

42:56.810 --> 42:57.730
Oh, sorry.

42:57.730 --> 42:58.510
You're still on mic.

42:59.270 --> 42:59.810
All right.

42:59.810 --> 43:06.870
So out of all the implementations that you have, that you've scanned, what is in your opinion, the most secure?

43:08.090 --> 43:10.490
Uh, the most seeker or the most insecure?

43:10.610 --> 43:11.830
The most secure.

43:11.830 --> 43:12.250
Okay.

43:12.250 --> 43:12.550
Yeah.

43:12.550 --> 43:18.770
The, yeah, two, you know, the, the TLDR of this entire talk is just use openness H98P1 and don't do anything else.

43:18.770 --> 43:20.130
Just don't roll your own.

43:20.130 --> 43:21.030
That's basically all you found.

43:21.030 --> 43:21.930
Just like any other crypto.

43:21.930 --> 43:23.610
Anytime you try to mess with it, you break it.

43:24.390 --> 43:25.110
Oh, thank you.

43:25.890 --> 43:27.190
Uh, any other questions?

43:29.190 --> 43:31.090
Does anybody recognize my shirt?

43:31.090 --> 43:33.210
It's, it's particularly nerdy.

43:34.710 --> 43:36.230
I'll be your friend if you know.

43:36.230 --> 43:37.010
Okay.

43:39.650 --> 43:40.370
Anybody?

43:40.710 --> 43:41.830
One more question?

43:42.250 --> 43:42.670
Yes.

43:42.670 --> 43:44.710
Did you guys try anything with Putty?

43:45.350 --> 43:48.070
Putty, P-U-T-T-Y client?

43:49.210 --> 43:49.890
Sorry.

43:49.890 --> 43:50.330
Yeah.

43:50.470 --> 43:57.470
It's a TTY client for windows called Putty SSH.

43:57.490 --> 43:57.670
Yeah.

43:57.670 --> 43:59.670
We didn't look at the code for it, but it's mostly client side.

43:59.670 --> 44:01.990
We really focused on all the, just the server side of invitations.

44:02.090 --> 44:03.990
I know Putty does a bunch of weird things with the keys.

44:03.990 --> 44:08.370
Like it has a weird preferences in which E-D-S-A keys uses, but we didn't get the chance to test Putty itself.

44:08.810 --> 44:13.810
There, there was an interesting, uh, not volume per se, but there was an interesting, uh, key generation issue with Putty this year.

44:13.810 --> 44:14.870
I need to go back and look at that.

44:14.870 --> 44:14.930
Yeah.

44:14.930 --> 44:15.150
Sorry.

44:15.150 --> 44:15.890
Another question?

44:15.930 --> 44:17.770
Does Shamble detects honeypots?

44:17.770 --> 44:20.210
Like how do you guys are detecting honeypots?

44:20.210 --> 44:24.370
And like, how Shamble detects honeypots?

44:28.130 --> 44:28.770
Okay.

44:29.370 --> 44:29.570
Yeah.

44:29.570 --> 44:33.910
So the short version is you, it just makes the TCP connection to whatever port and range you tell it to.

44:33.910 --> 44:36.190
And then it looks for that stage version, does the handshake, all that.

44:36.190 --> 44:37.850
So , um, that's about it.

44:37.850 --> 44:38.890
Unless I missed your question.

44:39.450 --> 44:41.510
How is it detecting honeypots?

44:41.530 --> 44:42.590
Oh, honeypots.

44:42.650 --> 44:43.030
Yeah.

44:43.030 --> 44:51.230
Um, so the funny thing is most honeypots, uh, have a bug where they accept a null-byte password and they just drop and they accept that where a real machine will never accept the null-byte password.

44:51.310 --> 44:56.390
So in a, in a, in an open-stage implementation, by default, if you put a null into the password field, it'll kick you back out.

44:56.490 --> 44:59.410
But most honeypots will accept you with a null-byte password.

44:59.410 --> 45:01.350
And that's an easy way to find like 5,000 of them.

45:01.350 --> 45:05.910
Um, we found a bunch of other ones through, uh, some of them accept any public key, no matter what key you give it.

45:05.910 --> 45:11.090
Other ones will take, uh, passwords that are, uh, outside the spec otherwise or m-mangled password requests.

45:11.150 --> 45:12.770
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:16.630
Cool.

45:16.690 --> 45:16.950
All right.

45:16.950 --> 45:17.470
And that's it.

45:17.470 --> 45:18.270
Thank you very much.

45:18.290 --> 45:19.010
Thanks everybody.

45:19.310 --> 45:20.510
Look for us if you have any questions.

45:20.510 --> 45:21.490
We're happy to talk to y'all.

