1 00:00:00,000 --> 00:00:01,980 Hello everyone, thanks for coming. 2 00:00:01,980 --> 00:00:05,060 I am very honored to be here to give a presentation. 3 00:00:05,300 --> 00:00:06,670 So today, our topic is... 4 00:00:11,700 --> 00:00:14,620 First of all, let me introduce my team. 5 00:00:14,620 --> 00:00:19,220 We are security engineers from Alibaba County, and I am Ziyang Lin. 6 00:00:20,280 --> 00:00:22,280 Then, let me introduce the agenda. 7 00:00:22,280 --> 00:00:25,280 First, I will introduce something about Kafka. 8 00:00:25,280 --> 00:00:29,280 Then, we will compare previous research with our new findings. 9 00:00:29,280 --> 00:00:33,700 Next, we will discuss the journey of hunting bugs in Kafka Ecology. 10 00:00:33,700 --> 00:00:38,740 After that, we will uncover the hidden vulnerabilities in Kafka broker. 11 00:00:38,760 --> 00:00:41,720 And finally, explore the insights and differences. 12 00:00:43,060 --> 00:00:46,060 Okay, let's officially begin our presentation. 13 00:00:47,320 --> 00:00:49,240 So, what is Kafka? 14 00:00:49,240 --> 00:01:08,880 According to the official documentation, Apache Kafka is an open-source distributed event streaming platform widely adapted by the enterprises for building high performance data pipelines, real-time analysis, data integration systems, and critical application architectures. 15 00:01:09,520 --> 00:01:17,800 At its core, Kafka has three main parts, producers, consumers, and the Kafka cluster. 16 00:01:17,800 --> 00:01:20,120 Consumers are like the data sources. 17 00:01:20,120 --> 00:01:22,720 They send messages into the system. 18 00:01:22,720 --> 00:01:29,680 Consumers read those messages and add on them, like analyzing or storing data. 19 00:01:29,880 --> 00:01:32,640 And the Kafka cluster is a backbone. 20 00:01:32,640 --> 00:01:39,840 It handles messages, storage, reputations, and ensures everything runs smoothly at scale. 21 00:01:40,900 --> 00:01:49,420 Inside the Kafka cluster, the functions are stripped into two main parts, the data prime and the control prime. 22 00:01:49,420 --> 00:01:56,520 The control prime is in charge of chain managing all the metadata, like topics, brokers, and reputations. 23 00:01:56,900 --> 00:02:01,160 Meanwhile, the data prime is where the real action happens. 24 00:02:01,160 --> 00:02:08,180 It's handled by the brokers, which are responsible for reading from and writing to Kafka topics. 25 00:02:08,680 --> 00:02:16,100 In the control prime of Kafka, there are two different implementations of the kiss-and-save protocol. 26 00:02:16,160 --> 00:02:22,100 The older one, based on Kafka, and the newer one, known as kraft-control. 27 00:02:23,320 --> 00:02:33,160 As for the data prime, current requests fall into two categories, producer requests and flash requests. 28 00:02:33,160 --> 00:02:39,180 A producer request is used to write a data to a specific topic. 29 00:02:39,180 --> 00:02:44,840 A flash request, on the other hand, is used to write data from Kafka topics. 30 00:02:45,460 --> 00:02:55,080 These operations are all limited with the topic, making it the central component in Kafka's architecture. 31 00:02:55,760 --> 00:02:59,700 In addition, Kafka has a powerful ecology. 32 00:02:59,700 --> 00:03:03,880 The Kafka ecology is built around several core components. 33 00:03:03,880 --> 00:03:11,920 Kafka core, Kafka systems, Kafka connect, rest procedure, schema registry, and case code. 34 00:03:13,340 --> 00:03:16,670 So, are there any security risks? 35 00:03:18,360 --> 00:03:19,920 That's a good question. 36 00:03:19,920 --> 00:03:27,420 Let's now look at the known findings and see how certain protections might be bypassed in repetition. 37 00:03:28,220 --> 00:03:41,480 There is a remote code execution ability in Kafka clients, identified at CVE-2023-25194, which can be supported in components such as Red and Kafka Connect. 38 00:03:42,320 --> 00:03:59,460 The key issue is that if an attacker can control the connection string used to connect to Kafka, they might be able to trigger gmdata injection, and that will lead all the way to remote code execution. 39 00:04:00,240 --> 00:04:03,180 Here is the proof of concept. 40 00:04:03,180 --> 00:04:11,780 The program acts as a Kafka client and uses an attacker-controlled connection string to connect the Kafka server. 41 00:04:12,260 --> 00:04:18,180 The payload contains an LDAP which is the key component in this export. 42 00:04:19,280 --> 00:04:23,780 As the program ends, it ends up triggering a gmdata lookup. 43 00:04:23,780 --> 00:04:30,740 Here on the right, you can clearly see the code stack leading to the injection point. 44 00:04:30,740 --> 00:04:33,240 This is the cover of the vulnerability. 45 00:04:34,140 --> 00:04:37,760 Let's focus on the context logging process. 46 00:04:37,760 --> 00:04:43,440 It's essential to understand how the export works. 47 00:04:44,160 --> 00:04:58,200 It will initialize, subject, and construct gmdl logging model and analyze with subject, callback handler options, and finally, we'll call the logging method. 48 00:04:58,760 --> 00:05:05,400 gmdl logging model logging calls the attempt authentication method. 49 00:05:05,400 --> 00:05:09,280 Then the lookup method of the initial method is called. 50 00:05:09,860 --> 00:05:17,220 Before we move on to the next slide, I would like to briefly introduce the lookup method here. 51 00:05:17,680 --> 00:05:29,480 It's a common thing like runtime.exec, and it will look up an untransitive address and leads to RCE. 52 00:05:30,800 --> 00:05:35,360 You can use a diagram to show how the attack process. 53 00:05:35,380 --> 00:05:39,480 First, the attacker set up an evil gmdl server. 54 00:05:39,480 --> 00:05:46,860 Second, the attacker constructs the evil connection stream and passes it to the Kafka client. 55 00:05:46,860 --> 00:06:00,840 Third, the Kafka client passes the connection stream, constructs the evil logging config, passes it to the logging context, and calls the logging method of the logging context. 56 00:06:00,840 --> 00:06:09,100 Then, the logging context analyzes the gmdl logging model to authenticate the user. 57 00:06:09,100 --> 00:06:17,280 Next, the gmdl logging model loads our evil gmdl server, and the server returns something evil payload. 58 00:06:17,280 --> 00:06:20,360 Finally, the server is taken over. 59 00:06:20,460 --> 00:06:23,750 The key point is the controllable logging config. 60 00:06:24,140 --> 00:06:34,160 Kafka client allows the users to control the logging config, so the user can use an evil logging config to achieve RCE. 61 00:06:36,760 --> 00:06:48,260 In version 3.4.1, the rector introduces a backlist mechanism, and by default, it includes the gmdl logging module. 62 00:06:48,820 --> 00:06:53,680 In other words, the gmdl logging module is disabled out of the box. 63 00:06:54,340 --> 00:07:00,920 If we run the poke again, we will see the program now slower and exception. 64 00:07:01,400 --> 00:07:07,000 The error message clearly says that the gmdl logging module is not allowed. 65 00:07:08,160 --> 00:07:12,300 We can use a diagram to show how the patch was. 66 00:07:12,300 --> 00:07:22,880 When the attacker constructs evil connection stream and passes it to the Kafka client, the Kafka client will check the logging config. 67 00:07:22,880 --> 00:07:32,360 If the logging config contains an evil logging module, memory-level gmdl logging module, the Kafka client will raise an exception. 68 00:07:33,700 --> 00:07:35,720 And can we bypass? 69 00:07:36,340 --> 00:07:45,440 After understanding both the vulnerability and how the patch was, we came up with an idea. 70 00:07:45,440 --> 00:07:51,460 What if we find another logging module that can be abused in the similar way? 71 00:07:51,900 --> 00:08:03,380 If we can identify a new malicious logging module, such as some much-liked gmdl logging module, we might be able to achieve RCE once again. 72 00:08:04,040 --> 00:08:09,740 So, what are the registrations on the logging modules that we are looking for? 73 00:08:11,480 --> 00:08:15,440 First, improvement logging module. 74 00:08:15,440 --> 00:08:18,900 Second, it exists in popular javalibs. 75 00:08:19,480 --> 00:08:24,630 Third, can trigger RCE attribute flywrite, attribute flyread. 76 00:08:26,220 --> 00:08:31,190 Thanks to this idea, we found several interesting logging modules. 77 00:08:31,520 --> 00:08:36,400 The first one is a proxy logging module provided by JBoss. 78 00:08:36,760 --> 00:08:44,180 As the name suggests, it delegates an authentication request to another agent or module. 79 00:08:44,180 --> 00:08:55,460 Specifically, in its analyze method, it constructs an agent based on the specified logging module name and then analyzes it. 80 00:08:55,460 --> 00:09:03,320 During the logging phase, the proxy logging module passes the authentication process to the agent. 81 00:09:03,560 --> 00:09:07,640 Now, you might have already guessed where I am going with this. 82 00:09:08,000 --> 00:09:12,640 Yes, we can use proxy logging module to bypass the backlist. 83 00:09:13,320 --> 00:09:14,700 Here is the prologue. 84 00:09:14,700 --> 00:09:22,060 We configure the proxy logging module and set its logging name to gmdl logging method. 85 00:09:23,360 --> 00:09:33,580 Even though it is on the backlist, when we run the prologue, you can see that the logging method of a gmdl logging module is actually invoked. 86 00:09:34,540 --> 00:09:43,120 If we check the EVO gmdl server, we can find that we have bypassed the backlist and achieved RCE again. 87 00:09:45,670 --> 00:09:48,210 Here is how the bypass was. 88 00:09:48,310 --> 00:09:59,290 Proxy logging module delegates to gmdl logging module, allowing us to bypass the backlist and tickle gmdl injection, leading to RCE. 89 00:10:01,150 --> 00:10:06,590 Another interesting state of logging modules is provided by WebSphere. 90 00:10:07,070 --> 00:10:19,150 Due to time constraints, I won't go into full details, but here is the proof of concept. 91 00:10:19,150 --> 00:10:27,110 Imagine a web server deployed on WebSphere that allows users to control Kafka connection stream. 92 00:10:27,710 --> 00:10:29,030 Could we take over? 93 00:10:29,810 --> 00:10:31,590 Of course we can. 94 00:10:31,770 --> 00:10:33,470 The idea is simple. 95 00:10:33,470 --> 00:10:38,610 We prepare a consumer login configuration file. 96 00:10:39,130 --> 00:10:45,070 Then we send the first payload to instruct the web server to use our login config. 97 00:10:45,590 --> 00:10:50,790 After that, we send a second payload, which will trigger an error. 98 00:10:51,410 --> 00:11:01,180 As a result, the server writes the error message now containing malicious content to the file we specified. 99 00:11:03,610 --> 00:11:08,910 Finally, we will get a web shell and achieve RCE again. 100 00:11:10,450 --> 00:11:15,670 In addition, there's an interesting logging module named the LDAP logging module. 101 00:11:15,750 --> 00:11:18,310 It's built into the JDK. 102 00:11:18,470 --> 00:11:22,550 This logging method calls a timer authentication method. 103 00:11:22,550 --> 00:11:30,830 When authenticating the user, the logging module will first obtain name and password via a callback handler. 104 00:11:31,910 --> 00:11:34,870 Then it will check whether the password is blank. 105 00:11:34,870 --> 00:11:44,410 If not blank, it will initialize the GMDI LDAP logged context, which is a trigger GMDI injection. 106 00:11:44,750 --> 00:11:54,810 Briefly, if we can find a callback handler that can provide a password, we can trigger GMDI injection and achieve RCE. 107 00:11:56,050 --> 00:12:02,630 So our goal is to find a callback handler for the LDAP logging module. 108 00:12:03,930 --> 00:12:09,770 There are three registrations on the callback handlers that we are looking for. 109 00:12:09,870 --> 00:12:15,590 First, you should be able to handle name callback and password callback. 110 00:12:15,590 --> 00:12:20,130 Otherwise, you will receive unsupportive callback exception. 111 00:12:20,410 --> 00:12:25,850 Second, you should be able to obtain a password which is not blank. 112 00:12:25,910 --> 00:12:35,790 Most importantly, it should be in permanent authenticated callback handler, which is an interface provided by Kafka. 113 00:12:35,790 --> 00:12:40,170 Otherwise, you will receive a cluster exception. 114 00:12:40,930 --> 00:12:52,630 To be honest, it is really hard to share all three requirements at the same time, especially the last one, which greatly limited the range. 115 00:12:53,870 --> 00:12:58,070 So which vendors implement the interfaces of Kafka? 116 00:12:59,210 --> 00:13:05,550 After some registration, we found that Confluent is a great candidate. 117 00:13:05,550 --> 00:13:14,610 Confluent is the creators of Kafka and the custodians of Kafka. 118 00:13:15,310 --> 00:13:19,170 And Confluent has their released versions. 119 00:13:20,850 --> 00:13:33,970 Confluent primarily offers two versions, the community versions of Kafka, known as cp-kafka, and the commercial version called cp-server. 120 00:13:34,890 --> 00:13:41,030 As shown here, the availability exists in cp-server but not in cp-kafka. 121 00:13:41,030 --> 00:13:53,390 We tested this on November 2024 on version 7.7.1 and it was confirmed to be support flow. 122 00:13:53,390 --> 00:13:59,630 These issues have been fixed in the newer versions. 123 00:14:00,430 --> 00:14:14,190 We discovered a callback handler named filebase-dynamic-blank-callback-handler in Confluent Kafka, which reads the username and password from the local file. 124 00:14:14,850 --> 00:14:18,370 Here is a simplified code of a file callback handler. 125 00:14:18,790 --> 00:14:22,870 We can control the file name, the keys of name, and password. 126 00:14:23,310 --> 00:14:38,630 For example, if there is a file named user.conf, the file contains one or more username, password, pairs, separative, private, and password. 127 00:14:40,750 --> 00:14:44,950 This callback handler means almost a resistance. 128 00:14:47,830 --> 00:14:52,970 But the file named user.conf is created by us. 129 00:14:52,970 --> 00:14:58,110 Can we find one more common one? 130 00:14:58,570 --> 00:15:04,170 Of course, the etc password file fits our needs perfectly. 131 00:15:04,170 --> 00:15:10,570 This means we no longer need to upload a consumer user.conf. 132 00:15:10,750 --> 00:15:17,230 We just need to set the file name to etc password and keep to m the existing user. 133 00:15:17,230 --> 00:15:18,830 For example, root. 134 00:15:19,890 --> 00:15:21,770 Here is the poke. 135 00:15:26,020 --> 00:15:35,030 In the end, we can use this callback handler to trigger jmdi injection and achieve RCE. 136 00:15:36,690 --> 00:15:43,450 As shown in the diagram, it shows how the entire attack processed. 137 00:15:43,710 --> 00:15:54,770 In the third step, we can use the file-based dynamic blanker callback handler to bypass the login config track. 138 00:15:55,050 --> 00:16:02,670 And this callback handler will obtain the username and password to the LDAP login module. 139 00:16:02,670 --> 00:16:12,330 And finally, the LDAP login module will recover an evil jmdi server and finally will be taken over. 140 00:16:15,710 --> 00:16:22,490 As you can see on this slide, we are now entering a new phase of our research. 141 00:16:22,750 --> 00:16:31,210 Not just exploiting a single vulnerability, but hunting for bugs around the entire Kafka ecologic. 142 00:16:32,010 --> 00:16:42,090 In the previous chapter, we successfully triggered the jmdi injection in the Kafka client of the conventional version of Kafka. 143 00:16:43,910 --> 00:16:52,890 Can this be implemented in the real system as CVE-2023-25194? 144 00:16:53,850 --> 00:16:57,030 Let's take it step by step. 145 00:16:57,030 --> 00:17:00,870 First, can Kafka Connect be exported? 146 00:17:01,710 --> 00:17:06,670 After our testing, the answer is yes, it can be exported. 147 00:17:06,790 --> 00:17:15,130 We can follow the official Confluent Kafka documentation to install and set up a Confluent platform. 148 00:17:16,090 --> 00:17:27,130 This proof-of-concept is exploitable CVE-2023-25194, operative in Apache Kafka Connect. 149 00:17:27,470 --> 00:17:31,710 This is our new plug from Confluent Kafka Connect. 150 00:17:31,870 --> 00:17:42,090 We just need to convert it into appropriate format and then we replace it with the previously mentioned bypass payload. 151 00:17:44,490 --> 00:17:50,110 And you will finally trigger jmdi injection and achieve RCE again. 152 00:17:52,540 --> 00:17:54,480 Something else? 153 00:17:55,160 --> 00:18:00,900 Yes, let's start a journey to take over Confluent ksqlDB server. 154 00:18:01,820 --> 00:18:05,780 When we deploy the Confluent platform, there are many components. 155 00:18:06,860 --> 00:18:12,520 In the website, we can see three of those components. 156 00:18:13,460 --> 00:18:18,620 When I try to use it, I find the ksqlDB is something like DBMS. 157 00:18:19,200 --> 00:18:25,660 Since DBMS also has a lot of features, just choose this to analyze. 158 00:18:26,380 --> 00:18:29,960 And then I read documents to learn about this. 159 00:18:31,220 --> 00:18:36,120 And when I read the documents, I find an interesting issue in the GitHub. 160 00:18:36,120 --> 00:18:40,100 It says the producer is closed firstly. 161 00:18:40,520 --> 00:18:44,740 Wait a moment, why does the producer exist here? 162 00:18:46,220 --> 00:18:51,000 And I just try to try it out in our local environment. 163 00:18:52,340 --> 00:18:55,840 We can see the producer configured in logs. 164 00:18:56,260 --> 00:18:58,660 What does this mean? 165 00:18:59,460 --> 00:19:04,600 Through the insert operation, ksqlDB can produce data. 166 00:19:06,160 --> 00:19:08,960 Can we modify the producer config? 167 00:19:11,060 --> 00:19:16,640 We can see that the configuration is obtained from the session config. 168 00:19:16,640 --> 00:19:19,000 So what is the session config? 169 00:19:19,860 --> 00:19:27,540 Since there is no other place to set here, let's try, let's give a simple try. 170 00:19:28,200 --> 00:19:32,660 Unexpectedly, we successfully modified the configuration. 171 00:19:35,380 --> 00:19:39,260 And then we modify it to use our POC. 172 00:19:39,900 --> 00:19:43,240 And we finally achieve an answer each year. 173 00:19:45,330 --> 00:19:48,150 Let's watch the video demo. 174 00:20:19,970 --> 00:20:22,870 Okay, let's do a brief summary. 175 00:20:23,010 --> 00:20:33,230 Using the bypass technology, we successfully bypass confluent Kafka broker and achieve RCE on ksqlDB. 176 00:20:34,650 --> 00:20:39,590 We have taken over the confluent products of multiple cloud vendors. 177 00:20:42,900 --> 00:20:55,620 So if we can, we can attack, control Kafka client's configuration, and using the bypass tactics, we can achieve RCE. 178 00:21:00,750 --> 00:21:06,110 So next, let's uncover hidden vulnerabilities in Kafka broker. 179 00:21:06,610 --> 00:21:13,110 And in previous section, we already have a basic understanding of the Kafka ecosystem. 180 00:21:13,150 --> 00:21:18,770 And it is clear that the Kafka broker is the core component of the Kafka ecosystem. 181 00:21:19,830 --> 00:21:24,390 And also, prior to this, Kafka broker had no RCE vulnerability. 182 00:21:24,470 --> 00:21:32,270 And so if someone can find a vulnerability in such a critical and unbreakable system, and it is definitely something worth celebrating. 183 00:21:32,910 --> 00:21:36,570 And so you may be curious about how I found this vulnerability. 184 00:21:36,650 --> 00:21:39,590 And to be honest, just by accident. 185 00:21:39,750 --> 00:21:44,710 So initially, I didn't ever think that I could achieve RCE in Kafka broker. 186 00:21:44,710 --> 00:21:52,770 And as mentioned earlier, I was actually focusing on finding other issues or potential bypass method in the Kafka client. 187 00:21:52,770 --> 00:21:58,750 And at that time, I was reading the official document, looking for some suspicious configuration. 188 00:21:59,530 --> 00:22:08,590 And when I read the document, I found a very interesting feature, and that is the listeners can be added or removed dynamically. 189 00:22:09,490 --> 00:22:16,750 And also, what's more, the JS configuration of the listener can also be set dynamically. 190 00:22:16,810 --> 00:22:21,530 So this means that the Kafka broker also supports JS. 191 00:22:22,270 --> 00:22:26,270 And here, let's take some time to introduce this interesting feature. 192 00:22:26,270 --> 00:22:29,130 So first, this is a very normal request. 193 00:22:29,130 --> 00:22:38,670 And the user just sends an add listener request to the Kafka broker, and the broker receives the request and adds a new listener. 194 00:22:38,670 --> 00:22:46,150 And after that, the other Kafka client can connect to this new listener for producing or consuming message. 195 00:22:46,450 --> 00:22:55,920 But if there is a hacker, and he can just send an evil request, and the broker will receive the add listener request and try to add a new listener. 196 00:22:55,920 --> 00:23:05,760 However, the server will also trigger the JS process, and will send the gender request to the evil gender server, and finally achieve RSE. 197 00:23:06,080 --> 00:23:09,520 So first, let's set up the exploit environment. 198 00:23:09,520 --> 00:23:15,660 And we can download the binary from the official website, and then run below command to start the Kafka server. 199 00:23:15,660 --> 00:23:18,900 And now, let's explore it step by step. 200 00:23:18,900 --> 00:23:24,360 So first, we can use the Kafka config tool to retrieve the broker's configuration. 201 00:23:24,360 --> 00:23:27,820 As you can see here, there are a lot of configurations. 202 00:23:27,820 --> 00:23:31,820 And here, we should pay special attention to the broker ID. 203 00:23:31,820 --> 00:23:33,280 And here it is one. 204 00:23:33,620 --> 00:23:38,300 And here, we only need to focus on the configurations related to listener. 205 00:23:38,300 --> 00:23:43,280 So we use grab command, and you can see that now it has two ports. 206 00:23:43,280 --> 00:23:49,980 The one is the standard 9092 port, and the protocol is blantest. 207 00:23:49,980 --> 00:23:54,300 And the other is managed by craft, and called controller listener. 208 00:23:54,300 --> 00:23:57,040 And the port is 9093. 209 00:23:57,080 --> 00:24:04,480 And then, we can use nested command to check the locally listener ports, and confirm the existence of these two ports. 210 00:24:05,580 --> 00:24:12,960 And so now, we will try to add a new listener, and we just copy the previous configuration, and add a new listener. 211 00:24:12,960 --> 00:24:15,840 Listen on the 9094 port. 212 00:24:15,840 --> 00:24:24,240 And as you can see that after we send this request, and the Kafka server will receive the request, and update its configuration. 213 00:24:24,240 --> 00:24:30,100 And we can use the nested command to check the newly added ports. 214 00:24:30,920 --> 00:24:36,880 And you may have noticed that the newly added listener configuration is SASL blantest. 215 00:24:36,880 --> 00:24:38,120 So what is that? 216 00:24:38,120 --> 00:24:42,540 And it is essentially the communication protocol for brokers. 217 00:24:42,540 --> 00:24:53,840 And there are different types, such as blantest, and it is encrypted, and SASL, and it is authenticate, and also SASL. 218 00:24:54,260 --> 00:24:56,560 SASL is the encrypted protocol. 219 00:24:57,660 --> 00:25:10,000 But in fact, after we execute the command to add a new listener, essentially when we specify the new listener, use the SASL protocol, and it will throw an exception on the broker side. 220 00:25:10,000 --> 00:25:19,560 And if we look carefully, the error message, we can see that it indicates that exists the absence of JAS related configuration. 221 00:25:19,560 --> 00:25:24,620 And this is because that Kafka's authentication mechanism is based on JAS. 222 00:25:24,620 --> 00:25:32,720 And therefore, when we add listeners that requires authentication, and the system will look for corresponding JAS configuration. 223 00:25:32,720 --> 00:25:38,940 And if we properly configure and we can trigger the JAS process and finally achieve RCE. 224 00:25:39,540 --> 00:25:43,540 But the question is, how can we set the evil JAS configuration? 225 00:25:44,260 --> 00:25:49,640 And after reviewing the Kafka document again, and I just found the answer. 226 00:25:49,640 --> 00:26:00,760 We can configure it through the configuration key, and you can see the key is listener name, listener name, and .saslmechanism.sasl.js.config. 227 00:26:01,060 --> 00:26:05,520 And so now, we need to set the corresponding configuration. 228 00:26:05,520 --> 00:26:24,260 And since by default, the SASL mechanism is JASS API, so we can name it in this way, listener.name.sasl.planetize, this is our listener name, and .gssapi, this is our SASL mechanism, and .sas.js.config. 229 00:26:24,280 --> 00:26:27,560 And so we re-succeed in one shoot. 230 00:26:28,500 --> 00:26:32,700 But it didn't work, and it's through a new exception. 231 00:26:32,980 --> 00:26:38,160 But not bad, since we at least successfully configured our JAS. 232 00:26:38,660 --> 00:26:47,040 But set not equal solution and code equal clues, and I just reviewed the code, and you can see that this is our error message. 233 00:26:47,040 --> 00:26:54,520 And so here, you can see we need to set either the JSS server name or the config service name. 234 00:26:54,520 --> 00:27:03,080 And here, I choose to set this config service name, and you can see that it get from our configuration, SASL Kerberos service name. 235 00:27:03,080 --> 00:27:05,660 So here, we need to add this parameter. 236 00:27:06,540 --> 00:27:11,300 So now, you can see that we just added this configuration key, and we can add a test. 237 00:27:11,460 --> 00:27:15,540 And finally, you can see that we receive the LDAP request. 238 00:27:15,540 --> 00:27:17,860 So yeah, we finally made it. 239 00:27:17,880 --> 00:27:19,880 And there exists another solution. 240 00:27:19,880 --> 00:27:26,940 So we can simply change our SASL mechanism to plan and don't forget to modify the name. 241 00:27:26,940 --> 00:27:29,920 And we can also receive the LDAP request. 242 00:27:29,920 --> 00:27:40,300 And since now, we can just utilize the server, send the GNDI request, and the only thing we need to do is deploying an evil GNDI server, and then waiting for the shell. 243 00:27:40,820 --> 00:27:49,260 So now, I have discovered the first-ever RCE vulnerability in CapCapBroker, and no one has thought of it in this way. 244 00:27:49,420 --> 00:27:54,360 And if you look carefully, and we just exploit it in our old version of CapCap. 245 00:27:54,360 --> 00:28:00,160 And so, at that time, I just wondered that this exploit also works in the latest version. 246 00:28:00,160 --> 00:28:09,960 And then, I just choose to exploit in the version 3.4.0, and the exact version fits the CVE-2023 and 25194. 247 00:28:09,960 --> 00:28:18,100 And but when I try to exploit, and but unfortunately, it just threw an exception, and just the same exception as the CapCap plan. 248 00:28:18,100 --> 00:28:20,840 And I was very confused. 249 00:28:20,840 --> 00:28:25,640 I don't know why the patch method related to the CapCap plan also affects CapCap server. 250 00:28:25,640 --> 00:28:29,420 And I reviewed the source code, and finally, I got the answer. 251 00:28:29,420 --> 00:28:36,460 And the reason is that you can say the CapCap plan uses the loadClientContext function to load the GIS configuration. 252 00:28:36,460 --> 00:28:41,420 And it will finally call the load function, which specifies we are client. 253 00:28:41,480 --> 00:28:52,180 And however, our CapCap server will also use the loadServerContext function, it will also call the load function in the end, and it will specify our type is server. 254 00:28:52,580 --> 00:28:58,240 But our CapCap patch method is adding a restriction in the load function. 255 00:28:58,240 --> 00:29:03,160 So this means that it will influence both the server side and the client side. 256 00:29:03,360 --> 00:29:08,900 So CapCap just accidentally fixed a crucial unknown server side vulnerability. 257 00:29:08,900 --> 00:29:10,300 So what the hell? 258 00:29:11,260 --> 00:29:20,200 But since the fixed way is the same as the client, and if you remember in the previous section, and we have a bypass method in the Confluent version. 259 00:29:20,300 --> 00:29:26,720 And so this means that we can bypass and achieve RSA in the latest version of Confluent CapCap broker. 260 00:29:27,260 --> 00:29:31,940 And so first, we also need to set up the environment and just follow the guide. 261 00:29:32,820 --> 00:29:37,020 And now we need to add a port mapping to help with our testing. 262 00:29:37,020 --> 00:29:44,040 And then we can use the CapCapConfig tool to quickly verify if our server runs normally. 263 00:29:44,280 --> 00:29:54,440 And here, we first just want to test with our previous code, just want to verify whether the CapCap, the Confluent broker has patched the vulnerability. 264 00:29:54,460 --> 00:30:04,480 And we started by fetching the current listener configuration, and this is now slightly different with the previous one, and then slightly modify the port. 265 00:30:04,480 --> 00:30:12,040 But however, it shows an exception, indicating the absence of the security protocol not defined. 266 00:30:12,800 --> 00:30:19,160 And I just find the reason, and the reason is that we missed this configuration. 267 00:30:19,160 --> 00:30:26,460 And you can see that the security protocol of each listeners must be defined in this configuration. 268 00:30:26,460 --> 00:30:37,420 And in our previous CapCap broker vulnerability, and since by default, it has already defined this map, and you can see it has the SASL plan test. 269 00:30:37,420 --> 00:30:40,440 So now, we will not encounter this error. 270 00:30:40,440 --> 00:30:50,460 But however, here, this is our now map, and you can see it only has controller, plan test, plan test holds, don't have the SASL plan test. 271 00:30:50,460 --> 00:30:52,540 So this is why we failed. 272 00:30:52,540 --> 00:30:54,860 So we need to add this parameter. 273 00:30:55,520 --> 00:31:03,620 And now you can see that we just modified the listener security protocol map, and we add this mapping. 274 00:31:03,620 --> 00:31:07,660 And now we can use the listeners SASL plan test. 275 00:31:07,660 --> 00:31:11,320 You can see that yes, and we just trigger the patch logic. 276 00:31:11,320 --> 00:31:16,600 So now, we need to just bypass it using our previous method. 277 00:31:16,620 --> 00:31:30,080 And just looking back at our previous method, and you can see that the key of the bypass method is the SASL.login.callback.handle.class parameter. 278 00:31:30,340 --> 00:31:36,220 But now, here is the question, how can we set the callback handler on the broker side? 279 00:31:36,220 --> 00:31:42,340 So after reviewing the official document again, and I discovered that it can also be configured dynamically. 280 00:31:42,340 --> 00:31:54,900 And the format of the key is similar to the key format used by the listener, and called listener.name.listener.name, listener .SASL.login.callback.handle.class. 281 00:31:54,900 --> 00:32:07,680 And now, we can just add in the callback handler, and the name is listener.name.SASL.plan test.plan.SASL.login.callback.handle.class. 282 00:32:07,680 --> 00:32:12,380 And we modify the JS configuration to our previous bypass method. 283 00:32:12,380 --> 00:32:16,940 And finally, we can also receive the GenDI request. 284 00:32:16,940 --> 00:32:20,460 So this means we successfully bypassed it. 285 00:32:20,900 --> 00:32:23,280 And now, here comes to the video. 286 00:32:24,020 --> 00:32:40,880 And so first, we can run our Evo GenDI server, and we get the listener's configuration, and we can run our... first we start the listening port, waiting for the share, and we run our exploit payload, and update the configuration, update configuration, 287 00:32:40,880 --> 00:32:43,980 and finally, we receive the share. 288 00:32:43,980 --> 00:32:50,600 And you can see that we are inside our container, and this is the Confluent Kafka broker. 289 00:32:52,920 --> 00:33:06,300 So after that, we promptly reported our findings to the Kafka official team, and finally, Kafka has acknowledged this vulnerability, and this is the first-ever RCE vulnerability affecting Kafka broker. 290 00:33:06,320 --> 00:33:14,480 And we also reported this vulnerability to Confluent, and we were rewarded the highest-ever bug bounty in Confluent. 291 00:33:15,260 --> 00:33:25,310 And also, here is the patch, and it is very easy to understand, and it just disabled GenDI login module and LDAP login module by default. 292 00:33:26,680 --> 00:33:30,000 And finally, it's some defense recommendation. 293 00:33:30,740 --> 00:33:37,000 So first, if you still use the affected version of Kafka, please update now. 294 00:33:37,000 --> 00:33:43,580 And then, authentication and authorization must be enabled to prevent unauthorized sites. 295 00:33:43,820 --> 00:33:55,320 And what's more, the components in the Kafka ecosystem are very important, and usually don't need to be exposed to public internet, and therefore, it is best not to expose them publicly. 296 00:33:56,120 --> 00:33:58,400 So, are there any questions? 297 00:33:59,960 --> 00:34:05,120 And thanks again for your listening, and if you have any questions, please feel free to contact us.