1 00:00:02,420 --> 00:00:04,840 Well, thank you for waiting. 2 00:00:05,160 --> 00:00:08,980 It was, uh, quite intense from the, the stage. 3 00:00:08,980 --> 00:00:09,840 All right. 4 00:00:10,380 --> 00:00:13,280 So, thank you very much for attending this talk. 5 00:00:13,320 --> 00:00:16,580 Uh, I hope you will find it, uh, enjoyable. 6 00:00:16,580 --> 00:00:22,920 It's, uh, it's a, it's a cool story to tell and there is a lot to cover, so buckle up. 7 00:00:27,220 --> 00:00:37,120 So over the past, uh, few years, the security industry, uh, you know, investigated a lot of different security incidents. 8 00:00:37,220 --> 00:00:45,720 But only a few of them were truly sophisticated, meaning something that was really different than what we used to be. 9 00:00:45,920 --> 00:00:57,680 We can talk about, for example, the SolarWinds case, the Lopetia attack, or even the 3CX, uh, supply chain attack last year. 10 00:00:58,000 --> 00:01:06,580 But today I want to talk about, um, another attack which surpasses even the most sophisticated we've seen before. 11 00:01:06,580 --> 00:01:21,920 This is, uh, an undercover operation that lasted almost three years, which is very impressive in terms of technical details, but also the social engineering aspect is very impressive as well. 12 00:01:22,180 --> 00:01:29,640 So I'm going to talk about the XE backdoor story, the undercover operation that set the internet on fire. 13 00:01:29,640 --> 00:01:39,620 And I'm pretty sure that by the end of this presentation, your definition of what is a sophisticated, uh, a sophisticated attacker is will be changed. 14 00:01:40,420 --> 00:01:45,080 So I'm Thomas Rocha, I'm a senior threat researcher at Microsoft. 15 00:01:45,080 --> 00:01:55,940 I've been working on the XE campaign when it came out by, uh, uh, Andres Freund, which is, uh, a colleague of mine, and we, we, we discovered the, the backdoor itself. 16 00:01:55,940 --> 00:02:03,580 I'm French, as you probably may have heard, and I'm living in Australia, so I'm, I'm good with the jet lag now because it's been a week in, uh, in Vegas already. 17 00:02:03,820 --> 00:02:11,220 Uh, if you want to learn more about my work, you can visit my website, securitybreak.io, or you can, you can also follow me on Twitter. 18 00:02:12,820 --> 00:02:17,440 What I will cover in this presentation, first, how the backdoor was found. 19 00:02:17,440 --> 00:02:22,020 Then I will talk about the long term operation and the timeline itself. 20 00:02:22,500 --> 00:02:27,620 I will then deep dive into the technical details, and we will discuss about some assumptions. 21 00:02:27,900 --> 00:02:33,720 And finally, I want to conclude this presentation of what it means for us, for the security industry. 22 00:02:35,540 --> 00:02:51,860 Okay, this story began on Friday, 29th of March, at exactly 851 minutes, and it was uh, a message sent by Andres Froon to the OSS security DL list. 23 00:02:51,860 --> 00:03:00,860 With the, the subject, backdoor in upstream exit, Libel ZMA leading to SSH server compromise. 24 00:03:01,480 --> 00:03:12,720 So that's pretty much around that time, when I saw the, the email and read the investigation, that I started to investigate more about the backdoor itself and how it was working. 25 00:03:14,060 --> 00:03:19,160 But before, I want to talk a little bit about Andres and how he found the, the backdoor. 26 00:03:19,160 --> 00:03:32,960 Because on the internet, there was a kind of a legend where everyone was saying that the backdoor was discovered because of a 500 millisecond and uh, for, from Andres that triggered the investigation. 27 00:03:33,260 --> 00:03:35,640 The reality is a bit different. 28 00:03:35,920 --> 00:03:48,000 Actually, what triggered the investigation from Andres was that he found that the SSH login in some of the tested, the testing he was doing was actually failing. 29 00:03:48,000 --> 00:03:56,360 So he decided to investigate a little bit more to try to understand why the SSH was, the SSH logins were actually failing. 30 00:03:56,740 --> 00:04:11,580 And he discovered that there was a substantial CPU usage during the SSH and he found out the 500 millisecond delay which he identified, identified later in the new package uh, XE. 31 00:04:13,820 --> 00:04:18,120 And he said that, he said itself, it was a bunch of coincidences. 32 00:04:18,120 --> 00:04:27,440 So if we, if we have a look to how he discovered the backdoor, first, he saw that there was some issue with the SSH uh, login. 33 00:04:27,500 --> 00:04:36,440 Then he decided to investigate and then he found uh, a little bit of uh, amount of CPU uh, using by the SSH process. 34 00:04:37,200 --> 00:04:46,000 So he decided to investigate a little more and he found out that this amount of CPU usage was used by the Libel ZMA. 35 00:04:46,620 --> 00:04:58,980 But then, that's now which is becoming a little bit crazy because he actually used some specific setup which led him to find the backdoor . 36 00:04:58,980 --> 00:05:09,680 First, he decided to choose a Debian unstable which at the time of the release of the, the backdoor uh, only this kind of Linux version was affected by the backdoor. 37 00:05:10,040 --> 00:05:12,200 Then he chose to use a specific flag. 38 00:05:12,200 --> 00:05:28,120 And without the flag, this flag, he wouldn't have found uh, the, the backdoor because he was actually tracing the process using Valgrind and Valgrind complaining, complained about uh, the, the processes because of the flag he was setting up before. 39 00:05:28,740 --> 00:05:40,780 So that's super crazy because thanks to that, he was able to investigate and to find out the high CPU usage was in the SSHD processes below get CPU ID. 40 00:05:40,860 --> 00:05:46,460 Keep that information in mind because it will be interesting and important for the next part of the presentation. 41 00:05:52,510 --> 00:05:58,150 But you may wondering, what the fuck is uh, exe, exe-utils package? 42 00:05:58,550 --> 00:06:10,370 So, the exe, the exe-utils package is a free software, an open source software which is dedicated for lossless data compression through SDMA algorithm and exe. 43 00:06:10,370 --> 00:06:20,370 It, it, it is maintained by Lasikolin which is the main maintainer of the backdoor of the, sorry, of the, of the package since more than a, than a decade . 44 00:06:20,430 --> 00:06:28,130 The backdoor has been found in Libel ZMA in the version of exe-560 and 561. 45 00:06:28,130 --> 00:06:34,430 And it was introduced by a mysterious user called Jiatan in February 2024. 46 00:06:34,830 --> 00:06:44,650 The, the package, uh, and the backdoor affected mostly uh, development version so it was not widely deployed when Andres found the backdoor itself. 47 00:06:44,650 --> 00:06:50,690 And Red Hat assigned the vulnerability CVE 2024-30-94. 48 00:06:51,290 --> 00:07:05,030 There is something interesting here because you may wondering as well, why the exe-utils package has in, uh, has in any relation with uh, SSH? 49 00:07:05,030 --> 00:07:06,350 Well, I'm glad you ask. 50 00:07:06,350 --> 00:07:20,870 Because actually, the exe-util uh, uh, backdoor uh, package is widely used in many Linux uh, distribution and it's a trusted open source component for pro- for compression uh, and any kind of uh, optimization. 51 00:07:22,150 --> 00:07:36,910 The exe-util is, has been used in the open source industry for years and which is interesting is that open SSH is using the exe-compression to reduce the size of transfer data when you are doing a connection. 52 00:07:37,930 --> 00:07:41,510 So, quite interesting target for an attacker. 53 00:07:43,270 --> 00:07:46,010 Okay, I want now to talk about the timeline. 54 00:07:46,010 --> 00:07:47,750 And it's a bit uh, heavy. 55 00:07:47,750 --> 00:07:53,570 So, what I did, I actually split the timeline into five different phases. 56 00:07:53,910 --> 00:08:03,250 The first phase, the first phase which I called initial involvement of GATAN from October 29, 2021 to June 2021. 57 00:08:03,270 --> 00:08:04,930 June 29, 2022. 58 00:08:05,730 --> 00:08:16,090 So, during this phase, the user GATAN started to get, started to gain trust into the exe uh, project and started to do some commit and to work a little bit more. 59 00:08:16,090 --> 00:08:31,950 Which is interesting is um, during that phase as well, there was, there were additional persona that was part of a kind of a pressure campaign against Lassie Collin, the main maintainer of the exe package. 60 00:08:32,430 --> 00:08:38,090 To move the member, the um, the maintainership to another user. 61 00:08:38,390 --> 00:08:48,510 So, some additional personnel, persona such as Jigar Kumar and Dennis Hance have been part of this pressure campaign to put the pressure on Lassie Collin. 62 00:08:48,790 --> 00:08:57,190 And in June 29 of 2022, Lassie Collin started to mention GATAN as a co-maintainer already. 63 00:08:57,530 --> 00:09:07,490 Then in phase two, which I call transition of mentorship from September 27 of 2022 to March 18 uh, 2023. 64 00:09:07,830 --> 00:09:18,590 During this time, GATAN continued to contribute to the project to gain trust with uh, with the, the main maintainer and to the project itself. 65 00:09:18,670 --> 00:09:29,270 On October 2022, GATAN was added to the Tukeni organization on GitHub, which is the organization uh, that released the exe package. 66 00:09:29,270 --> 00:09:33,130 So, and then additional event as well during this time. 67 00:09:33,130 --> 00:09:41,930 Then during phase three, which I call preparation for the attack from March 2023 to January 19, 2024. 68 00:09:42,190 --> 00:09:46,290 During this time, a bunch of information happened as well. 69 00:09:46,290 --> 00:09:52,690 First, GATAN uh, updates the Google OSS first to send bugs to his own email. 70 00:09:52,930 --> 00:10:02,110 Then, another persona, Hans Jensen, sends patches for GNU indirect uh, function features, which is quite important as well. 71 00:10:03,190 --> 00:10:14,690 And uh, and GATAN also disables uh, iPhone support during the OSS first build, which is quite important because it's a kind of uh, evading some, some security protections. 72 00:10:15,190 --> 00:10:25,450 And then during phase four, which I call backdoor insertion and distribution from February 23 uh, to March 28 of 2024. 73 00:10:25,830 --> 00:10:29,410 This is where GATAN started to release the backdoor. 74 00:10:29,410 --> 00:10:39,210 So, in February 24, GATAN merged hidden backdoor binary code in kind of test files, which are actually fake text, test files. 75 00:10:39,670 --> 00:10:49,010 And then he released the version 5.6.0 with an additional file that was not present in the GitHub repository itself. 76 00:10:50,190 --> 00:11:01,470 And in March 9, uh, GATAN committed uh, an update of the backdoor because there was a bug and then he released the version 5.6.1, which was backdoored as well. 77 00:11:01,550 --> 00:11:21,150 And then on the last phase, phase uh, phase number 5, which I call discovery and response from March 28 to March 30, this is where Andres found the backdoor, started to alert and to send the email with his own investigation and this is where internet was on fire as well. 78 00:11:22,750 --> 00:11:24,650 But there is something which is interesting. 79 00:11:24,650 --> 00:11:26,250 I talk about the pressure campaign. 80 00:11:26,250 --> 00:11:29,270 So let me give you a little bit more detail about that. 81 00:11:29,770 --> 00:11:34,030 Cause this is quite interesting from the social engineering aspect. 82 00:11:34,030 --> 00:11:44,790 So first, I mentioned that some additional personas were part of this pressure campaign to move the mentorship of the, of the backdoor to someone else. 83 00:11:45,090 --> 00:11:50,450 So in March, uh, in April 2022, Jigar Kumar sent a message. 84 00:11:50,570 --> 00:11:52,290 Patches spend years. 85 00:11:53,210 --> 00:12:02,650 In May 2022, Dennis Hance, the, the other persona, sent another message as well and said, I asked a question here a week ago and I have not heard back. 86 00:12:02,650 --> 00:12:04,890 It has not updated in over a year. 87 00:12:04,890 --> 00:12:07,030 Is there a plan for this thing in the future? 88 00:12:07,330 --> 00:12:13,350 Lassie Colleen, which at the time was getting all these messages from these personas and so on. 89 00:12:13,510 --> 00:12:16,670 Jiatan has helped me at least with exe-utils. 90 00:12:16,850 --> 00:12:20,230 And he might have a bigger role in the future. 91 00:12:20,850 --> 00:12:24,050 It's clear that my resources are too limited. 92 00:12:26,070 --> 00:12:29,090 In May 2022, Jigar Kumar and so on. 93 00:12:29,550 --> 00:12:31,750 Over a month and no closer to being merged. 94 00:12:31,750 --> 00:12:33,010 Not a surprise. 95 00:12:33,650 --> 00:12:35,590 Jigar Kumar sent another message. 96 00:12:35,590 --> 00:12:39,130 Progress will not happen until there is a new maintainer. 97 00:12:39,230 --> 00:12:42,850 The current maintainer lost interest or doesn't care to maintain anymore. 98 00:12:42,990 --> 00:12:44,250 Quite aggressive. 99 00:12:45,490 --> 00:12:48,950 Then on June 2022, Lassie Colleen and so on. 100 00:12:48,950 --> 00:12:55,870 My ability to care has been fairly limited, mostly due to long term mental health, but also due to some other things. 101 00:12:55,890 --> 00:12:59,770 Jiatan may have a bigger role in the future. 102 00:12:59,890 --> 00:13:09,790 And he mentioned also, and I think this is quite important in this case, he mentioned it's also good to keep in mind that this is a non-paid OB project. 103 00:13:11,090 --> 00:13:14,750 In June 2022, Jigar Kumar sent another message. 104 00:13:14,750 --> 00:13:16,510 Right now you shock your repo. 105 00:13:16,510 --> 00:13:19,510 Why wait until 5 4 0 to change maintainer? 106 00:13:19,510 --> 00:13:21,570 Why delay what your repo needs? 107 00:13:22,290 --> 00:13:24,110 Dennis Ant sends a message. 108 00:13:24,110 --> 00:13:29,190 Why not pass on mentorship for exe for C so you can give exe for Java more attention? 109 00:13:30,250 --> 00:13:32,610 And then Jigar Kumar sent another message. 110 00:13:32,610 --> 00:13:36,390 Jia, this is the first time he actually talked to Jia. 111 00:13:36,550 --> 00:13:39,030 Jia, I see you have recent commits. 112 00:13:39,030 --> 00:13:41,210 Why can't you commit this yourself? 113 00:13:41,390 --> 00:13:47,050 And then Lassie Colleen replied on June 2022, on the day 29. 114 00:13:47,730 --> 00:13:49,790 Jiatan may have a bigger role. 115 00:13:49,990 --> 00:13:52,930 He is practically a co-maintainer already. 116 00:13:53,870 --> 00:13:57,410 Some change in mentorship is already in progress. 117 00:13:57,950 --> 00:13:59,970 Mission accomplished. 118 00:14:00,650 --> 00:14:05,950 Jiatan is no part of the project and he has a lot of more right to contribute. 119 00:14:06,370 --> 00:14:13,290 Alright, so now I want to talk about the technical details and how the backdoor was deploying and how the backdoor works as well. 120 00:14:13,570 --> 00:14:19,270 So remember, I mentioned that the user Jiatan deployed two different test files. 121 00:14:19,270 --> 00:14:29,710 The first one was bad3corrupt underscore lzma2 dot exe and the second one was goodlarge underscore compressed dot lzma. 122 00:14:29,710 --> 00:14:44,090 And additionally, when he released the latest version, version 5.6.0 of the exe package, he shipped the version with an additional file called build2host dot m4. 123 00:14:44,090 --> 00:14:51,790 If you are not familiar with m4 files, it's a kind of macro file used for configuration during the compilation process. 124 00:14:51,790 --> 00:14:56,210 And this file was present in the release but not in the repository. 125 00:14:58,170 --> 00:15:03,250 So let me talk a little bit more about the build2host dot m4 file. 126 00:15:03,570 --> 00:15:07,530 And I will focus here on the version 5.6.0. 127 00:15:07,650 --> 00:15:23,010 So what you see on the screen is just the malicious part of this file, just to focus on what it is exactly doing, but imagine that this file is super big with a lot of different configuration and a lot of legitimate actions. 128 00:15:23,510 --> 00:15:28,450 So the ones that you saw, you see on the screens, are only the malicious part. 129 00:15:28,770 --> 00:15:46,590 So first, you can see there is a variable called glam config make, with a grep, which actually looks for one of the malicious test files that have been released, and specifically the bad3corrup underscore lzma2 dot exe. 130 00:15:46,830 --> 00:15:50,790 Then we have, in number two, two additional variables. 131 00:15:50,790 --> 00:16:05,710 The first one, which is the trtool, trtool translate which is basically doing a kind of a substitution algorithm for part of the backdoor, of the file itself, the bad3. 132 00:16:05,710 --> 00:16:20,970 And the second one is actually showing the file, the test file, and making a sed to retrieve the extension of this file, exe, which will later be used as a common line. 133 00:16:21,210 --> 00:16:28,630 And as you can see, the translation of this piece of screen is the cat at the end of the presentation. 134 00:16:28,630 --> 00:16:42,350 So basically, transforming the file itself and decompressing using exe, the file which has been deobfuscated kind of using tr. 135 00:16:45,800 --> 00:16:57,940 So here you have a look of what was the original bad3corrup lzma2 file before the decryption, the, the, the, the, the substitution and the, the decompression using exe. 136 00:16:57,940 --> 00:17:02,280 And you have the malicious script on your right. 137 00:17:02,500 --> 00:17:06,760 So if you have a look to this malicious script, there is some interesting information here. 138 00:17:06,760 --> 00:17:13,380 So first, I, I like to comment, which is actually an exact decimal string. 139 00:17:13,520 --> 00:17:24,040 So today, we still don't know what is exactly this string, but I believe, because in version 5.6.1, this exact decimal string was not the same. 140 00:17:24,120 --> 00:17:28,780 So I believe this string was potentially related to a kind of a versioning number. 141 00:17:29,540 --> 00:17:35,300 Then we have a bunch of, uh, head command which are used to manipulate input data stream. 142 00:17:35,380 --> 00:17:54,580 And at the end, we have the stash3 and backdoor extraction because in the bad3corrupt, uh, uh, in the, in the bad3corrupt lzma and the second file, the goodlargecompressed lzma, there is the next part of the, of the, the release of the backdoor and also the decompression of an object. 143 00:17:54,580 --> 00:17:56,080 I will come to it later. 144 00:17:56,480 --> 00:18:04,840 I just give me, let, let me give you a look, a deeper look of what the file, what the script is doing to release the next part. 145 00:18:05,140 --> 00:18:08,760 So first, is decompress the second malicious file. 146 00:18:08,760 --> 00:18:13,720 Remember, the second test file, goodlarge underscore compressed dot lzma. 147 00:18:13,720 --> 00:18:19,320 That cons, contains the stash3 and the binary backdoor. 148 00:18:19,480 --> 00:18:25,280 It remove a, a, a bunch of junk data and unus byte, cause the file is a bit obfuscated. 149 00:18:25,280 --> 00:18:29,000 There is again a custom substitution cipher using TR. 150 00:18:29,260 --> 00:18:35,500 And then, all the, the deciphered data are decompressed again using Xs. 151 00:18:35,680 --> 00:18:45,480 Which lead to the stash3, which is another script, which is doing a bunch of checking during the compilation process. 152 00:18:45,480 --> 00:18:49,700 So let me walk through some of the checking this stash3 is doing. 153 00:18:49,800 --> 00:18:52,900 First, it's checked for the iPhone support. 154 00:18:52,920 --> 00:18:55,260 Remember, previous commit, we discussed about it. 155 00:18:55,260 --> 00:18:57,560 Keep that in mind for the, for the next part. 156 00:18:57,640 --> 00:19:05,780 Then it verify CRC source file, CRC64 underscore fast C, and CRC32 underscore fast C. 157 00:19:05,780 --> 00:19:10,080 For require iPhone code, because the backdoor require this feature. 158 00:19:10,600 --> 00:19:12,520 There is a bunch of multiple checks. 159 00:19:12,520 --> 00:19:24,500 It verify the version of the Linux system, uh, validate the GCC comp, compiler, check for the previous two test file, because if the two test file are not present, there is no need to continue to deploy the backdoor. 160 00:19:24,500 --> 00:19:26,040 So it's a kind of protection. 161 00:19:26,040 --> 00:19:30,140 It ensures position independent code. 162 00:19:30,500 --> 00:19:37,280 And also, it extract the backdoor from the, the test file, good large compressed dot LZMA. 163 00:19:38,680 --> 00:19:51,680 And this backdoor, ex, uh, extracted from this file will be embedded into the, the object file, libLZMA LA dash CRC64 dash fast dot O. 164 00:19:51,860 --> 00:20:10,760 Then, there is a modification of a function, isArchExtensionSupported in CRCXX86CLMUL dot H, and it replaces getCPUID with two underscore, with getCPUID with one underscore. 165 00:20:11,820 --> 00:20:20,860 Remember getCPUID was where address trust the execution of the backdoor and the amount of CPU usage. 166 00:20:27,800 --> 00:20:34,580 So I want to talk a little bit about the backdoor extraction itself, because it's quite interesting how the attacker did it as well. 167 00:20:34,720 --> 00:20:58,140 So in the code, there is a, a piece which is using the AWK func, um, tools from Linux, and this is actually doing like a kind of a RC4 like algorithm to decrypt the payload itself that will be later stored into the libLZMA LA CRC64. 168 00:20:59,260 --> 00:21:01,520 So quite interesting to see that as well. 169 00:21:03,480 --> 00:21:10,020 So, to recapitulate a little bit the compilation process, because I know it could be quite uh, quite complex. 170 00:21:10,020 --> 00:21:19,160 So first we have the execution of the macro file, the build to host dot info, which is executed and subsequent scripts are also executed. 171 00:21:19,680 --> 00:21:25,560 It run all the checks, and it create the make file if previous conditions are met. 172 00:21:25,560 --> 00:21:31,400 Because there was a bunch of information, if all the conditions are not met, then the backdoor is not released. 173 00:21:31,740 --> 00:21:42,040 Then during the make process, there is a backup of the original file, which has been backdoor, and libLZMA LA CRC64 fast dot O. 174 00:21:42,040 --> 00:21:55,560 There is a backup because if something, something goes wrong, the backdoor itself, I mean the, the code itself can push back the original file and so there is no track into the final release of the exe util package. 175 00:21:55,900 --> 00:21:58,800 There is also some specific compilation flags. 176 00:21:58,880 --> 00:22:02,580 I think, I think resolvers run at startup. 177 00:22:02,980 --> 00:22:09,360 Modification of the file CRC64 fast dot C and CRC32 fast dot C. 178 00:22:09,360 --> 00:22:23,580 And then finally, compilation, linking stage, manipulation and cleanup because the attacker did well, they also have a bunch of clean, cleaning up to avoid any forensic investigation or further, further investigation. 179 00:22:23,680 --> 00:22:32,640 And then at this point, we are here, malicious libLZMA is incorporated into the compiled libLZMA. 180 00:22:34,360 --> 00:22:39,340 So now I want to talk a little bit more about the backdoor itself and some of the functionalities. 181 00:22:39,340 --> 00:22:50,940 So first it's using the iFunc feature, which allows for dynamic resolution of function implementation during the run time, meaning it can load some specific feature at the run time. 182 00:22:50,980 --> 00:23:02,300 And actually the backdoor hijacks the iFunc resolver to allow the modification of the global offset table, which, which is a kind of a table with address to some specific functions. 183 00:23:02,900 --> 00:23:13,600 And here on the screen, what you can see is actually the malicious get CPU ID that will trigger the backdoor and continue the execution to the global offset table hijack. 184 00:23:15,400 --> 00:23:27,240 Another interesting feature about the backdoor is the usage of DL audit to set up the hook and to bypass Railroad and to intercept also redirect function, function call. 185 00:23:27,240 --> 00:23:36,880 If you are not familiar with Railroad, it's a kind of a memory protection space to avoid, uh, to avoid to have some, some space that could be vulnerable for some vulnerability exploitation. 186 00:23:37,000 --> 00:23:47,000 So what it is doing here, so first it's checking that the loaded target process is SSHD, because remember, it is our target here. 187 00:23:47,580 --> 00:23:57,440 And verify that the share library, and specifically Libel ZMA, because this is the, the, the, this is where the backdoor is loaded, is already present. 188 00:23:57,900 --> 00:24:02,520 Then it set up the DL audit structure to start the audit mechanism. 189 00:24:02,780 --> 00:24:09,640 And during the dynamic linking, so think about all these steps, uh, doing, doing the, the loading. 190 00:24:10,100 --> 00:24:12,200 It resolve and bind symbols. 191 00:24:12,200 --> 00:24:19,900 And then, the DL audit symbol function is called by the linker whenever a symbol needs binding. 192 00:24:19,900 --> 00:24:31,660 And if all the conditions are met, then it set the backdoor to the install hook function to install the, the hooking function that the payload will need later. 193 00:24:33,860 --> 00:24:42,120 There is also the global offset table, uh, redirect, which I mentioned is a kind of a table with a function address. 194 00:24:42,400 --> 00:24:53,600 And in that case, at the run time, the backdoor will manipulate this pointer into the global offset table to redirect codes to the main malware function. 195 00:24:56,000 --> 00:25:09,340 And if you have a look to the investigation, if you have a look to the, to the running at this time, everything will look like it's been called through the CPU ID functions. 196 00:25:12,450 --> 00:25:17,570 On top of that, there is additional evasion mechanisms and kind of obfuscation. 197 00:25:17,570 --> 00:25:20,270 First, there is a string obfuscation. 198 00:25:20,310 --> 00:25:26,030 In that case, what the backdoor is doing is looking for a tree structure. 199 00:25:26,510 --> 00:25:33,350 A tree structure is basically, uh, a corresponding reference between a string and a number . 200 00:25:33,350 --> 00:25:41,090 And what the backdoor is doing is looking for a specific number to retrieve the strings it needs for the execution of the payload. 201 00:25:42,430 --> 00:25:52,570 So if you, it's kind of a, if you are familiar, it's kind of API, API hashing, where you are retrieving the function code, uh, based on a specific hash. 202 00:25:52,630 --> 00:26:06,630 And in that case, the sample, the payload is, is looking for some specific string and for example, 0x1d0 is for RSA public decrypt, which is one of the function. 203 00:26:06,670 --> 00:26:14,050 Or for example, for 0x300 for the ELF header, which is used for the deployment mechanism as well. 204 00:26:14,290 --> 00:26:21,490 And you have some of the strings that was extracted by the backdoor and needed for the rest of the execution. 205 00:26:23,970 --> 00:26:31,970 So as I said, there is function hook that have been added by the, by the, by the payload itself. 206 00:26:31,970 --> 00:26:49,510 So first, what it is, what it, what it is doing, it's actually retrieving obfuscated string from the tree structure and one of the string which is important here are the RSA public decrypt function, which is a hook and the RSA get zero key function, which is also a hook. 207 00:26:50,030 --> 00:27:00,470 These two function are used in the latest SSH server version and are called when an RSA certificate is configured, is using for the authentication. 208 00:27:00,470 --> 00:27:02,570 Remember that because this is important. 209 00:27:02,790 --> 00:27:18,070 And the last function which have been hooked is the EVP PK set one RSA, which it's a little bit weird because it's not used in the latest SSH version, but probably that it has been set up for compatibility or probably for a specific environment. 210 00:27:20,910 --> 00:27:26,450 There is a bunch of other checks and evasion used by the sample, uh, by the payload. 211 00:27:26,610 --> 00:27:28,090 Here, there is an overview. 212 00:27:28,090 --> 00:27:39,030 So first, as we saw, it's, it's checks that the current process is well SSHG because there is no need to deploy the backdoor if we, if we are not running, uh, if SSHG is not running. 213 00:27:39,370 --> 00:27:42,030 It check for a potential kill switch. 214 00:27:42,030 --> 00:27:43,890 So this one is not very clear. 215 00:27:43,950 --> 00:27:52,450 This is a string that was present into the malware itself, the payload, but it's not very clear what's the goal, what was the goal of this string. 216 00:27:52,450 --> 00:27:55,810 Some researcher are thinking that it could be like a kind of a kill switch. 217 00:27:55,810 --> 00:28:03,810 If the backdoor see the, this, uh, strings into the, the environment, the memory, then it will not run. 218 00:28:03,810 --> 00:28:05,430 Potentially a kill switch. 219 00:28:05,470 --> 00:28:12,930 It also abuses the legit LZMA alloc function for memory allocation, which is required by the payload at some point. 220 00:28:12,970 --> 00:28:28,830 And there is also, it is, the backdoor is also hooking the logging function, meaning for every authentication through the backdoor, nothing will be logged into the, into the log of the machine. 221 00:28:29,990 --> 00:28:35,250 So that means it's also more difficult for forensic investigation and incident response. 222 00:28:35,250 --> 00:28:45,350 And there is a bunch of other advanced functionality such as encryption, anti-replay, it also embeds its own tiny embedded disassembler which is required at some point as well. 223 00:28:47,530 --> 00:28:50,790 But how the, how does the backdoor works really? 224 00:28:51,310 --> 00:28:55,510 So remember I said there is, uh, three main function that have been hooked. 225 00:28:55,510 --> 00:29:01,550 And which is interesting as well, is that the backdoor embeds three main function to be triggered. 226 00:29:01,550 --> 00:29:20,450 To trigger this function, there is kind of magic number, actually three magic number, and there is an operation which is used by the backdoor itself, which is magic one multiplied by magic two, plus magic two, which, which will give us the common number that will be triggered by the payload itself and the backdoor. 227 00:29:21,050 --> 00:29:29,810 So the first one, command zero and command one, is actually an SSH authentication bypass using root login. 228 00:29:29,930 --> 00:29:35,010 Second one is a remote code execution via systemd, cmd2. 229 00:29:35,010 --> 00:29:42,270 And the third one is, uh, cleaning a closed pre-authentication that have been previously opened. 230 00:29:42,410 --> 00:30:02,050 And if you pay attention to the, to the diagram below, to trigger this specific, uh, command, the attacker have to embed the payload into an RSA certificate that will be read by the, by the backdoor server during the authentication. 231 00:30:02,050 --> 00:30:04,050 And then there is a bunch of decryption. 232 00:30:04,050 --> 00:30:20,390 Of course, to exploit this specific backdoor, there is an upcoded certificate used, so that means only the attacker itself can login to the compromise server because he already have the private key. 233 00:30:22,710 --> 00:30:36,130 So to give you a little more details of how works the certificate payload, so you have here a kind of an overview of what is inside the certificate itself. 234 00:30:36,230 --> 00:30:45,990 So first, this certificate is used to the connection to the SSH, uh, to the SSH, uh, process to the backdoor server. 235 00:30:45,990 --> 00:30:54,450 Then there is an exchange of the public key, and this public key, there is also a SHA256 which is calculated as well. 236 00:30:54,450 --> 00:30:57,550 So let me give you an overview of the certificate itself. 237 00:30:57,610 --> 00:31:03,530 First, if you have a look, it's a normal RSA certificate, but there is some interesting information. 238 00:31:03,830 --> 00:31:12,070 In the IV, I call that the IV because it's used later, the, this IV is actually the magic numbers. 239 00:31:12,070 --> 00:31:21,690 Remember, the magic numbers are used to calculate the common number that will be interpreted by the, the server and, and the, the backdoor itself. 240 00:31:21,750 --> 00:31:35,270 And then, in the modulus N, uh, payload, in the, in the modulus N part of the RSA certificate, there is the payload which is encrypted in SHA20, 20, uh, SHA20, sorry. 241 00:31:35,510 --> 00:31:49,290 And this payload is decrypted using the outcoded ED448 public key that has been exchanged during the initiation of the connection, but only with the first 32 byte. 242 00:31:49,290 --> 00:31:59,970 And it's also using the IV, which are the magic numbers used, outcoded into the, the malicious RSA key, to decrypt the payload. 243 00:32:00,150 --> 00:32:04,150 Then, in the decryption of the payload, we have two main parts. 244 00:32:04,170 --> 00:32:13,990 The first, which is the signatures, which have been verified by the payload to be sure this is well, this is well the attacker that has been trying to connect. 245 00:32:14,030 --> 00:32:18,170 And we have the payload itself, which have been executed. 246 00:32:18,570 --> 00:32:25,010 And the signature is generated with the CMD value, which have been calculated. 247 00:32:25,350 --> 00:32:29,950 A five byte flag, which we don't know at this time what is it exactly. 248 00:32:30,150 --> 00:32:37,450 The payload itself, and the SHA256 that have been calculated from the ED448 signature. 249 00:32:37,610 --> 00:32:45,310 So a bunch of mechanisms to avoid also, uh, the replay of the certificate and to investigate a little bit more. 250 00:32:45,310 --> 00:32:48,510 And at this point, JITAN is in. 251 00:32:50,210 --> 00:32:54,650 So there is a small, um, let me show you. 252 00:32:58,470 --> 00:33:03,650 I did a small, uh, demonstration using, I 253 00:33:08,190 --> 00:33:17,770 did a small demonstration using, uh, a payload, using, uh, someone reused, um, uh, recoded, actually, the, the backdoor. 254 00:33:17,770 --> 00:33:18,710 So I reused this code. 255 00:33:18,710 --> 00:33:22,470 So on, on the right, you have the target, which is the attacker. 256 00:33:22,470 --> 00:33:31,890 So what I did here, uh, recompiled the backdoor itself with my own certificate, so I can reuse the code and authenticate like if I, like if I was the attacker. 257 00:33:31,890 --> 00:33:34,170 So you have the target on your right. 258 00:33:34,210 --> 00:33:52,650 On the, on the bottom you have the logs, because some researcher found that if you activate the verbose mechanism in the, in the logs and the configuration of SSH, there is a logging feature, uh, that appear and then there is some track, some trace into the, 259 00:33:52,650 --> 00:33:53,670 into the logs. 260 00:33:54,230 --> 00:34:01,270 So what I'm using here, I'm actually running the backdoor against my server, which I've been compromised. 261 00:34:01,390 --> 00:34:12,930 And here you can see, there is, what I did here is extracting some of the components that have been used to generate the RSA certificate used to authenticate to the compromised server. 262 00:34:13,530 --> 00:34:24,550 And as you can see here, you can see the OSCE, the SHA-256, the different magic number, the magic command, in that case it's number two, so I'm using the RCE, remote code execution. 263 00:34:24,870 --> 00:34:29,730 And then we have the certificate that have been sent to the compromised server. 264 00:34:29,730 --> 00:34:39,870 And if you look to the target here, I've been written a file called it's me, and that have been executed by, uh, the certificate itself. 265 00:34:39,870 --> 00:34:47,010 And this payload was actually part of the RSA, uh, key that are sent to the mal- to the compromised server. 266 00:34:47,770 --> 00:35:00,150 The second one is a, um, is a remote code execution as well, just to, uh, have, uh, a reverse shell and to be able to, uh, authenticate and to do some action onto the mali- onto the compromised server. 267 00:35:05,550 --> 00:35:06,310 So, 268 00:35:33,790 --> 00:35:35,970 okay. 269 00:35:42,780 --> 00:35:44,720 Okay, sorry about that. 270 00:35:45,600 --> 00:35:49,520 Okay, so you may wondering who is behind, uh, this attack. 271 00:35:49,600 --> 00:36:02,120 So, as I, as I discussed at the beginning, there was multiple personas involved into the, into the deployment of the backdoor for the pressure campaign against LaCie calling. 272 00:36:02,120 --> 00:36:08,340 So, remember, I talk about Jigar Kumar, Dennis Ants, and Ants Jensen, and Jiathan as well. 273 00:36:08,520 --> 00:36:25,140 So, what I did here, I wanted to know if, because we already had this, their, their email address, also their user name, and I wanted to understand if there is some connection or if the specific email addresses were known before or not. 274 00:36:25,200 --> 00:36:41,500 So, what I actually did, I look for some, uh, connection using this email address, especially for the Jiathan user, and I found out that there was only a few server, only a few website that was using this email address. 275 00:36:41,940 --> 00:37:05,840 What I found out as well is that for Jigar Kumar, with the ProtonMail address, I was able to recover the date of creation of this email address, which was on 2022 April, April 27, and which is interesting because this email address has been created just a day before Jigar Kumar sent the first email to the, 276 00:37:05,840 --> 00:37:10,640 to the Exe, uh, Utils, uh, uh, DL list and, and project. 277 00:37:11,340 --> 00:37:26,580 So, Jigar Kumar, Hans Jensen, and Dennis Hans was part of the first pressure campaign, and the second one, Mizo Heter and Krigorin was part of the second pressure campaign which occurred between the release of the version 5.6.0 and the release of the version 5, 278 00:37:26,580 --> 00:37:27,860 5.6.1. 279 00:37:28,340 --> 00:37:37,960 And which is interesting is that if you have a look to the structure of this email addresses, they all have the same structures. 280 00:37:38,060 --> 00:37:43,600 They have a username, they have a number, and they all use, used a free email service. 281 00:37:43,760 --> 00:37:53,400 And also, what I wanted to discover is, does this email address are using, have been, for example, known in public data leak database. 282 00:37:53,700 --> 00:38:00,860 And I checked for all of them, and all of them were not present in any of the public leak, leak database. 283 00:38:00,860 --> 00:38:21,640 And Brian Krebs, at the time of the investigation, when everyone was crazy about it, uh, said, it's super rare to have one email address which is not present in data leak databases, but it's even more rare to have multiple email address which are not present in any of the data leaks, 284 00:38:21,640 --> 00:38:29,340 which could give us some information about, you know, a really well-crafted, uh, operation. 285 00:38:31,100 --> 00:38:32,960 So, what can we do about it? 286 00:38:32,960 --> 00:38:41,440 Well, it's not an easy question, and I don't think I have the, the answer today, but here is some elements maybe to, you know, just to think about it. 287 00:38:42,020 --> 00:38:50,480 Maybe something that could be done specially on project like this one that have been widely used everywhere, would be to have like a strict contributor verification. 288 00:38:50,960 --> 00:38:59,260 Also to ensure that the builds are reproducible, meaning to have like the equivalent of the GitHub repository and the release of the tarball. 289 00:38:59,680 --> 00:39:08,580 Then hooded hooks and railroad protection, but as we saw in that case, the backdoor we are actually using, uh, bypassing for, of the railroad. 290 00:39:08,840 --> 00:39:14,980 And also improving dependency management could be a good way to improve issue like this one. 291 00:39:16,940 --> 00:39:23,920 There is also something which is important to keep in mind, which is, what does it mean for the security community and beyond? 292 00:39:23,960 --> 00:39:40,740 So first, I think it's important to keep in mind that the entire industry relies on open source tools, and as we saw for the XE utility package, some people are relying of a biased project such as the XE, uh, utility package. 293 00:39:40,860 --> 00:39:56,620 I think also the discovery of the backdoor itself was a mix of luck, coincidence and expertise because without the investigation of Andres, then we won't be able to, we probably wouldn't have been able to find the backdoor itself. 294 00:39:56,740 --> 00:40:00,340 So I think it's kind of important to think about it. 295 00:40:00,960 --> 00:40:15,160 I believe also, if you are, if you have a look to the sophistication, the mechanisms and the deep understanding of Linux operating systems, I believe it's also redefine what we call sophisticated attacker. 296 00:40:15,240 --> 00:40:18,120 And of course, as I said, there is no easy solution. 297 00:40:18,120 --> 00:40:34,000 Probably the knowledge of what I'm trying to do today, meaning explaining you how the backdoor is working and what the attacker did, is also maybe part of the solution because knowledge potentially is the key, so you are, you are well prepared for the next one. 298 00:40:35,520 --> 00:40:39,980 Of course, in 45 minutes, it's super difficult to give you the whole details. 299 00:40:39,980 --> 00:40:44,840 There is a bunch of technical, uh, details, uh, into the backdoor itself. 300 00:40:44,840 --> 00:40:47,340 There is a, a lot of information to cover. 301 00:40:47,480 --> 00:40:58,260 So I want to acknowledge, uh, all the researchers that have been working on it because they did a fantastic job and I really recommend you to have a look to the different blogs at the end if you want to learn more about it. 302 00:40:58,360 --> 00:41:10,940 And because, because of, uh, I mean, thanks to all their writer, we know a little bit more today how the backdoor works, but there is potentially more to discover and potentially stuff that we will never discover. 303 00:41:11,280 --> 00:41:25,020 And before to conclude on the presentation, I just want you to, to ask you a question to think about for potentially the, the rest of the day, the rest of the week or potentially the, the rest of your career. 304 00:41:27,300 --> 00:41:34,520 How many other JATAN do you think are paid, are, are paid to insert backdoors in open source project? 305 00:41:34,520 --> 00:41:36,760 And thank you very much for listening me today.