[00:02.420 --> 00:10.780] Well, thank you for waiting. It was, uh, quite intense from the, the stage. All right. So, [00:10.780 --> 00:16.580] thank you very much for attending this talk. Uh, I hope you will find it, uh, enjoyable. [00:16.580 --> 00:28.000] It's, uh, it's a, it's a cool story to tell and there is a lot to cover, so buckle up. So over [00:28.000 --> 00:35.560] the past, uh, few years, the security industry, uh, you know, investigated a lot of different [00:35.560 --> 00:43.000] security incidents. But only a few of them were truly sophisticated, meaning something that [00:43.000 --> 00:48.900] was really different than what we used to be. We can talk about, for example, the SolarWinds [00:48.900 --> 00:57.680] case, the Lopetia attack, or even the 3CX, uh, supply chain attack last year. [00:58.000 --> 01:04.560] But today I want to talk about, um, another attack which surpasses even the most [01:04.560 --> 01:11.680] sophisticated we've seen before. This is, uh, an undercover operation that lasted almost [01:11.680 --> 01:19.000] three years, which is very impressive in terms of technical details, but also the social [01:19.000 --> 01:24.400] engineering aspect is very impressive as well. So I'm going to talk about the XE backdoor [01:24.400 --> 01:31.100] story, the undercover operation that set the internet on fire. And I'm pretty sure that by the [01:31.100 --> 01:37.380] end of this presentation, your definition of what is a sophisticated, uh, a sophisticated [01:37.380 --> 01:44.360] attacker is will be changed. So I'm Thomas Rocha, I'm a senior threat researcher at [01:44.360 --> 01:49.520] Microsoft. I've been working on the XE campaign when it came out by, uh, uh, Andres [01:49.520 --> 01:55.220] Freund, which is, uh, a colleague of mine, and we, we, we discovered the, the backdoor [01:55.220 --> 02:00.200] itself. I'm French, as you probably may have heard, and I'm living in Australia, so I'm, I'm [02:00.200 --> 02:04.520] good with the jet lag now because it's been a week in, uh, in Vegas already. Uh, if you want [02:04.520 --> 02:09.780] to learn more about my work, you can visit my website, securitybreak.io, or you can, you can [02:09.780 --> 02:16.380] also follow me on Twitter. What I will cover in this presentation, first, how the backdoor [02:16.380 --> 02:22.840] was found. Then I will talk about the long term operation and the timeline itself. I will [02:22.840 --> 02:28.120] then deep dive into the technical details, and we will discuss about some assumptions. And [02:28.120 --> 02:32.640] finally, I want to conclude this presentation of what it means for us, for the security [02:32.640 --> 02:45.960] industry. Okay, this story began on Friday, 29th of March, at exactly 851 minutes, and it was [02:46.380 --> 02:53.860] uh, a message sent by Andres Froon to the OSS security DL list. With the, the subject, [02:53.860 --> 03:03.680] backdoor in upstream exit, Libel ZMA leading to SSH server compromise. So that's pretty much [03:03.680 --> 03:08.780] around that time, when I saw the, the email and read the investigation, that I started to [03:08.780 --> 03:15.500] investigate more about the backdoor itself and how it was working. But before, I want to [03:15.500 --> 03:19.760] talk a little bit about Andres and how he found the, the backdoor. Because on the [03:19.760 --> 03:24.920] internet, there was a kind of a legend where everyone was saying that the backdoor was [03:24.920 --> 03:31.880] discovered because of a 500 millisecond and uh, for, from Andres that triggered the [03:31.880 --> 03:38.700] investigation. The reality is a bit different. Actually, what triggered the investigation [03:38.700 --> 03:45.200] from Andres was that he found that the SSH login in some of the tested, the testing he was [03:45.200 --> 03:51.480] doing was actually failing. So he decided to investigate a little bit more to try to [03:51.480 --> 03:58.580] understand why the SSH was, the SSH logins were actually failing. And he discovered that [03:58.580 --> 04:06.180] there was a substantial CPU usage during the SSH and he found out the 500 millisecond delay [04:06.180 --> 04:15.360] which he identified, identified later in the new package uh, XE. And he said that, he said [04:15.360 --> 04:21.260] itself, it was a bunch of coincidences. So if we, if we have a look to how he discovered [04:21.260 --> 04:27.960] the backdoor, first, he saw that there was some issue with the SSH uh, login. Then he [04:27.960 --> 04:34.440] decided to investigate and then he found uh, a little bit of uh, amount of CPU uh, using [04:34.440 --> 04:41.480] by the SSH process. So he decided to investigate a little more and he found out that this [04:41.480 --> 04:49.400] amount of CPU usage was used by the Libel ZMA. But then, that's now which is becoming a [04:49.400 --> 04:58.480] little bit crazy because he actually used some specific setup which led him to find the [04:58.480 --> 05:04.340] backdoor. First, he decided to choose a Debian unstable which at the time of the release of [05:04.340 --> 05:10.340] the, the backdoor uh, only this kind of Linux version was affected by the backdoor. Then he [05:10.340 --> 05:16.540] chose to use a specific flag. And without the flag, this flag, he wouldn't have found uh, [05:16.540 --> 05:21.400] the, the backdoor because he was actually tracing the process using Valgrind and Valgrind [05:21.400 --> 05:27.280] complaining, complained about uh, the, the processes because of the flag he was setting up [05:27.280 --> 05:34.560] before. So that's super crazy because thanks to that, he was able to investigate and to find [05:34.560 --> 05:42.020] out the high CPU usage was in the SSHD processes below get CPU ID. Keep that information in [05:42.020 --> 05:53.130] mind because it will be interesting and important for the next part of the presentation. But [05:53.130 --> 06:01.610] you may wondering, what the fuck is uh, exe, exe-utils package? So, the exe, the exe-utils [06:01.610 --> 06:06.410] package is a free software, an open source software which is dedicated for lossless data [06:06.410 --> 06:13.530] compression through SDMA algorithm and exe. It, it, it is maintained by Lasikolin which is the [06:13.530 --> 06:19.670] main maintainer of the backdoor of the, sorry, of the, of the package since more than a, than a [06:19.670 --> 06:29.330] decade. The backdoor has been found in Libel ZMA in the version of exe-560 and 561. And it was [06:29.330 --> 06:36.390] introduced by a mysterious user called Jiatan in February 2024. The, the package, uh, [06:36.410 --> 06:42.610] and the backdoor affected mostly uh, development version so it was not widely deployed when [06:42.610 --> 06:50.690] Andres found the backdoor itself. And Red Hat assigned the vulnerability CVE 2024-30-94. [06:51.290 --> 06:58.150] There is something interesting here because you may wondering as well, why the exe-utils [06:58.150 --> 07:06.390] package has in, uh, has in any relation with uh, SSH? Well, I'm glad you ask. Because [07:06.410 --> 07:12.510] actually, the exe-util uh, uh, backdoor uh, package is widely used in many Linux uh, [07:12.510 --> 07:19.010] distribution and it's a trusted open source component for pro- for compression uh, and any [07:19.010 --> 07:25.670] kind of uh, optimization. The exe-util is, has been used in the open source industry for [07:25.670 --> 07:33.270] years and which is interesting is that open SSH is using the exe-compression to reduce the [07:33.270 --> 07:40.630] size of transfer data when you are doing a connection. So, quite interesting target for an [07:40.630 --> 07:49.150] attacker. Okay, I want now to talk about the timeline. And it's a bit uh, heavy. So, what I [07:49.150 --> 07:55.670] did, I actually split the timeline into five different phases. The first phase, the first [07:55.670 --> 08:03.250] phase which I called initial involvement of GATAN from October 29, 2021 to June 2021. [08:03.270 --> 08:10.770] June 29, 2022. So, during this phase, the user GATAN started to get, started to gain trust into [08:10.770 --> 08:16.490] the exe uh, project and started to do some commit and to work a little bit more. Which is [08:16.490 --> 08:23.890] interesting is um, during that phase as well, there was, there were additional persona that was [08:23.890 --> 08:30.870] part of a kind of a pressure campaign against Lassie Collin, the main maintainer of the exe [08:30.870 --> 08:38.970] package. To move the member, the um, the maintainership to another user. So, some [08:38.970 --> 08:45.510] additional personnel, persona such as Jigar Kumar and Dennis Hance have been part of this [08:45.510 --> 08:52.410] pressure campaign to put the pressure on Lassie Collin. And in June 29 of 2022, Lassie [08:52.410 --> 08:59.290] Collin started to mention GATAN as a co-maintainer already. Then in phase two, which I [08:59.290 --> 09:08.470] call transition of mentorship from September 27 of 2022 to March 18 uh, 2023. During this [09:08.470 --> 09:16.010] time, GATAN continued to contribute to the project to gain trust with uh, with the, the main [09:16.010 --> 09:22.770] maintainer and to the project itself. On October 2022, GATAN was added to the Tukeni [09:22.770 --> 09:29.270] organization on GitHub, which is the organization uh, that released the exe package. So, [09:30.270 --> 09:35.450] and then additional event as well during this time. Then during phase three, which I call [09:35.450 --> 09:44.070] preparation for the attack from March 2023 to January 19, 2024. During this time, a bunch of [09:44.070 --> 09:51.290] information happened as well. First, GATAN uh, updates the Google OSS first to send bugs to [09:51.290 --> 09:58.950] his own email. Then, another persona, Hans Jensen, sends patches for GNU indirect uh, [09:58.950 --> 10:06.930] function features, which is quite important as well. And uh, and GATAN also disables uh, [10:06.930 --> 10:12.290] iPhone support during the OSS first build, which is quite important because it's a kind of uh, [10:12.290 --> 10:18.690] evading some, some security protections. And then during phase four, which I call backdoor [10:18.690 --> 10:27.430] insertion and distribution from February 23 uh, to March 28 of 2024. This is where GATAN [10:27.430 --> 10:33.990] started to release the backdoor. So, in February 24, GATAN merged hidden backdoor binary code [10:33.990 --> 10:41.690] in kind of test files, which are actually fake text, test files. And then he released the [10:41.690 --> 10:49.010] version 5.6.0 with an additional file that was not present in the GitHub repository itself. [10:50.190 --> 10:56.950] And in March 9, uh, GATAN committed uh, an update of the backdoor because there was a bug [10:56.950 --> 11:02.670] and then he released the version 5.6.1, which was backdoored as well. And then on the last [11:02.670 --> 11:10.670] phase, phase uh, phase number 5, which I call discovery and response from March 28 to March 30, [11:10.670 --> 11:16.570] this is where Andres found the backdoor, started to alert and to send the email with his own [11:16.570 --> 11:24.110] investigation and this is where internet was on fire as well. But there is something which is [11:24.110 --> 11:28.070] interesting. I talk about the pressure campaign. So let me give you a little bit more detail [11:28.070 --> 11:35.130] about that. Cause this is quite interesting from the social engineering aspect. So first, I [11:35.130 --> 11:40.250] mentioned that some additional personas were part of this pressure campaign to move the [11:40.250 --> 11:48.950] mentorship of the, of the backdoor to someone else. So in March, uh, in April 2022, Jigar [11:48.950 --> 11:56.170] Kumar sent a message. Patches spend years. In May 2022, Dennis Hance, the, the other [11:56.170 --> 12:01.430] persona, sent another message as well and said, I asked a question here a week ago and I [12:01.430 --> 12:06.290] have not heard back. It has not updated in over a year. Is there a plan for this thing in the [12:06.290 --> 12:11.890] future? Lassie Colleen, which at the time was getting all these messages from these personas [12:11.890 --> 12:19.430] and so on. Jiatan has helped me at least with exe-utils. And he might have a bigger role in the [12:19.430 --> 12:29.850] future. It's clear that my resources are too limited. In May 2022, Jigar Kumar and so on. Over [12:30.070 --> 12:35.590] a month and no closer to being merged. Not a surprise. Jigar Kumar sent another message. [12:35.590 --> 12:40.390] Progress will not happen until there is a new maintainer. The current maintainer lost [12:40.390 --> 12:47.990] interest or doesn't care to maintain anymore. Quite aggressive. Then on June 2022, Lassie [12:47.990 --> 12:52.670] Colleen and so on. My ability to care has been fairly limited, mostly due to long term mental [12:52.670 --> 13:00.170] health, but also due to some other things. Jiatan may have a bigger role in the future. And he [13:00.170 --> 13:05.830] mentioned also, and I think this is quite important in this case, he mentioned it's also good to [13:05.830 --> 13:14.750] keep in mind that this is a non-paid OB project. In June 2022, Jigar Kumar sent another message. [13:14.750 --> 13:20.410] Right now you shock your repo. Why wait until 5 4 0 to change maintainer? Why delay what your [13:20.410 --> 13:27.210] repo needs? Dennis Ant sends a message. Why not pass on mentorship for exe for C so you can give [13:27.210 --> 13:34.190] exe for Java more attention? And then Jigar Kumar sent another message. Jia, this is the first [13:34.190 --> 13:40.150] time he actually talked to Jia. Jia, I see you have recent commits. Why can't you commit this [13:40.150 --> 13:48.830] yourself? And then Lassie Colleen replied on June 2022, on the day 29. Jiatan may have a bigger [13:48.830 --> 13:56.390] role. He is practically a co-maintainer already. Some change in mentorship is already in [13:56.390 --> 14:04.170] progress. Mission accomplished. Jiatan is no part of the project and he has a lot of [14:04.190 --> 14:09.470] more right to contribute. Alright, so now I want to talk about the technical details and how [14:09.470 --> 14:15.410] the backdoor was deploying and how the backdoor works as well. So remember, I mentioned [14:15.410 --> 14:21.610] that the user Jiatan deployed two different test files. The first one was bad3corrupt [14:21.610 --> 14:29.710] underscore lzma2 dot exe and the second one was goodlarge underscore compressed dot lzma. [14:29.710 --> 14:39.030] And additionally, when he released the latest version, version 5.6.0 of the exe package, he [14:39.030 --> 14:45.070] shipped the version with an additional file called build2host dot m4. If you are not familiar [14:45.070 --> 14:50.910] with m4 files, it's a kind of macro file used for configuration during the compilation [14:50.910 --> 14:59.430] process. And this file was present in the release but not in the repository. So let me talk a [14:59.430 --> 15:07.530] little bit more about the build2host dot m4 file. And I will focus here on the version 5.6.0. [15:07.650 --> 15:14.810] So what you see on the screen is just the malicious part of this file, just to focus on what it [15:14.810 --> 15:18.910] is exactly doing, but imagine that this file is super big with a lot of different [15:18.910 --> 15:26.050] configuration and a lot of legitimate actions. So the ones that you saw, you see on the [15:26.050 --> 15:32.610] screens, are only the malicious part. So first, you can see there is a variable called glam [15:32.610 --> 15:40.410] config make, with a grep, which actually looks for one of the malicious test files that have [15:40.410 --> 15:48.610] been released, and specifically the bad3corrup underscore lzma2 dot exe. Then we have, in [15:48.610 --> 15:56.030] number two, two additional variables. The first one, which is the trtool, trtool translate [15:56.050 --> 16:04.070] which is basically doing a kind of a substitution algorithm for part of the backdoor, of the [16:04.070 --> 16:12.450] file itself, the bad3. And the second one is actually showing the file, the test file, and [16:12.450 --> 16:19.850] making a sed to retrieve the extension of this file, exe, which will later be used as a [16:19.850 --> 16:27.430] common line. And as you can see, the translation of this piece of screen is the cat at the [16:27.430 --> 16:35.470] end of the presentation. So basically, transforming the file itself and decompressing using [16:35.470 --> 16:48.440] exe, the file which has been deobfuscated kind of using tr. So here you have a look of what was [16:48.440 --> 16:54.740] the original bad3corrup lzma2 file before the decryption, the, the, the, the, the [16:54.740 --> 17:01.440] substitution and the, the decompression using exe. And you have the malicious script on your [17:01.440 --> 17:05.420] right. So if you have a look to this malicious script, there is some interesting [17:05.420 --> 17:13.760] information here. So first, I, I like to comment, which is actually an exact decimal string. So [17:14.440 --> 17:21.140] today, we still don't know what is exactly this string, but I believe, because in version 5.6.1, [17:21.140 --> 17:26.400] this exact decimal string was not the same. So I believe this string was potentially related [17:26.400 --> 17:33.320] to a kind of a versioning number. Then we have a bunch of, uh, head command which are used to [17:33.320 --> 17:38.120] manipulate input data stream. And at the end, we have the stash3 and backdoor extraction [17:38.120 --> 17:45.760] because in the bad3corrupt, uh, uh, in the, in the bad3corrupt lzma and the second file, the [17:45.760 --> 17:52.040] goodlargecompressed lzma, there is the next part of the, of the, the release of the backdoor [17:52.040 --> 17:57.900] and also the decompression of an object. I will come to it later. I just give me, let, let [17:57.900 --> 18:03.740] me give you a look, a deeper look of what the file, what the script is doing to release the [18:03.740 --> 18:09.680] next part. So first, is decompress the second malicious file. Remember, the second test [18:09.680 --> 18:17.880] file, goodlarge underscore compressed dot lzma. That cons, contains the stash3 and the [18:17.880 --> 18:24.120] binary backdoor. It remove a, a, a bunch of junk data and unus byte, cause the file is a bit [18:24.120 --> 18:31.400] obfuscated. There is again a custom substitution cipher using TR. And then, all the, the [18:31.400 --> 18:40.640] deciphered data are decompressed again using Xs. Which lead to the stash3, which is another [18:40.640 --> 18:46.220] script, which is doing a bunch of checking during the compilation process. So let me walk [18:46.220 --> 18:51.840] through some of the checking this stash3 is doing. First, it's checked for the iPhone [18:51.840 --> 18:56.600] support. Remember, previous commit, we discussed about it. Keep that in mind for the, for the [18:56.600 --> 19:04.760] next part. Then it verify CRC source file, CRC64 underscore fast C, and CRC32 underscore [19:04.760 --> 19:11.420] fast C. For require iPhone code, because the backdoor require this feature. There is a bunch [19:11.420 --> 19:16.640] of multiple checks. It verify the version of the Linux system, uh, validate the GCC [19:16.640 --> 19:21.260] comp, compiler, check for the previous two test file, because if the two test file are not [19:21.260 --> 19:26.040] present, there is no need to continue to deploy the backdoor. So it's a kind of protection. [19:26.040 --> 19:34.300] It ensures position independent code. And also, it extract the backdoor from the, the test [19:34.300 --> 19:42.260] file, good large compressed dot LZMA. And this backdoor, ex, uh, extracted from this file [19:42.260 --> 19:52.980] will be embedded into the, the object file, libLZMA LA dash CRC64 dash fast dot O. Then, there [19:52.980 --> 20:01.260] is a modification of a function, isArchExtensionSupported in CRCXX86CLMUL dot H, and it [20:01.260 --> 20:12.480] replaces getCPUID with two underscore, with getCPUID with one underscore. Remember [20:12.480 --> 20:20.860] getCPUID was where address trust the execution of the backdoor and the amount of CPU usage. [20:27.800 --> 20:31.760] So I want to talk a little bit about the backdoor extraction itself, because it's quite [20:31.760 --> 20:38.600] interesting how the attacker did it as well. So in the code, there is a, a piece which is [20:38.600 --> 20:46.720] using the AWK func, um, tools from Linux, and this is actually doing like a kind of a RC4 [20:46.720 --> 20:56.360] like algorithm to decrypt the payload itself that will be later stored into the libLZMA [20:56.360 --> 21:05.860] LA CRC64. So quite interesting to see that as well. So, to recapitulate a little bit the [21:05.860 --> 21:10.800] compilation process, because I know it could be quite uh, quite complex. So first we have [21:10.800 --> 21:16.280] the execution of the macro file, the build to host dot info, which is executed and [21:16.280 --> 21:23.980] subsequent scripts are also executed. It run all the checks, and it create the make file if [21:23.980 --> 21:28.340] previous conditions are met. Because there was a bunch of information, if all the [21:28.340 --> 21:34.020] conditions are not met, then the backdoor is not released. Then during the make process, [21:34.020 --> 21:41.140] there is a backup of the original file, which has been backdoor, and libLZMA LA CRC64 fast [21:41.140 --> 21:47.400] dot O. There is a backup because if something, something goes wrong, the backdoor itself, I [21:47.400 --> 21:52.480] mean the, the code itself can push back the original file and so there is no track into the [21:52.480 --> 21:58.800] final release of the exe util package. There is also some specific compilation flags. [21:58.880 --> 22:06.660] I think, I think resolvers run at startup. Modification of the file CRC64 fast dot C and [22:06.660 --> 22:14.180] CRC32 fast dot C. And then finally, compilation, linking stage, manipulation and cleanup [22:14.180 --> 22:19.980] because the attacker did well, they also have a bunch of clean, cleaning up to avoid any [22:19.980 --> 22:25.500] forensic investigation or further, further investigation. And then at this point, we are [22:25.500 --> 22:35.980] here, malicious libLZMA is incorporated into the compiled libLZMA. So now I want to talk a [22:35.980 --> 22:40.700] little bit more about the backdoor itself and some of the functionalities. So first it's [22:40.700 --> 22:46.100] using the iFunc feature, which allows for dynamic resolution of function implementation [22:46.100 --> 22:51.320] during the run time, meaning it can load some specific feature at the run time. And [22:51.320 --> 22:57.060] actually the backdoor hijacks the iFunc resolver to allow the modification of the global [22:57.060 --> 23:03.400] offset table, which, which is a kind of a table with address to some specific functions. And [23:03.400 --> 23:08.460] here on the screen, what you can see is actually the malicious get CPU ID that will trigger [23:08.460 --> 23:16.000] the backdoor and continue the execution to the global offset table hijack. Another [23:16.100 --> 23:22.300] interesting feature about the backdoor is the usage of DL audit to set up the hook and to [23:22.300 --> 23:27.640] bypass Railroad and to intercept also redirect function, function call. If you are not [23:27.640 --> 23:32.480] familiar with Railroad, it's a kind of a memory protection space to avoid, uh, to avoid to [23:32.480 --> 23:37.700] have some, some space that could be vulnerable for some vulnerability exploitation. So what [23:37.700 --> 23:44.480] it is doing here, so first it's checking that the loaded target process is SSHD, because [23:44.480 --> 23:50.580] remember, it is our target here. And verify that the share library, and specifically [23:50.580 --> 23:56.440] Libel ZMA, because this is the, the, the, this is where the backdoor is loaded, is already [23:56.440 --> 24:04.100] present. Then it set up the DL audit structure to start the audit mechanism. And during the [24:04.100 --> 24:10.460] dynamic linking, so think about all these steps, uh, doing, doing the, the loading. It [24:10.460 --> 24:16.540] resolve and bind symbols. And then, the DL audit symbol function is called by the [24:16.540 --> 24:24.780] linker whenever a symbol needs binding. And if all the conditions are met, then it set the [24:24.780 --> 24:30.200] backdoor to the install hook function to install the, the hooking function that the payload [24:30.200 --> 24:39.100] will need later. There is also the global offset table, uh, redirect, which I mentioned is a [24:39.100 --> 24:46.020] kind of a table with a function address. And in that case, at the run time, the backdoor will [24:46.020 --> 24:52.500] manipulate this pointer into the global offset table to redirect codes to the main malware [24:52.500 --> 25:00.760] function. And if you have a look to the investigation, if you have a look to the, to the [25:00.760 --> 25:08.340] running at this time, everything will look like it's been called through the CPU ID [25:08.340 --> 25:18.270] functions. On top of that, there is additional evasion mechanisms and kind of obfuscation. First, [25:18.270 --> 25:24.970] there is a string obfuscation. In that case, what the backdoor is doing is looking for a tree [25:24.970 --> 25:32.830] structure. A tree structure is basically, uh, a corresponding reference between a string and a [25:32.830 --> 25:37.590] number. And what the backdoor is doing is looking for a specific number to retrieve the [25:37.590 --> 25:44.630] strings it needs for the execution of the payload. So if you, it's kind of a, if you are [25:44.630 --> 25:51.090] familiar, it's kind of API, API hashing, where you are retrieving the function code, uh, based [25:51.090 --> 25:57.330] on a specific hash. And in that case, the sample, the payload is, is looking for some [25:57.330 --> 26:05.490] specific string and for example, 0x1d0 is for RSA public decrypt, which is one of the [26:05.490 --> 26:12.510] function. Or for example, for 0x300 for the ELF header, which is used for the deployment [26:12.510 --> 26:19.370] mechanism as well. And you have some of the strings that was extracted by the backdoor and [26:19.370 --> 26:27.890] needed for the rest of the execution. So as I said, there is function hook that have been [26:27.890 --> 26:35.030] added by the, by the, by the payload itself. So first, what it is, what it, what it is doing, [26:35.030 --> 26:40.950] it's actually retrieving obfuscated string from the tree structure and one of the string [26:40.950 --> 26:46.590] which is important here are the RSA public decrypt function, which is a hook and the RSA [26:46.590 --> 26:52.930] get zero key function, which is also a hook. These two function are used in the latest SSH [26:52.930 --> 26:59.470] server version and are called when an RSA certificate is configured, is using for the [26:59.470 --> 27:04.030] authentication. Remember that because this is important. And the last function which have [27:04.030 --> 27:10.530] been hooked is the EVP PK set one RSA, which it's a little bit weird because it's not used in [27:10.530 --> 27:16.370] the latest SSH version, but probably that it has been set up for compatibility or probably [27:16.370 --> 27:24.250] for a specific environment. There is a bunch of other checks and evasion used by the [27:24.250 --> 27:29.870] sample, uh, by the payload. Here, there is an overview. So first, as we saw, it's, it's [27:29.870 --> 27:34.490] checks that the current process is well SSHG because there is no need to deploy the [27:34.490 --> 27:41.010] backdoor if we, if we are not running, uh, if SSHG is not running. It check for a potential [27:41.010 --> 27:47.130] kill switch. So this one is not very clear. This is a string that was present into the [27:47.130 --> 27:51.970] malware itself, the payload, but it's not very clear what's the goal, what was the goal of [27:51.970 --> 27:55.970] this string. Some researcher are thinking that it could be like a kind of a kill switch. If [27:55.970 --> 28:02.870] the backdoor see the, this, uh, strings into the, the environment, the memory, then it will [28:02.870 --> 28:09.090] not run. Potentially a kill switch. It also abuses the legit LZMA alloc function for memory [28:09.090 --> 28:15.530] allocation, which is required by the payload at some point. And there is also, it is, the [28:15.530 --> 28:24.010] backdoor is also hooking the logging function, meaning for every authentication through the [28:24.010 --> 28:31.310] backdoor, nothing will be logged into the, into the log of the machine. So that means it's also [28:31.310 --> 28:36.130] more difficult for forensic investigation and incident response. And there is a bunch of [28:36.130 --> 28:41.730] other advanced functionality such as encryption, anti-replay, it also embeds its own tiny [28:41.730 --> 28:49.110] embedded disassembler which is required at some point as well. But how the, how does the [28:49.110 --> 28:54.890] backdoor works really? So remember I said there is, uh, three main function that have been [28:54.890 --> 28:59.930] hooked. And which is interesting as well, is that the backdoor embeds three main [28:59.930 --> 29:06.070] function to be triggered. To trigger this function, there is kind of magic number, actually [29:06.070 --> 29:10.130] three magic number, and there is an operation which is used by the backdoor itself, which is [29:10.130 --> 29:16.810] magic one multiplied by magic two, plus magic two, which, which will give us the common [29:16.810 --> 29:22.510] number that will be triggered by the payload itself and the backdoor. So the first one, [29:22.510 --> 29:29.810] command zero and command one, is actually an SSH authentication bypass using root login. [29:29.930 --> 29:37.150] Second one is a remote code execution via systemd, cmd2. And the third one is, uh, [29:37.150 --> 29:43.130] cleaning a closed pre-authentication that have been previously opened. And if you pay [29:43.130 --> 29:50.650] attention to the, to the diagram below, to trigger this specific, uh, command, the [29:50.650 --> 29:58.030] attacker have to embed the payload into an RSA certificate that will be read by the, by the [29:58.030 --> 30:04.230] backdoor server during the authentication. And then there is a bunch of decryption. Of [30:04.230 --> 30:13.130] course, to exploit this specific backdoor, there is an upcoded certificate used, so that means [30:13.130 --> 30:19.090] only the attacker itself can login to the compromise server because he already have the [30:19.090 --> 30:28.010] private key. So to give you a little more details of how works the certificate payload, [30:28.990 --> 30:37.210] so you have here a kind of an overview of what is inside the certificate itself. So first, [30:37.210 --> 30:44.610] this certificate is used to the connection to the SSH, uh, to the SSH, uh, process to the [30:44.610 --> 30:50.910] backdoor server. Then there is an exchange of the public key, and this public key, there is [30:50.910 --> 30:56.030] also a SHA256 which is calculated as well. So let me give you an overview of the [30:56.030 --> 31:01.970] certificate itself. First, if you have a look, it's a normal RSA certificate, but there is some [31:01.970 --> 31:09.910] interesting information. In the IV, I call that the IV because it's used later, the, this IV is [31:09.910 --> 31:15.830] actually the magic numbers. Remember, the magic numbers are used to calculate the common [31:15.830 --> 31:22.010] number that will be interpreted by the, the server and, and the, the backdoor itself. And [31:22.010 --> 31:28.530] then, in the modulus N, uh, payload, in the, in the modulus N part of the RSA certificate, [31:28.530 --> 31:37.830] there is the payload which is encrypted in SHA20, 20, uh, SHA20, sorry. And this payload is [31:37.830 --> 31:46.030] decrypted using the outcoded ED448 public key that has been exchanged during the initiation of [31:46.030 --> 31:51.810] the connection, but only with the first 32 byte. And it's also using the IV, which are [31:52.530 --> 31:59.970] the magic numbers used, outcoded into the, the malicious RSA key, to decrypt the payload. [32:00.150 --> 32:05.010] Then, in the decryption of the payload, we have two main parts. The first, which is the [32:05.010 --> 32:11.690] signatures, which have been verified by the payload to be sure this is well, this is well the [32:11.690 --> 32:17.090] attacker that has been trying to connect. And we have the payload itself, which have been [32:17.090 --> 32:25.710] executed. And the signature is generated with the CMD value, which have been calculated. A [32:25.710 --> 32:31.830] five byte flag, which we don't know at this time what is it exactly. The payload itself, and [32:31.830 --> 32:39.870] the SHA256 that have been calculated from the ED448 signature. So a bunch of mechanisms to [32:39.870 --> 32:45.630] avoid also, uh, the replay of the certificate and to investigate a little bit more. And at [32:45.630 --> 32:59.790] this point, JITAN is in. So there is a small, um, let me show you. I did a small, uh, [32:59.790 --> 33:11.970] demonstration using, I did a small demonstration using, uh, a payload, using, uh, someone [33:12.690 --> 33:20.250] reused, um, uh, recoded, actually, the, the backdoor. So I reused this code. So on, on the [33:20.250 --> 33:24.790] right, you have the target, which is the attacker. So what I did here, uh, recompiled the [33:24.790 --> 33:30.450] backdoor itself with my own certificate, so I can reuse the code and authenticate like if I, [33:30.450 --> 33:36.250] like if I was the attacker. So you have the target on your right. On the, on the bottom you [33:36.250 --> 33:42.510] have the logs, because some researcher found that if you activate the verbose [33:42.510 --> 33:49.210] mechanism in the, in the logs and the configuration of SSH, there is a logging feature, uh, [33:49.210 --> 33:55.130] that appear and then there is some track, some trace into the, into the logs. So what I'm [33:55.130 --> 34:00.370] using here, I'm actually running the backdoor against my server, which I've been [34:00.370 --> 34:06.230] compromised. And here you can see, there is, what I did here is extracting some of the [34:06.230 --> 34:11.670] components that have been used to generate the RSA certificate used to authenticate to the [34:11.670 --> 34:17.910] compromised server. And as you can see here, you can see the OSCE, the SHA-256, the [34:17.910 --> 34:22.370] different magic number, the magic command, in that case it's number two, so I'm using the [34:22.370 --> 34:28.550] RCE, remote code execution. And then we have the certificate that have been sent to the [34:28.550 --> 34:35.350] compromised server. And if you look to the target here, I've been written a file called [34:35.350 --> 34:41.050] it's me, and that have been executed by, uh, the certificate itself. And this payload was [34:41.050 --> 34:48.250] actually part of the RSA, uh, key that are sent to the mal- to the compromised server. The [34:48.250 --> 34:54.130] second one is a, um, is a remote code execution as well, just to, uh, have, uh, a reverse [34:54.130 --> 34:59.030] shell and to be able to, uh, authenticate and to do some action onto the mali- onto the [34:59.030 --> 35:47.480] compromised server. So, okay. Okay, sorry about that. Okay, so you may wondering who is [35:47.500 --> 35:52.760] behind, uh, this attack. So, as I, as I discussed at the beginning, there was multiple [35:52.760 --> 36:00.720] personas involved into the, into the deployment of the backdoor for the pressure campaign [36:00.720 --> 36:05.600] against LaCie calling. So, remember, I talk about Jigar Kumar, Dennis Ants, and Ants [36:05.600 --> 36:12.500] Jensen, and Jiathan as well. So, what I did here, I wanted to know if, because we already [36:12.500 --> 36:18.200] had this, their, their email address, also their user name, and I wanted to understand if [36:18.200 --> 36:25.740] there is some connection or if the specific email addresses were known before or not. So, [36:25.740 --> 36:32.980] what I actually did, I look for some, uh, connection using this email address, especially [36:32.980 --> 36:39.040] for the Jiathan user, and I found out that there was only a few server, only a few website [36:39.040 --> 36:45.820] that was using this email address. What I found out as well is that for Jigar Kumar, with [36:45.820 --> 36:51.960] the ProtonMail address, I was able to recover the date of creation of this email address, [36:51.960 --> 36:59.800] which was on 2022 April, April 27, and which is interesting because this email address [36:59.800 --> 37:06.260] has been created just a day before Jigar Kumar sent the first email to the, to the [37:06.260 --> 37:13.920] Exe, uh, Utils, uh, uh, DL list and, and project. So, Jigar Kumar, Hans Jensen, and Dennis [37:13.920 --> 37:19.160] Hans was part of the first pressure campaign, and the second one, Mizo Heter and [37:19.160 --> 37:23.760] Krigorin was part of the second pressure campaign which occurred between the release of [37:23.760 --> 37:30.180] the version 5.6.0 and the release of the version 5, 5.6.1. And which is interesting is that [37:30.180 --> 37:37.000] if you have a look to the structure of this email addresses, they all have the same [37:37.000 --> 37:42.660] structures. They have a username, they have a number, and they all use, used a free email [37:42.660 --> 37:49.660] service. And also, what I wanted to discover is, does this email address are using, have [37:49.660 --> 37:55.920] been, for example, known in public data leak database. And I checked for all of them, and [37:55.920 --> 38:01.900] all of them were not present in any of the public leak, leak database. And Brian Krebs, at [38:01.900 --> 38:08.960] the time of the investigation, when everyone was crazy about it, uh, said, it's super rare [38:09.720 --> 38:16.520] to have one email address which is not present in data leak databases, but it's even more [38:16.520 --> 38:21.980] rare to have multiple email address which are not present in any of the data leaks, which [38:21.980 --> 38:31.740] could give us some information about, you know, a really well-crafted, uh, operation. So, what [38:31.740 --> 38:36.080] can we do about it? Well, it's not an easy question, and I don't think I have the, the answer [38:36.080 --> 38:42.480] today, but here is some elements maybe to, you know, just to think about it. Maybe [38:42.480 --> 38:47.060] something that could be done specially on project like this one that have been widely used [38:47.060 --> 38:52.700] everywhere, would be to have like a strict contributor verification. Also to ensure that the [38:52.700 --> 38:57.740] builds are reproducible, meaning to have like the equivalent of the GitHub repository and the [38:57.740 --> 39:04.100] release of the tarball. Then hooded hooks and railroad protection, but as we saw in that case, [39:04.100 --> 39:10.140] the backdoor we are actually using, uh, bypassing for, of the railroad. And also improving [39:10.140 --> 39:17.760] dependency management could be a good way to improve issue like this one. There is also [39:17.760 --> 39:22.140] something which is important to keep in mind, which is, what does it mean for the security [39:22.140 --> 39:27.500] community and beyond? So first, I think it's important to keep in mind that the entire [39:27.500 --> 39:34.560] industry relies on open source tools, and as we saw for the XE utility package, some people [39:34.560 --> 39:42.140] are relying of a biased project such as the XE, uh, utility package. I think also the [39:42.140 --> 39:48.060] discovery of the backdoor itself was a mix of luck, coincidence and expertise because [39:48.060 --> 39:53.780] without the investigation of Andres, then we won't be able to, we probably wouldn't have [39:53.780 --> 40:01.500] been able to find the backdoor itself. So I think it's kind of important to think about it. I [40:01.500 --> 40:07.200] believe also, if you are, if you have a look to the sophistication, the mechanisms and the [40:07.200 --> 40:13.400] deep understanding of Linux operating systems, I believe it's also redefine what we call [40:13.400 --> 40:18.620] sophisticated attacker. And of course, as I said, there is no easy solution. Probably the [40:18.620 --> 40:23.260] knowledge of what I'm trying to do today, meaning explaining you how the backdoor is [40:23.260 --> 40:29.160] working and what the attacker did, is also maybe part of the solution because knowledge [40:29.160 --> 40:36.300] potentially is the key, so you are, you are well prepared for the next one. Of course, in [40:36.300 --> 40:41.160] 45 minutes, it's super difficult to give you the whole details. There is a bunch of [40:41.160 --> 40:46.640] technical, uh, details, uh, into the backdoor itself. There is a, a lot of information to [40:46.640 --> 40:51.540] cover. So I want to acknowledge, uh, all the researchers that have been working on it [40:51.540 --> 40:55.440] because they did a fantastic job and I really recommend you to have a look to the different [40:55.440 --> 41:01.840] blogs at the end if you want to learn more about it. And because, because of, uh, I mean, [41:01.840 --> 41:06.760] thanks to all their writer, we know a little bit more today how the backdoor works, but there [41:06.760 --> 41:11.480] is potentially more to discover and potentially stuff that we will never discover. And [41:11.480 --> 41:17.500] before to conclude on the presentation, I just want you to, to ask you a question to think [41:17.500 --> 41:23.780] about for potentially the, the rest of the day, the rest of the week or potentially the, the [41:23.780 --> 41:32.700] rest of your career. How many other JATAN do you think are paid, are, are paid to insert [41:32.700 --> 41:36.760] backdoors in open source project? And thank you very much for listening me today.