start	end	text
0	7140	We know that bots are everywhere, they're scanning your servers, they're doing it fast, and
7140	18420	database servers is obviously a big target. So we have created a high interaction MySQL
18420	28160	honeypot. So we create a tool that mimics the database, implements MySQL protocol, and those
28160	37500	bots start connecting to this honeypot. So we need to understand the MySQL protocol. And
37500	46160	MySQL protocol, unlike other database protocols, actually a server initiated. So if we just
46160	53700	start a TCP server, then it will not be enough. If you connect to your MySQL server using
53700	62060	Telnet on the port 3306, you will see this. And this is what MySQL server provides for the
62060	68460	client to be able to connect. It specifies version, it specifies fault, it specifies client
68460	78120	plugin. So listening to the port, a TCP server is not enough. So what we did to create the
78120	87560	high interaction MySQL honeypot is we used the Python module. The Python provides, there's a
87560	93540	module called MySQL mimic. It implements MySQL protocol, it's a really powerful thing, and you
93540	101960	can do a lot of things with that. So from there, we started the honeypot, and we start receiving
101960	109000	the connections. So you start the honeypot as a fake MySQL server on an open port from the
109000	115500	internet. And you start receiving the connections. And you can see a lot of information about the
115500	123800	connection actually. Like the HTTP protocol, MySQL protocol also have this client version
123800	130980	recorded and stuff like that. So this is called attributes. MySQL provides a lot of attributes as
131080	136040	a part of the connection. That's part of protocol. We have client version, OS, and stuff
136040	142320	like that. So we started the honeypot and we immediately see the fingerprints of the
142320	148440	connections. And you can see the version of the client library, you can see the operating
148440	156820	system, you can see all other stuff. This is very useful actually. Now from there, the part
156820	169960	two is what kind of attacks we have. We have seen from this honeypot, we see two major
169960	176640	attacks on MySQL. The first is an attempt to own MySQL server and create a backdoor. This
176640	181640	actually pretty well-known attack, and there's a blog post about that. What is interesting
181640	190840	about that is we can see right away that it's using a very old MySQL client version. It
190840	197400	actually only works for older servers as well. So the second is even more interesting
197400	204840	attack. It's a ransomware. It tries to download your data, basically brute force the
204840	213740	password first, then try to download the data, and then drops the databases and asks for
213740	219860	ransom. So this is exactly the same thing. We see the fingerprints. We see what OS version,
219860	229940	we see what the client is using. So now, from there, we started an atomic version of the
229940	239080	honeypot. Honeypot that strikes back. So what we want to do, our goal is actually interact
239080	245880	with those attacks. And our goal was to see what they are doing, how they do that, and
245880	253780	potentially download the malicious code that they are using. So our atomic honeypot now
253780	264640	strikes back. What do we have? So we have been juggling with different CVEs in MySQL client.
265020	274760	And we have arbitrary file read, which is super old issue. We have the remote code execution
274760	283760	where MySQL server attacks you. We actually found that issue a year ago, 2023. We have
283780	294380	presented it, and we can use that to actually execute code on the client. And then finally,
294380	301620	this year we have found another issue in MySQL client utility. We reported it to Oracle. This
301620	313360	is the second remote code execution in MySQL client. All right. So MySQL server attacks MySQL
313360	321420	client. This is how it works. There are two things here. The first thing is that we have a MySQL
321420	329320	client arbitrary file read, and we create a server, and then your client connects to the server, and
329320	338900	the server requests a file. So we can have an arbitrary file read from the client. The second is
338900	344360	the one that we found a year ago, and we presented it last year. There are lots of details
344360	350920	there. And basically, the prerequisite of this attack is that you need to have the shared
350920	357460	library uploaded to the client first. Then, whatever the connection will be established, you
357460	365580	can actually take that client connection to execute your shared library. You don't need to
366240	374080	execute the shared library itself. You just need to have that file on the client. And finally, we
374080	380520	have found this year, we have found a new issue in MySQL client utility, and then I will
380520	387980	invite Martin, my colleague Martin, to explain how it works. And this is the first time we are
387980	392280	releasing the details about the CVE. Martin?
394250	402800	Hi. So let's jump into this CVE. As you probably know, MySQL dump is a tool which allows you to
402800	412360	produce logical backups of a database, basic script tables, and other objects and data to be
412360	421700	transferred to another server. So this is an example how you can use MySQL dump together with
421700	429480	MySQL. You just pipe the output of MySQL dump to MySQL to recreate a database on another
429480	435720	server. And this is pretty close to what the official documentation says. Where is the
435720	443500	problem? The MySQL utility allows you to use so-called meta comments. For example, if you do
443500	449880	backslash, exclamation mark, and then space in the comment, it's going to execute a shell
449880	457940	comment on a computer where the MySQL tool is running. So the CVE itself is about tricking MySQL
457940	465700	dump to emit such a shell comment, for example. So how this works exactly? By default, MySQL
466340	474280	dump tries to process everything it receives from a server, but it's not the case for the version. As
474280	480380	you can see, there is a version string coming from a server, and it is emitted as a comment in the
480380	488620	output of MySQL dump. But this is not processed, this is not sanitized, and it just is sent back to
488620	495620	output as is. We can leverage this by simply creating our own server, the MySQL server.
495720	501360	So this is a patched version of a server. As you can see here, I just replaced a version with a
501360	507300	hard-coded string, a new line, and then my comment of choice to be executed on the machine. Here,
507300	513180	just create a file. And if you could tell that to this patched server, you will see this. In red,
513180	521980	you see our comment. And then, this is output of a MySQL dump. We have a common execution for
521980	531520	this vulnerability. All we need to do is to provide a fake server. So, we have created Honeypot,
531520	539980	which is a Python code, which allows you to exploit this specific vulnerability and also the
539980	548760	plugin-loading vulnerability by passing specific configuration options to this Honeypot. The goal
548760	556080	is simple. We try to run code on the clients who connect to our Honeypot by leveraging these
556600	570200	vulnerabilities. And here's a demo. So, let's see. We have a payload script, a VBS script, which
570200	575920	will be running on Windows, which just pops up a message, you have been pwned. Now, we start our
575920	589800	Honeypot and pass the payload. And once... also, we start the HTTP server. And once the MySQL dump
589800	598500	is executed on Windows now, the version is 36, which is one version before the latest, we get this
598500	604800	pwned message. That's it. Back to you, Alex.
605600	619620	Thank you very much. Alright, so now we successfully pwned the client. We were actually trying to
619620	630980	figure out and scratching our heads, how do we actually attack those bad guys? So, back to the two
630980	639160	attacks that we have been working on. The first attack, this is what we have captured, a
639160	650320	fingerprint. Right? So, from the fingerprint itself, we can already see what we can or cannot do. So,
650320	656420	arbitrary file read, we know this is old version. We know that it will work. Remote code execution
656420	662760	with a plugin. We don't know. We will try it out. And there is no MySQL dump in this particular
662760	671680	attack, so we will not be able to use the newest version. So, how do we use the arbitrary file read?
671680	676840	Arbitrary file read is super easy. There is a tool that you can download from the internet, from the
676840	684160	GitHub. You start this tool and you simply specify the file that you want to download from the
684160	690580	client. Again, the client will be connecting to the server, this is fake server, and then we will be
690580	701560	able to read the file. So, this is how the client arbitrary file read works. I will go through this
701560	714140	real quick. So, you have this, um, uh, I download this tool, I start this tool on port 3306 and I
715020	724040	request a password. And now I'm connecting from my machine with the old version of MySQL, uh, and I
724040	732900	connect into this fake server and here I go. I got the file. So, I obtain this file. This is an old
732900	745260	attack. Now, how can we use that? What we want to do is we want to first understand which version of
745260	752920	Windows those attackers, those bots, are using. There are a number of, um, ways how you can
752920	760060	determine the version of Windows by downloading the file. So, we started this file list and we
760060	767720	determined that this is really old version of Windows. This is Windows server 2003. Alright, so
767720	774960	with this attack, we were able to understand and get more details about what the attackers are
774960	783620	using. Now, let's try the remote code execution. The remote code execution is actually on
783620	790920	Windows you need DLL. We need to deliver that DLL to the attacker's machines, to the client, to be
790920	802400	able to trigger it. So, we started to think, how do we deliver this code? Again, DLL doesn't need to
802400	809440	be triggered on the client. We are triggering through the remote code execution. What we did is
809440	817560	we collected the fingerprint, the actual commands that the server, the client, is running, is
817560	824980	trying to run on the server. And we can see that what they are trying to do is they are trying to
824980	834140	download the malicious code on the server. So, they are running an FTP server on their own
834140	841320	machine. And we know the password, the username, and the port of the server. So, we started
841320	850900	creating the simulation. Here's our plan of attack. We will upload the DDL to a public location on
850900	860580	the client. On the actual server, Windows 2003. And then we will run the honeypot, wait for the
860580	865700	connection, and through the connection we will trigger that DLL so we will have the remote code
865700	875240	execution. So, we created this RCE via the simulation. So, this is how it could work. First of
875240	883460	all, we have, we are connecting to FTP server here. Simulating that we are connecting to the
883460	896480	actual machine. We, we do the demo demo, now we will put our evil DLL. And now, after we put
896480	905220	the evil DLL in a public location, then we will start the server, the honeypot. So, we will
905240	914820	start the server. Uh, this is the startup script. We specify the plugin dir, public documents, and
914820	925160	then this thing will actually trigger the execution of our DLL via the directory traversal. I don't
925160	931520	have much time to explain this attack, but this has been explained, uh, last year. You can
931520	937860	actually see the recording from the HIDBI. Basically, there is a plugin dir in my SQL and the
937860	944820	file name, and we use the directory traversal to actually trigger DLL open, which, or, or load
944820	951820	library on Windows, which is in the server. Now, I'm listening on the port, and now here's my
951820	961500	DDL. My DDL is displaying the, um, the text and actually create, uh, the, um, um, uh,
962420	971800	dialogue. Here's how it works. So, we have this MySQL command line utility, and we have the evil
971800	982740	DLL, uh, uploaded to the client. Now, the client in this simulation, that's the bad actor, they are
982740	989700	connecting to us. And here's, here we go. We actually executed the code, remote code
989700	1001640	execution. Thank you. Alright, so this is done. We demonstrated arbitrary file read, we
1001640	1009360	demonstrated remote code execution, uh, with a plugin. So, the second attack is even more
1009360	1018340	interesting. Now, from the fingerprint, what do we see? We see this is later versions of MySQL
1018340	1026320	client. We know that this remote code execution via plugin will not work. But, what we see
1026320	1033500	immediately is that it's using MySQL dump. This is the utility, we actually found a way to, to
1033500	1040100	do the, the code execution. And then again, we were scratching our heads, and then we decide,
1040100	1045740	well, let's collect more information. Let's understand how this attack is being, uh,
1045740	1053600	executed. So, this is what we see. The, the application that connects to, uh, our server,
1053600	1061880	right? It, um, uh, connects to the server, do the show databases, and then what it will do is it
1061880	1072840	will run, it will execute MySQL dump utility and, uh, pass the database and the table name.
1072840	1084220	So, basically what it do, the, the goal of this thing is to download the database so that they
1084220	1091700	can actually claim that they download your data. But, we can see that they're only
1091700	1100220	downloading ten records. So, don't pay, obviously, right? Don't pay. Those guys don't
1100220	1104980	have your data. They claim that they have downloaded, backed it up, backed your
1104980	1113820	database, but they didn't. They only have ten records. Right? And then, from here, we
1113820	1120420	were started brainstorming. Can we download the code via arbitrary file rate? No. Can we
1120420	1126480	execute code via plugin? Actually, no as well. Right? We know because this is the newer
1126480	1132460	versions. So, we started looking again, how this attack is being handled. So, we see
1132460	1138040	that they're using MySQL, MyADB connector, right? This is from the fingerprint. This should
1138040	1144700	be some application there, right? And then suddenly, MySQL dump connects to our server. So,
1144700	1152240	they probably do some execution of the MySQL dump and then we see back, we see that the
1152240	1161140	application connects back. So, we also see this. Again, we are providing the server. Whatever
1161140	1168120	client will execute, we will see immediately. And this is what we see. This is our table that
1168120	1176340	we generated. It's sending it up, up, back to us. So, maybe, if this is what they're doing,
1176340	1184760	maybe we can actually do a command injection. And, we started experimenting with this. We
1184760	1190960	created a fake database. A schema name is a database in MySQL. We created this, a
1190960	1200040	classical command injection. And, uh, we were surprised. It actually worked. So, we use the
1200040	1207640	command injection on this client attack, right? On this bot, just like this, and we receive all
1207640	1214300	the information, uh, out of this command back to us. So, we downloaded the evil code from
1214300	1222320	those attackers. This is how it is looking like. It's a MySQL dump. We have a command
1222320	1229740	injection here and here's what we see. We got the evil code. So, it's a Python script. It's a
1229740	1237920	Python script that connects to your database, try to brute force the password, and then, uh,
1237920	1243660	execute the MySQL dump. The multiple injections. We were looking at this code and we were
1243660	1249980	like, well, there are multiple places where you can execute the command. Alright, so, we
1249980	1259200	successfully, we achieved our goal, but not the way we thought originally. We executed the
1259200	1267980	command injection. How do you try that at home? Uh, I'm pretty sure this will be fixed shortly,
1267980	1274800	so you need to try it right now if you want to see what it looks like. Uh, and you don't even
1274800	1282520	need the tool. You can start a MySQL database server, any version. You will create a root
1282520	1290000	with no password. This is a born version of, of MySQL server, right? You don't care if they
1290000	1295760	will be downloading your data. Uh, I'm done almost. And then you open that and this is the
1295760	1302860	injections that you will do. Create database, put it in a backticks, and that's it. This is
1302860	1310640	how you will be able to attack, uh, the bad guys. Alright, this is done. All done. So, new
1310640	1313460	CV, details, and thank you.
