WEBVTT

00:00.000 --> 00:11.200
It is my absolute pleasure to introduce Jonas Cernica, who will be talking about Silent Leaks, Harvesting Secrets from Shared Linux Environments.

00:11.200 --> 00:12.620
Take it away.

00:13.840 --> 00:15.500
Thank you.

00:16.380 --> 00:21.340
So, welcome to my presentation, Silent Leaks, Harvesting Secrets from Shared Linux Environments.

00:21.340 --> 00:23.120
My name is Jonas Cernica.

00:23.440 --> 00:26.660
So, for today, so I'm...

00:27.320 --> 00:31.380
Okay, I was thinking I did an update, but it's okay.

00:31.540 --> 00:43.380
I'm an application security engineer for UiPath, and also I'm an AI security researcher, bug bounty hunter, former CTF player, and former entrepreneur.

00:44.040 --> 00:54.280
For today, I'll have a short introduction about multi-user Linux environments, how the process arguments are leaked through commands in Linux.

00:54.420 --> 01:01.460
Then I'll speak about jailing and isolation systems, temporary file leaks, and a demo, and closing remarks, the conclusion.

01:02.580 --> 01:08.420
So, multi-user Linux environments is where you have multiple users with unprivileged...

01:12.740 --> 01:15.700
you are not privileged... you haven't... you don't have privilege...

01:17.320 --> 01:27.620
privileges, and mostly you find in hosting panels, dev servers, education labs, providers, and CTF infrastructure, maybe.

01:27.860 --> 01:40.920
The assumption you have no root privileges, and you don't have to do the local privilege escalation, you just have a basic user with maybe an SSH shell, access, or a web shell.

01:40.920 --> 01:44.740
You can do both ways.

01:44.860 --> 01:54.900
So, as an attacker goal, you have to discover secrets like database secrets, API keys, passwords, and other kinds of secrets.

01:54.900 --> 02:05.080
Then you can fingerprint, you have to fingerprint the users or domain if you can do that, and then prepare for the lateral movement.

02:06.780 --> 02:14.500
Process arguments leaks most of the time are leaked through this command, ps, which is a default...

02:15.140 --> 02:18.000
is default for each Linux installation.

02:18.460 --> 02:33.880
Sometimes I found that I can cut in the prox prox directory any bid, but in some situations, not all the situations, and you can use the big rep in the shared Linux environments, like web hosting providers and so on.

02:34.800 --> 02:38.680
Why is this default behavior like you can use the command ps?

02:38.900 --> 02:59.600
Legacy of transparency, so the Linux was designed to trust multi-user environments for university or shared labs, and it was a good debugging and monitor way to do it for tools, and in this case, just in this case, it wasn't a security, it was a priority of the security,

02:59.600 --> 03:06.840
so it's about a backward compatibility changing this behavior would break many tools, as I said earlier.

03:07.960 --> 03:21.200
I will not name affected providers in this presentation, because, yeah, I reported these issues in early of April this year, and I want to give them more time.

03:22.080 --> 03:28.360
One of the providers did a very quick fix in a few days, and it was very proactive.

03:28.360 --> 03:34.140
They told me not to put their name on the slides, but I can do the demo with them.

03:36.040 --> 03:42.160
To act responsibly, so I choose not to give names about the providers, but most of them have problems.

03:42.160 --> 03:46.240
You'll see in the examples, and then you'll see in the demo.

03:47.140 --> 03:53.200
So let's run the command in Linux ps au xww.

03:53.220 --> 03:57.140
It's au xww to take the full command and all the arguments.

03:57.140 --> 03:59.740
That's why I choose this.

04:00.900 --> 04:15.880
You have to run it in a loop to take each, I don't know, you can put, you can make a loop, which at 100 milliseconds you run this command and take the output.

04:16.180 --> 04:19.460
And let's see some data.

04:19.740 --> 04:35.680
In one of the hosting providers, when you run this from one of your users, so you have just to register as a user, you have your web access, your website, you have web access shell or you have SSH shell, I don't know, they can provide this to you.

04:35.880 --> 04:42.400
Maybe most of you know about the web hosting providers, how it works and you get some SSH shell.

04:42.400 --> 04:48.440
If not, there are ways to get to run system commands on the Linux.

04:48.740 --> 04:57.880
So from another user I run the command that the ps au xww and I took this kind of information.

04:57.880 --> 05:17.400
Another user like test one here, he was installing his newly website, it was about WordPress and in the command it was linked the user name of the newly WordPress install and the password here as you can see.

05:17.480 --> 05:22.000
So it's easy to wait for new users and take their passwords.

05:22.600 --> 05:36.760
On another web hosting provider, this command was run by root, I redacted the first part of the output of the command ps because you figure out which provider it would be.

05:36.760 --> 05:47.380
But it was running by root and as you can see, the root is installing the new user test two and his password, this is the Linux user as you can see.

05:47.380 --> 05:52.160
And he is creating the home directory, public HTML and so on.

05:52.160 --> 05:57.860
So I can find his password on the leaked command arguments.

05:57.940 --> 06:08.940
So you figure out already that most of them they put passwords and important data in the arguments of newly installed websites and so on.

06:09.060 --> 06:09.920
Okay.

06:09.960 --> 06:17.060
Here another case, another web hosting provider, he's running as root, this will be the demo at the end.

06:17.700 --> 06:31.580
They run as root and they created the ‑‑ when I tried to ‑‑ to come back, the other two cases was about to wait for other users to come on the website and register.

06:31.580 --> 06:34.800
This case, you can trigger this exploit by your own.

06:34.800 --> 06:37.440
So you have to create a database backup.

06:37.440 --> 06:46.320
We'll create this temporary directory which I will show you in another slide that you can leak this one because it's readable by any user.

06:46.320 --> 06:54.660
You have to wait in the temporary directory and grab anything from there that is coming because this will be deleted in seconds, in milliseconds.

06:54.920 --> 07:01.300
And as well you can see in the process arguments that you have the root MySQL and the password of the root user.

07:01.300 --> 07:05.300
And you can grab all the databases from the hosting provider.

07:06.620 --> 07:14.380
So he was doing a backup restore with the user root just to don't have any problems.

07:14.380 --> 07:20.060
And he used the root user name to do the restoration.

07:20.460 --> 07:33.420
In another case, I know that all these cases have similarities, but they do in a way or another they do differently.

07:33.420 --> 07:43.240
So here he chose to run as root and put the database name, database user and the database password and you can leak it through other user.

07:44.120 --> 07:51.680
As well in another case, again the root is installing the new database for a newly user from the web hosting panel.

07:52.160 --> 08:01.060
He put here the database name, database user, database password and you can grab it very easy with your user.

08:01.920 --> 08:02.560
Okay.

08:02.560 --> 08:17.940
Now solutions for this would be to, I don't know, to install a new, to remount the proc directory so with high speed too, but it may break some tools and monitor debugging tools.

08:18.200 --> 08:25.600
Also a lot of hosting providers they are using containers or like docker, but not a lot.

08:25.600 --> 08:36.540
You can use the containerization, but I think it will cost a lot to do that, but most of the hosting providers they are using cage FS with cloud Linux.

08:36.540 --> 08:39.900
But you'll see that you can break that too.

08:40.560 --> 08:40.800
Okay.

08:40.800 --> 08:48.860
Jailing and installation systems, most of the hosting providers they are using this first two, cage FS and cage root.

08:49.040 --> 09:09.100
The others I didn't see, I did bug bounty on these problems and I found a lot of things, but most of the hosting providers which gives you the ability to look on their stuff and they have a public bug bounty program for their web hosting, they use cage FS or cage root.

09:09.900 --> 09:19.140
So now bug bounty time, I used to have to use this information and make some money.

09:19.900 --> 09:37.840
So escape, I used to escape the cage FS in a major hosting panel, but after I used that on their panel, I figured out that that escaping solution was working on all other hosting panels because it was a general problem.

09:38.140 --> 09:50.900
So I cannot speak about this one because I sent this problem to the vendor, but he didn't give me any clue when this problem will be fixed.

09:50.900 --> 10:01.310
I told them that I will speak at DEF CON about this problem, but maybe that's why they delayed the fix, I'm not sure.

10:01.390 --> 10:17.770
So I was able to find the binary in the cage FS that was executing in the ‑‑ not in the isolation environment, in the Linux itself.

10:17.770 --> 10:20.470
So outside the cage FS.

10:20.470 --> 10:26.450
So I was able to read any file from most of the users, but I combined with another exploit for that.

10:28.470 --> 10:43.910
Another way to create isolation was with chroot, and most of the chroot isolation they are using the file browser, which is a software written in Go.

10:43.910 --> 10:45.250
Let me go back.

10:49.420 --> 10:51.260
I'm not sure it's not ‑‑ okay.

10:51.520 --> 11:02.940
It's a software written in Go and it's a UI interface for the file system, so the user that has a website can access their files through this file browser.

11:02.940 --> 11:15.580
So I find an undocumented command on file browser to run commands, system commands, and that's how I escaped the chroot from one of the hosting panels.

11:16.780 --> 11:20.900
Another problem was credential exposure via light speed.

11:20.900 --> 11:31.400
Light speed is an optimization software for ‑‑ so when you create isolation environments, you have problems with ‑‑ I don't know.

11:31.580 --> 11:39.060
You have problems that your websites can run much slower and so on.

11:39.060 --> 11:41.540
So they created light speed for caching.

11:41.540 --> 11:46.420
It's a caching technique for isolated systems for web hosting.

11:46.660 --> 11:52.880
And the major hosting providers are using light speed because they have thousands of users.

11:53.100 --> 12:04.720
And in a lot of bug bounties programs, I found that if you execute a script and then read the proc ‑‑ I'm not sure why it doesn't work anymore.

12:04.720 --> 12:05.200
Okay.

12:05.200 --> 12:14.400
If you read the proc self file descriptor number 2, you will read the STD error log file which is from all the users.

12:14.540 --> 12:19.480
And I reported this on 31 March and they on 3 April light speed already fixed this.

12:19.480 --> 12:22.220
That's why I can speak about this right now.

12:22.320 --> 12:34.420
So what I found in bug bounty programs with this kind of problem, so I read that file and I find it was the full request like the response and the request that was sent to the server.

12:34.420 --> 12:54.020
So there you can find user name, password, when cookie was set for web servers, you can grab the cookie and the domain where you have to use that cookie or the authorization tokens from PayPal or other websites domain.

12:54.540 --> 13:00.180
So there were a lot of information in those files or gigabytes of files.

13:00.180 --> 13:06.840
I just look for a few kinds of information and just to prove that it is a big problem.

13:07.680 --> 13:23.600
Now I'll speak about temporary file leaks and poor file permission because when you install a new website or you are doing something on the disk, sometimes they create new files on temporary directories and those files are readable by anyone.

13:23.600 --> 13:44.880
So here it's an example of hosting provider which when you install that software, you have in temporary file directory, a directory then a log where you can find all these passwords and you can take control over the hosting panel.

13:45.540 --> 13:47.820
I report this it's already fixed.

13:47.820 --> 14:01.300
They fix it in a few days but I didn't speak with them because they didn't want to show to speak their name to a conference.

14:02.200 --> 14:22.480
Another example and this one will be in my demo, is when you are trying to create, to restore a database, you first create the restoration data, you first create the backup, then the backup will be named, will be placed on your space, on your public user.

14:22.520 --> 14:32.800
But firstly when it's created, it will be sent in temporary directory then deleted from them and it will be sent, I don't know, via e-mail or something like this.

14:32.840 --> 14:42.160
But if you, from another user, if you want to grab all these files, you can do it easily and you can read all the databases that are backup from the system.

14:43.660 --> 14:57.120
In another bug bounty program, it was about not web hosting necessary but they didn't have, I didn't have access to the proc directory, the PS command as well.

14:57.120 --> 15:05.560
It was very easily, it was very good, and it was very good isolated.

15:05.560 --> 15:13.040
But I found that they were installed scripts for each user with their passwords and so on.

15:13.040 --> 15:18.620
It was in a temporary directory under a random name and then main.php.

15:18.620 --> 15:27.240
So it was exposing credentials like WordPress passwords and other kind of credentials, not just WordPress.

15:28.080 --> 15:28.800
Okay.

15:30.000 --> 15:35.240
Let me go on the first demonstration.

15:35.720 --> 15:37.820
Oh no, this is not mine.

15:40.880 --> 15:44.740
There are multiple,

15:48.130 --> 15:50.890
I think it's this, yeah.

15:51.590 --> 16:05.050
So in this demo it's about our panel which is a web hosting software, which right now I create a backup copy here.

16:05.170 --> 16:10.890
I already, here, I already created the backup copy.

16:12.910 --> 16:32.510
And after that, when the backup is created, now I'm going to my shell, I'm on the user A, there is the user B, and I run this command, the PS AAUXWW in a loop, and I grab the content at 100 milliseconds.

16:32.590 --> 16:42.450
So now I'll restore the database and let's see what I took from the output of the PS command.

16:44.870 --> 16:52.390
So here is the whole output and now I look for the root password from my shell.

16:55.950 --> 16:58.050
So here is the root password of my shell.

16:59.170 --> 17:01.890
Let me show you here.

17:02.210 --> 17:21.850
As you can see, I trigger a backup copy of my database, then I try a restoration of the database and when I read the output of the command PS, I find the root password of my shell and I can take all the databases from that web hosting software.

17:27.570 --> 17:28.770
Here is it.

17:29.130 --> 17:40.170
And as you can see, it has the temporary file with random name and you can grab it from another user, it's readable and so on.

17:40.230 --> 17:45.850
Another example, it is for file leak, the second video.

17:47.830 --> 18:12.530
So here, here is just when you install a new website, you create a new website, you'll do the, let's see, I'll cut everything that starts with temporary A, A, W, B, C, E, I and every file that starts with that name, I'll cut and redirect to another file,

18:12.530 --> 18:13.750
to a dump file.

18:15.750 --> 18:17.170
So let's see what's happening.

18:17.170 --> 18:24.150
Right now I'm under the user A, so I try to hack the user B, which is the newly user created.

18:28.580 --> 18:35.500
Okay, the dump file which was under the user A and let's see what's in there.

18:35.880 --> 18:41.780
So we have data about the user B, the user password, the user B account and so on.

18:41.780 --> 18:44.960
So you can easily take this kind of data.

18:50.650 --> 18:59.680
Now, going back to my presentation, yeah,

19:07.980 --> 19:25.440
as closing remarks, so multi-user environments are full of unexpected leaks and maybe sometimes are devastating and can take everything from your, you have to give like databases and passwords.

19:25.440 --> 19:32.720
So security is not just about exploits, it's about assumptions, so don't make wrong assumptions about your system.

19:33.180 --> 19:46.500
So tools like PS or PGREP are trusted because they are standard, but in shared environments you can see that are not so, they can have a lot of problems, you can have a lot of problems with them.

19:47.680 --> 19:49.120
That's all, thank you.

