1 00:00:00,000 --> 00: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. 2 00:00:11,200 --> 00:00:12,620 Take it away. 3 00:00:13,840 --> 00:00:15,500 Thank you. 4 00:00:16,380 --> 00:00:21,340 So, welcome to my presentation, Silent Leaks, Harvesting Secrets from Shared Linux Environments. 5 00:00:21,340 --> 00:00:23,120 My name is Jonas Cernica. 6 00:00:23,440 --> 00:00:26,660 So, for today, so I'm... 7 00:00:27,320 --> 00:00:31,380 Okay, I was thinking I did an update, but it's okay. 8 00:00:31,540 --> 00: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. 9 00:00:44,040 --> 00: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. 10 00:00:54,420 --> 00:01:01,460 Then I'll speak about jailing and isolation systems, temporary file leaks, and a demo, and closing remarks, the conclusion. 11 00:01:02,580 --> 00:01:08,420 So, multi-user Linux environments is where you have multiple users with unprivileged... 12 00:01:12,740 --> 00:01:15,700 you are not privileged... you haven't... you don't have privilege... 13 00:01:17,320 --> 00:01:27,620 privileges, and mostly you find in hosting panels, dev servers, education labs, providers, and CTF infrastructure, maybe. 14 00:01:27,860 --> 00: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. 15 00:01:40,920 --> 00:01:44,740 You can do both ways. 16 00:01:44,860 --> 00:01:54,900 So, as an attacker goal, you have to discover secrets like database secrets, API keys, passwords, and other kinds of secrets. 17 00:01:54,900 --> 00: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. 18 00:02:06,780 --> 00:02:14,500 Process arguments leaks most of the time are leaked through this command, ps, which is a default... 19 00:02:15,140 --> 00:02:18,000 is default for each Linux installation. 20 00:02:18,460 --> 00: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. 21 00:02:34,800 --> 00:02:38,680 Why is this default behavior like you can use the command ps? 22 00:02:38,900 --> 00: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, 23 00:02:59,600 --> 00:03:06,840 so it's about a backward compatibility changing this behavior would break many tools, as I said earlier. 24 00:03:07,960 --> 00: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. 25 00:03:22,080 --> 00:03:28,360 One of the providers did a very quick fix in a few days, and it was very proactive. 26 00:03:28,360 --> 00:03:34,140 They told me not to put their name on the slides, but I can do the demo with them. 27 00:03:36,040 --> 00:03:42,160 To act responsibly, so I choose not to give names about the providers, but most of them have problems. 28 00:03:42,160 --> 00:03:46,240 You'll see in the examples, and then you'll see in the demo. 29 00:03:47,140 --> 00:03:53,200 So let's run the command in Linux ps au xww. 30 00:03:53,220 --> 00:03:57,140 It's au xww to take the full command and all the arguments. 31 00:03:57,140 --> 00:03:59,740 That's why I choose this. 32 00:04:00,900 --> 00: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. 33 00:04:16,180 --> 00:04:19,460 And let's see some data. 34 00:04:19,740 --> 00: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. 35 00:04:35,880 --> 00:04:42,400 Maybe most of you know about the web hosting providers, how it works and you get some SSH shell. 36 00:04:42,400 --> 00:04:48,440 If not, there are ways to get to run system commands on the Linux. 37 00:04:48,740 --> 00:04:57,880 So from another user I run the command that the ps au xww and I took this kind of information. 38 00:04:57,880 --> 00: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. 39 00:05:17,480 --> 00:05:22,000 So it's easy to wait for new users and take their passwords. 40 00:05:22,600 --> 00: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. 41 00:05:36,760 --> 00: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. 42 00:05:47,380 --> 00:05:52,160 And he is creating the home directory, public HTML and so on. 43 00:05:52,160 --> 00:05:57,860 So I can find his password on the leaked command arguments. 44 00:05:57,940 --> 00: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. 45 00:06:09,060 --> 00:06:09,920 Okay. 46 00:06:09,960 --> 00:06:17,060 Here another case, another web hosting provider, he's running as root, this will be the demo at the end. 47 00:06:17,700 --> 00: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. 48 00:06:31,580 --> 00:06:34,800 This case, you can trigger this exploit by your own. 49 00:06:34,800 --> 00:06:37,440 So you have to create a database backup. 50 00:06:37,440 --> 00: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. 51 00:06:46,320 --> 00: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. 52 00:06:54,920 --> 00: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. 53 00:07:01,300 --> 00:07:05,300 And you can grab all the databases from the hosting provider. 54 00:07:06,620 --> 00:07:14,380 So he was doing a backup restore with the user root just to don't have any problems. 55 00:07:14,380 --> 00:07:20,060 And he used the root user name to do the restoration. 56 00:07:20,460 --> 00: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. 57 00:07:33,420 --> 00: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. 58 00:07:44,120 --> 00: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. 59 00:07:52,160 --> 00:08:01,060 He put here the database name, database user, database password and you can grab it very easy with your user. 60 00:08:01,920 --> 00:08:02,560 Okay. 61 00:08:02,560 --> 00: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. 62 00:08:18,200 --> 00:08:25,600 Also a lot of hosting providers they are using containers or like docker, but not a lot. 63 00:08:25,600 --> 00: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. 64 00:08:36,540 --> 00:08:39,900 But you'll see that you can break that too. 65 00:08:40,560 --> 00:08:40,800 Okay. 66 00:08:40,800 --> 00:08:48,860 Jailing and installation systems, most of the hosting providers they are using this first two, cage FS and cage root. 67 00:08:49,040 --> 00: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. 68 00:09:09,900 --> 00:09:19,140 So now bug bounty time, I used to have to use this information and make some money. 69 00:09:19,900 --> 00: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. 70 00:09:38,140 --> 00: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. 71 00:09:50,900 --> 00: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. 72 00:10:01,390 --> 00: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. 73 00:10:17,770 --> 00:10:20,470 So outside the cage FS. 74 00:10:20,470 --> 00:10:26,450 So I was able to read any file from most of the users, but I combined with another exploit for that. 75 00:10:28,470 --> 00: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. 76 00:10:43,910 --> 00:10:45,250 Let me go back. 77 00:10:49,420 --> 00:10:51,260 I'm not sure it's not ‑‑ okay. 78 00:10:51,520 --> 00: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. 79 00:11:02,940 --> 00: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. 80 00:11:16,780 --> 00:11:20,900 Another problem was credential exposure via light speed. 81 00:11:20,900 --> 00:11:31,400 Light speed is an optimization software for ‑‑ so when you create isolation environments, you have problems with ‑‑ I don't know. 82 00:11:31,580 --> 00:11:39,060 You have problems that your websites can run much slower and so on. 83 00:11:39,060 --> 00:11:41,540 So they created light speed for caching. 84 00:11:41,540 --> 00:11:46,420 It's a caching technique for isolated systems for web hosting. 85 00:11:46,660 --> 00:11:52,880 And the major hosting providers are using light speed because they have thousands of users. 86 00:11:53,100 --> 00: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. 87 00:12:04,720 --> 00:12:05,200 Okay. 88 00:12:05,200 --> 00: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. 89 00:12:14,540 --> 00:12:19,480 And I reported this on 31 March and they on 3 April light speed already fixed this. 90 00:12:19,480 --> 00:12:22,220 That's why I can speak about this right now. 91 00:12:22,320 --> 00: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. 92 00:12:34,420 --> 00: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. 93 00:12:54,540 --> 00:13:00,180 So there were a lot of information in those files or gigabytes of files. 94 00:13:00,180 --> 00:13:06,840 I just look for a few kinds of information and just to prove that it is a big problem. 95 00:13:07,680 --> 00: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. 96 00:13:23,600 --> 00: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. 97 00:13:45,540 --> 00:13:47,820 I report this it's already fixed. 98 00:13:47,820 --> 00: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. 99 00:14:02,200 --> 00: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. 100 00:14:22,520 --> 00: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. 101 00:14:32,840 --> 00: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. 102 00:14:43,660 --> 00: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. 103 00:14:57,120 --> 00:15:05,560 It was very easily, it was very good, and it was very good isolated. 104 00:15:05,560 --> 00:15:13,040 But I found that they were installed scripts for each user with their passwords and so on. 105 00:15:13,040 --> 00:15:18,620 It was in a temporary directory under a random name and then main.php. 106 00:15:18,620 --> 00:15:27,240 So it was exposing credentials like WordPress passwords and other kind of credentials, not just WordPress. 107 00:15:28,080 --> 00:15:28,800 Okay. 108 00:15:30,000 --> 00:15:35,240 Let me go on the first demonstration. 109 00:15:35,720 --> 00:15:37,820 Oh no, this is not mine. 110 00:15:40,880 --> 00:15:44,740 There are multiple, 111 00:15:48,130 --> 00:15:50,890 I think it's this, yeah. 112 00:15:51,590 --> 00: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. 113 00:16:05,170 --> 00:16:10,890 I already, here, I already created the backup copy. 114 00:16:12,910 --> 00: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. 115 00:16:32,590 --> 00:16:42,450 So now I'll restore the database and let's see what I took from the output of the PS command. 116 00:16:44,870 --> 00:16:52,390 So here is the whole output and now I look for the root password from my shell. 117 00:16:55,950 --> 00:16:58,050 So here is the root password of my shell. 118 00:16:59,170 --> 00:17:01,890 Let me show you here. 119 00:17:02,210 --> 00: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. 120 00:17:27,570 --> 00:17:28,770 Here is it. 121 00:17:29,130 --> 00: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. 122 00:17:40,230 --> 00:17:45,850 Another example, it is for file leak, the second video. 123 00:17:47,830 --> 00: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, 124 00:18:12,530 --> 00:18:13,750 to a dump file. 125 00:18:15,750 --> 00:18:17,170 So let's see what's happening. 126 00:18:17,170 --> 00: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. 127 00:18:28,580 --> 00:18:35,500 Okay, the dump file which was under the user A and let's see what's in there. 128 00:18:35,880 --> 00:18:41,780 So we have data about the user B, the user password, the user B account and so on. 129 00:18:41,780 --> 00:18:44,960 So you can easily take this kind of data. 130 00:18:50,650 --> 00:18:59,680 Now, going back to my presentation, yeah, 131 00:19:07,980 --> 00: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. 132 00:19:25,440 --> 00:19:32,720 So security is not just about exploits, it's about assumptions, so don't make wrong assumptions about your system. 133 00:19:33,180 --> 00: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. 134 00:19:47,680 --> 00:19:49,120 That's all, thank you.