start	end	text
0	1980	Hello everyone, thanks for coming.
1980	5060	I am very honored to be here to give a presentation.
5300	6670	So today, our topic is...
11700	14620	First of all, let me introduce my team.
14620	19220	We are security engineers from Alibaba County, and I am Ziyang Lin.
20280	22280	Then, let me introduce the agenda.
22280	25280	First, I will introduce something about Kafka.
25280	29280	Then, we will compare previous research with our new findings.
29280	33700	Next, we will discuss the journey of hunting bugs in Kafka Ecology.
33700	38740	After that, we will uncover the hidden vulnerabilities in Kafka broker.
38760	41720	And finally, explore the insights and differences.
43060	46060	Okay, let's officially begin our presentation.
47320	49240	So, what is Kafka?
49240	68880	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.
69520	77800	At its core, Kafka has three main parts, producers, consumers, and the Kafka cluster.
77800	80120	Consumers are like the data sources.
80120	82720	They send messages into the system.
82720	89680	Consumers read those messages and add on them, like analyzing or storing data.
89880	92640	And the Kafka cluster is a backbone.
92640	99840	It handles messages, storage, reputations, and ensures everything runs smoothly at scale.
100900	109420	Inside the Kafka cluster, the functions are stripped into two main parts, the data prime and the control prime.
109420	116520	The control prime is in charge of chain managing all the metadata, like topics, brokers, and reputations.
116900	121160	Meanwhile, the data prime is where the real action happens.
121160	128180	It's handled by the brokers, which are responsible for reading from and writing to Kafka topics.
128680	136100	In the control prime of Kafka, there are two different implementations of the kiss-and-save protocol.
136160	142100	The older one, based on Kafka, and the newer one, known as kraft-control.
143320	153160	As for the data prime, current requests fall into two categories, producer requests and flash requests.
153160	159180	A producer request is used to write a data to a specific topic.
159180	164840	A flash request, on the other hand, is used to write data from Kafka topics.
165460	175080	These operations are all limited with the topic, making it the central component in Kafka's architecture.
175760	179700	In addition, Kafka has a powerful ecology.
179700	183880	The Kafka ecology is built around several core components.
183880	191920	Kafka core, Kafka systems, Kafka connect, rest procedure, schema registry, and case code.
193340	196670	So, are there any security risks?
198360	199920	That's a good question.
199920	207420	Let's now look at the known findings and see how certain protections might be bypassed in repetition.
208220	221480	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.
222320	239460	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.
240240	243180	Here is the proof of concept.
243180	251780	The program acts as a Kafka client and uses an attacker-controlled connection string to connect the Kafka server.
252260	258180	The payload contains an LDAP which is the key component in this export.
259280	263780	As the program ends, it ends up triggering a gmdata lookup.
263780	270740	Here on the right, you can clearly see the code stack leading to the injection point.
270740	273240	This is the cover of the vulnerability.
274140	277760	Let's focus on the context logging process.
277760	283440	It's essential to understand how the export works.
284160	298200	It will initialize, subject, and construct gmdl logging model and analyze with subject, callback handler options, and finally, we'll call the logging method.
298760	305400	gmdl logging model logging calls the attempt authentication method.
305400	309280	Then the lookup method of the initial method is called.
309860	317220	Before we move on to the next slide, I would like to briefly introduce the lookup method here.
317680	329480	It's a common thing like runtime.exec, and it will look up an untransitive address and leads to RCE.
330800	335360	You can use a diagram to show how the attack process.
335380	339480	First, the attacker set up an evil gmdl server.
339480	346860	Second, the attacker constructs the evil connection stream and passes it to the Kafka client.
346860	360840	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.
360840	369100	Then, the logging context analyzes the gmdl logging model to authenticate the user.
369100	377280	Next, the gmdl logging model loads our evil gmdl server, and the server returns something evil payload.
377280	380360	Finally, the server is taken over.
380460	383750	The key point is the controllable logging config.
384140	394160	Kafka client allows the users to control the logging config, so the user can use an evil logging config to achieve RCE.
396760	408260	In version 3.4.1, the rector introduces a backlist mechanism, and by default, it includes the gmdl logging module.
408820	413680	In other words, the gmdl logging module is disabled out of the box.
414340	420920	If we run the poke again, we will see the program now slower and exception.
421400	427000	The error message clearly says that the gmdl logging module is not allowed.
428160	432300	We can use a diagram to show how the patch was.
432300	442880	When the attacker constructs evil connection stream and passes it to the Kafka client, the Kafka client will check the logging config.
442880	452360	If the logging config contains an evil logging module, memory-level gmdl logging module, the Kafka client will raise an exception.
453700	455720	And can we bypass?
456340	465440	After understanding both the vulnerability and how the patch was, we came up with an idea.
465440	471460	What if we find another logging module that can be abused in the similar way?
471900	483380	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.
484040	489740	So, what are the registrations on the logging modules that we are looking for?
491480	495440	First, improvement logging module.
495440	498900	Second, it exists in popular javalibs.
499480	504630	Third, can trigger RCE attribute flywrite, attribute flyread.
506220	511190	Thanks to this idea, we found several interesting logging modules.
511520	516400	The first one is a proxy logging module provided by JBoss.
516760	524180	As the name suggests, it delegates an authentication request to another agent or module.
524180	535460	Specifically, in its analyze method, it constructs an agent based on the specified logging module name and then analyzes it.
535460	543320	During the logging phase, the proxy logging module passes the authentication process to the agent.
543560	547640	Now, you might have already guessed where I am going with this.
548000	552640	Yes, we can use proxy logging module to bypass the backlist.
553320	554700	Here is the prologue.
554700	562060	We configure the proxy logging module and set its logging name to gmdl logging method.
563360	573580	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.
574540	583120	If we check the EVO gmdl server, we can find that we have bypassed the backlist and achieved RCE again.
585670	588210	Here is how the bypass was.
588310	599290	Proxy logging module delegates to gmdl logging module, allowing us to bypass the backlist and tickle gmdl injection, leading to RCE.
601150	606590	Another interesting state of logging modules is provided by WebSphere.
607070	619150	Due to time constraints, I won't go into full details, but here is the proof of concept.
619150	627110	Imagine a web server deployed on WebSphere that allows users to control Kafka connection stream.
627710	629030	Could we take over?
629810	631590	Of course we can.
631770	633470	The idea is simple.
633470	638610	We prepare a consumer login configuration file.
639130	645070	Then we send the first payload to instruct the web server to use our login config.
645590	650790	After that, we send a second payload, which will trigger an error.
651410	661180	As a result, the server writes the error message now containing malicious content to the file we specified.
663610	668910	Finally, we will get a web shell and achieve RCE again.
670450	675670	In addition, there's an interesting logging module named the LDAP logging module.
675750	678310	It's built into the JDK.
678470	682550	This logging method calls a timer authentication method.
682550	690830	When authenticating the user, the logging module will first obtain name and password via a callback handler.
691910	694870	Then it will check whether the password is blank.
694870	704410	If not blank, it will initialize the GMDI LDAP logged context, which is a trigger GMDI injection.
704750	714810	Briefly, if we can find a callback handler that can provide a password, we can trigger GMDI injection and achieve RCE.
716050	722630	So our goal is to find a callback handler for the LDAP logging module.
723930	729770	There are three registrations on the callback handlers that we are looking for.
729870	735590	First, you should be able to handle name callback and password callback.
735590	740130	Otherwise, you will receive unsupportive callback exception.
740410	745850	Second, you should be able to obtain a password which is not blank.
745910	755790	Most importantly, it should be in permanent authenticated callback handler, which is an interface provided by Kafka.
755790	760170	Otherwise, you will receive a cluster exception.
760930	772630	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.
773870	778070	So which vendors implement the interfaces of Kafka?
779210	785550	After some registration, we found that Confluent is a great candidate.
785550	794610	Confluent is the creators of Kafka and the custodians of Kafka.
795310	799170	And Confluent has their released versions.
800850	813970	Confluent primarily offers two versions, the community versions of Kafka, known as cp-kafka, and the commercial version called cp-server.
814890	821030	As shown here, the availability exists in cp-server but not in cp-kafka.
821030	833390	We tested this on November 2024 on version 7.7.1 and it was confirmed to be support flow.
833390	839630	These issues have been fixed in the newer versions.
840430	854190	We discovered a callback handler named filebase-dynamic-blank-callback-handler in Confluent Kafka, which reads the username and password from the local file.
854850	858370	Here is a simplified code of a file callback handler.
858790	862870	We can control the file name, the keys of name, and password.
863310	878630	For example, if there is a file named user.conf, the file contains one or more username, password, pairs, separative, private, and password.
880750	884950	This callback handler means almost a resistance.
887830	892970	But the file named user.conf is created by us.
892970	898110	Can we find one more common one?
898570	904170	Of course, the etc password file fits our needs perfectly.
904170	910570	This means we no longer need to upload a consumer user.conf.
910750	917230	We just need to set the file name to etc password and keep to m the existing user.
917230	918830	For example, root.
919890	921770	Here is the poke.
926020	935030	In the end, we can use this callback handler to trigger jmdi injection and achieve RCE.
936690	943450	As shown in the diagram, it shows how the entire attack processed.
943710	954770	In the third step, we can use the file-based dynamic blanker callback handler to bypass the login config track.
955050	962670	And this callback handler will obtain the username and password to the LDAP login module.
962670	972330	And finally, the LDAP login module will recover an evil jmdi server and finally will be taken over.
975710	982490	As you can see on this slide, we are now entering a new phase of our research.
982750	991210	Not just exploiting a single vulnerability, but hunting for bugs around the entire Kafka ecologic.
992010	1002090	In the previous chapter, we successfully triggered the jmdi injection in the Kafka client of the conventional version of Kafka.
1003910	1012890	Can this be implemented in the real system as CVE-2023-25194?
1013850	1017030	Let's take it step by step.
1017030	1020870	First, can Kafka Connect be exported?
1021710	1026670	After our testing, the answer is yes, it can be exported.
1026790	1035130	We can follow the official Confluent Kafka documentation to install and set up a Confluent platform.
1036090	1047130	This proof-of-concept is exploitable CVE-2023-25194, operative in Apache Kafka Connect.
1047470	1051710	This is our new plug from Confluent Kafka Connect.
1051870	1062090	We just need to convert it into appropriate format and then we replace it with the previously mentioned bypass payload.
1064490	1070110	And you will finally trigger jmdi injection and achieve RCE again.
1072540	1074480	Something else?
1075160	1080900	Yes, let's start a journey to take over Confluent ksqlDB server.
1081820	1085780	When we deploy the Confluent platform, there are many components.
1086860	1092520	In the website, we can see three of those components.
1093460	1098620	When I try to use it, I find the ksqlDB is something like DBMS.
1099200	1105660	Since DBMS also has a lot of features, just choose this to analyze.
1106380	1109960	And then I read documents to learn about this.
1111220	1116120	And when I read the documents, I find an interesting issue in the GitHub.
1116120	1120100	It says the producer is closed firstly.
1120520	1124740	Wait a moment, why does the producer exist here?
1126220	1131000	And I just try to try it out in our local environment.
1132340	1135840	We can see the producer configured in logs.
1136260	1138660	What does this mean?
1139460	1144600	Through the insert operation, ksqlDB can produce data.
1146160	1148960	Can we modify the producer config?
1151060	1156640	We can see that the configuration is obtained from the session config.
1156640	1159000	So what is the session config?
1159860	1167540	Since there is no other place to set here, let's try, let's give a simple try.
1168200	1172660	Unexpectedly, we successfully modified the configuration.
1175380	1179260	And then we modify it to use our POC.
1179900	1183240	And we finally achieve an answer each year.
1185330	1188150	Let's watch the video demo.
1219970	1222870	Okay, let's do a brief summary.
1223010	1233230	Using the bypass technology, we successfully bypass confluent Kafka broker and achieve RCE on ksqlDB.
1234650	1239590	We have taken over the confluent products of multiple cloud vendors.
1242900	1255620	So if we can, we can attack, control Kafka client's configuration, and using the bypass tactics, we can achieve RCE.
1260750	1266110	So next, let's uncover hidden vulnerabilities in Kafka broker.
1266610	1273110	And in previous section, we already have a basic understanding of the Kafka ecosystem.
1273150	1278770	And it is clear that the Kafka broker is the core component of the Kafka ecosystem.
1279830	1284390	And also, prior to this, Kafka broker had no RCE vulnerability.
1284470	1292270	And so if someone can find a vulnerability in such a critical and unbreakable system, and it is definitely something worth celebrating.
1292910	1296570	And so you may be curious about how I found this vulnerability.
1296650	1299590	And to be honest, just by accident.
1299750	1304710	So initially, I didn't ever think that I could achieve RCE in Kafka broker.
1304710	1312770	And as mentioned earlier, I was actually focusing on finding other issues or potential bypass method in the Kafka client.
1312770	1318750	And at that time, I was reading the official document, looking for some suspicious configuration.
1319530	1328590	And when I read the document, I found a very interesting feature, and that is the listeners can be added or removed dynamically.
1329490	1336750	And also, what's more, the JS configuration of the listener can also be set dynamically.
1336810	1341530	So this means that the Kafka broker also supports JS.
1342270	1346270	And here, let's take some time to introduce this interesting feature.
1346270	1349130	So first, this is a very normal request.
1349130	1358670	And the user just sends an add listener request to the Kafka broker, and the broker receives the request and adds a new listener.
1358670	1366150	And after that, the other Kafka client can connect to this new listener for producing or consuming message.
1366450	1375920	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.
1375920	1385760	However, the server will also trigger the JS process, and will send the gender request to the evil gender server, and finally achieve RSE.
1386080	1389520	So first, let's set up the exploit environment.
1389520	1395660	And we can download the binary from the official website, and then run below command to start the Kafka server.
1395660	1398900	And now, let's explore it step by step.
1398900	1404360	So first, we can use the Kafka config tool to retrieve the broker's configuration.
1404360	1407820	As you can see here, there are a lot of configurations.
1407820	1411820	And here, we should pay special attention to the broker ID.
1411820	1413280	And here it is one.
1413620	1418300	And here, we only need to focus on the configurations related to listener.
1418300	1423280	So we use grab command, and you can see that now it has two ports.
1423280	1429980	The one is the standard 9092 port, and the protocol is blantest.
1429980	1434300	And the other is managed by craft, and called controller listener.
1434300	1437040	And the port is 9093.
1437080	1444480	And then, we can use nested command to check the locally listener ports, and confirm the existence of these two ports.
1445580	1452960	And so now, we will try to add a new listener, and we just copy the previous configuration, and add a new listener.
1452960	1455840	Listen on the 9094 port.
1455840	1464240	And as you can see that after we send this request, and the Kafka server will receive the request, and update its configuration.
1464240	1470100	And we can use the nested command to check the newly added ports.
1470920	1476880	And you may have noticed that the newly added listener configuration is SASL blantest.
1476880	1478120	So what is that?
1478120	1482540	And it is essentially the communication protocol for brokers.
1482540	1493840	And there are different types, such as blantest, and it is encrypted, and SASL, and it is authenticate, and also SASL.
1494260	1496560	SASL is the encrypted protocol.
1497660	1510000	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.
1510000	1519560	And if we look carefully, the error message, we can see that it indicates that exists the absence of JAS related configuration.
1519560	1524620	And this is because that Kafka's authentication mechanism is based on JAS.
1524620	1532720	And therefore, when we add listeners that requires authentication, and the system will look for corresponding JAS configuration.
1532720	1538940	And if we properly configure and we can trigger the JAS process and finally achieve RCE.
1539540	1543540	But the question is, how can we set the evil JAS configuration?
1544260	1549640	And after reviewing the Kafka document again, and I just found the answer.
1549640	1560760	We can configure it through the configuration key, and you can see the key is listener name, listener name, and .saslmechanism.sasl.js.config.
1561060	1565520	And so now, we need to set the corresponding configuration.
1565520	1584260	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.
1584280	1587560	And so we re-succeed in one shoot.
1588500	1592700	But it didn't work, and it's through a new exception.
1592980	1598160	But not bad, since we at least successfully configured our JAS.
1598660	1607040	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.
1607040	1614520	And so here, you can see we need to set either the JSS server name or the config service name.
1614520	1623080	And here, I choose to set this config service name, and you can see that it get from our configuration, SASL Kerberos service name.
1623080	1625660	So here, we need to add this parameter.
1626540	1631300	So now, you can see that we just added this configuration key, and we can add a test.
1631460	1635540	And finally, you can see that we receive the LDAP request.
1635540	1637860	So yeah, we finally made it.
1637880	1639880	And there exists another solution.
1639880	1646940	So we can simply change our SASL mechanism to plan and don't forget to modify the name.
1646940	1649920	And we can also receive the LDAP request.
1649920	1660300	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.
1660820	1669260	So now, I have discovered the first-ever RCE vulnerability in CapCapBroker, and no one has thought of it in this way.
1669420	1674360	And if you look carefully, and we just exploit it in our old version of CapCap.
1674360	1680160	And so, at that time, I just wondered that this exploit also works in the latest version.
1680160	1689960	And then, I just choose to exploit in the version 3.4.0, and the exact version fits the CVE-2023 and 25194.
1689960	1698100	And but when I try to exploit, and but unfortunately, it just threw an exception, and just the same exception as the CapCap plan.
1698100	1700840	And I was very confused.
1700840	1705640	I don't know why the patch method related to the CapCap plan also affects CapCap server.
1705640	1709420	And I reviewed the source code, and finally, I got the answer.
1709420	1716460	And the reason is that you can say the CapCap plan uses the loadClientContext function to load the GIS configuration.
1716460	1721420	And it will finally call the load function, which specifies we are client.
1721480	1732180	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.
1732580	1738240	But our CapCap patch method is adding a restriction in the load function.
1738240	1743160	So this means that it will influence both the server side and the client side.
1743360	1748900	So CapCap just accidentally fixed a crucial unknown server side vulnerability.
1748900	1750300	So what the hell?
1751260	1760200	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.
1760300	1766720	And so this means that we can bypass and achieve RSA in the latest version of Confluent CapCap broker.
1767260	1771940	And so first, we also need to set up the environment and just follow the guide.
1772820	1777020	And now we need to add a port mapping to help with our testing.
1777020	1784040	And then we can use the CapCapConfig tool to quickly verify if our server runs normally.
1784280	1794440	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.
1794460	1804480	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.
1804480	1812040	But however, it shows an exception, indicating the absence of the security protocol not defined.
1812800	1819160	And I just find the reason, and the reason is that we missed this configuration.
1819160	1826460	And you can see that the security protocol of each listeners must be defined in this configuration.
1826460	1837420	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.
1837420	1840440	So now, we will not encounter this error.
1840440	1850460	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.
1850460	1852540	So this is why we failed.
1852540	1854860	So we need to add this parameter.
1855520	1863620	And now you can see that we just modified the listener security protocol map, and we add this mapping.
1863620	1867660	And now we can use the listeners SASL plan test.
1867660	1871320	You can see that yes, and we just trigger the patch logic.
1871320	1876600	So now, we need to just bypass it using our previous method.
1876620	1890080	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.
1890340	1896220	But now, here is the question, how can we set the callback handler on the broker side?
1896220	1902340	So after reviewing the official document again, and I discovered that it can also be configured dynamically.
1902340	1914900	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.
1914900	1927680	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.
1927680	1932380	And we modify the JS configuration to our previous bypass method.
1932380	1936940	And finally, we can also receive the GenDI request.
1936940	1940460	So this means we successfully bypassed it.
1940900	1943280	And now, here comes to the video.
1944020	1960880	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,
1960880	1963980	and finally, we receive the share.
1963980	1970600	And you can see that we are inside our container, and this is the Confluent Kafka broker.
1972920	1986300	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.
1986320	1994480	And we also reported this vulnerability to Confluent, and we were rewarded the highest-ever bug bounty in Confluent.
1995260	2005310	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.
2006680	2010000	And finally, it's some defense recommendation.
2010740	2017000	So first, if you still use the affected version of Kafka, please update now.
2017000	2023580	And then, authentication and authorization must be enabled to prevent unauthorized sites.
2023820	2035320	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.
2036120	2038400	So, are there any questions?
2039960	2045120	And thanks again for your listening, and if you have any questions, please feel free to contact us.
