We know that bots are everywhere, they're scanning your servers, they're doing it fast, and database servers is obviously a big target. So we have created a high interaction MySQL honeypot. So we create a tool that mimics the database, implements MySQL protocol, and those bots start connecting to this honeypot. So we need to understand the MySQL protocol. And MySQL protocol, unlike other database protocols, actually a server initiated. So if we just start a TCP server, then it will not be enough. If you connect to your MySQL server using Telnet on the port 3306, you will see this. And this is what MySQL server provides for the client to be able to connect. It specifies version, it specifies fault, it specifies client plugin. So listening to the port, a TCP server is not enough. So what we did to create the high interaction MySQL honeypot is we used the Python module. The Python provides, there's a module called MySQL mimic. It implements MySQL protocol, it's a really powerful thing, and you can do a lot of things with that. So from there, we started the honeypot, and we start receiving the connections. So you start the honeypot as a fake MySQL server on an open port from the internet. And you start receiving the connections. And you can see a lot of information about the connection actually. Like the HTTP protocol, MySQL protocol also have this client version recorded and stuff like that. So this is called attributes. MySQL provides a lot of attributes as a part of the connection. That's part of protocol. We have client version, OS, and stuff like that. So we started the honeypot and we immediately see the fingerprints of the connections. And you can see the version of the client library, you can see the operating system, you can see all other stuff. This is very useful actually. Now from there, the part two is what kind of attacks we have. We have seen from this honeypot, we see two major attacks on MySQL. The first is an attempt to own MySQL server and create a backdoor. This actually pretty well-known attack, and there's a blog post about that. What is interesting about that is we can see right away that it's using a very old MySQL client version. It actually only works for older servers as well. So the second is even more interesting attack. It's a ransomware. It tries to download your data, basically brute force the password first, then try to download the data, and then drops the databases and asks for ransom. So this is exactly the same thing. We see the fingerprints. We see what OS version, we see what the client is using. So now, from there, we started an atomic version of the honeypot. Honeypot that strikes back. So what we want to do, our goal is actually interact with those attacks. And our goal was to see what they are doing, how they do that, and potentially download the malicious code that they are using. So our atomic honeypot now strikes back. What do we have? So we have been juggling with different CVEs in MySQL client. And we have arbitrary file read, which is super old issue. We have the remote code execution where MySQL server attacks you. We actually found that issue a year ago, 2023. We have presented it, and we can use that to actually execute code on the client. And then finally, this year we have found another issue in MySQL client utility. We reported it to Oracle. This is the second remote code execution in MySQL client. All right. So MySQL server attacks MySQL client. This is how it works. There are two things here. The first thing is that we have a MySQL client arbitrary file read, and we create a server, and then your client connects to the server, and the server requests a file. So we can have an arbitrary file read from the client. The second is the one that we found a year ago, and we presented it last year. There are lots of details there. And basically, the prerequisite of this attack is that you need to have the shared library uploaded to the client first. Then, whatever the connection will be established, you can actually take that client connection to execute your shared library. You don't need to execute the shared library itself. You just need to have that file on the client. And finally, we have found this year, we have found a new issue in MySQL client utility, and then I will invite Martin, my colleague Martin, to explain how it works. And this is the first time we are releasing the details about the CVE. Martin? Hi. So let's jump into this CVE. As you probably know, MySQL dump is a tool which allows you to produce logical backups of a database, basic script tables, and other objects and data to be transferred to another server. So this is an example how you can use MySQL dump together with MySQL. You just pipe the output of MySQL dump to MySQL to recreate a database on another server. And this is pretty close to what the official documentation says. Where is the problem? The MySQL utility allows you to use so-called meta comments. For example, if you do backslash, exclamation mark, and then space in the comment, it's going to execute a shell comment on a computer where the MySQL tool is running. So the CVE itself is about tricking MySQL dump to emit such a shell comment, for example. So how this works exactly? By default, MySQL dump tries to process everything it receives from a server, but it's not the case for the version. As you can see, there is a version string coming from a server, and it is emitted as a comment in the output of MySQL dump. But this is not processed, this is not sanitized, and it just is sent back to output as is. We can leverage this by simply creating our own server, the MySQL server. So this is a patched version of a server. As you can see here, I just replaced a version with a hard-coded string, a new line, and then my comment of choice to be executed on the machine. Here, just create a file. And if you could tell that to this patched server, you will see this. In red, you see our comment. And then, this is output of a MySQL dump. We have a common execution for this vulnerability. All we need to do is to provide a fake server. So, we have created Honeypot, which is a Python code, which allows you to exploit this specific vulnerability and also the plugin-loading vulnerability by passing specific configuration options to this Honeypot. The goal is simple. We try to run code on the clients who connect to our Honeypot by leveraging these vulnerabilities. And here's a demo. So, let's see. We have a payload script, a VBS script, which will be running on Windows, which just pops up a message, you have been pwned. Now, we start our Honeypot and pass the payload. And once... also, we start the HTTP server. And once the MySQL dump is executed on Windows now, the version is 36, which is one version before the latest, we get this pwned message. That's it. Back to you, Alex. Thank you very much. Alright, so now we successfully pwned the client. We were actually trying to figure out and scratching our heads, how do we actually attack those bad guys? So, back to the two attacks that we have been working on. The first attack, this is what we have captured, a fingerprint. Right? So, from the fingerprint itself, we can already see what we can or cannot do. So, arbitrary file read, we know this is old version. We know that it will work. Remote code execution with a plugin. We don't know. We will try it out. And there is no MySQL dump in this particular attack, so we will not be able to use the newest version. So, how do we use the arbitrary file read? Arbitrary file read is super easy. There is a tool that you can download from the internet, from the GitHub. You start this tool and you simply specify the file that you want to download from the client. Again, the client will be connecting to the server, this is fake server, and then we will be able to read the file. So, this is how the client arbitrary file read works. I will go through this real quick. So, you have this, um, uh, I download this tool, I start this tool on port 3306 and I request a password. And now I'm connecting from my machine with the old version of MySQL, uh, and I connect into this fake server and here I go. I got the file. So, I obtain this file. This is an old attack. Now, how can we use that? What we want to do is we want to first understand which version of Windows those attackers, those bots, are using. There are a number of, um, ways how you can determine the version of Windows by downloading the file. So, we started this file list and we determined that this is really old version of Windows. This is Windows server 2003. Alright, so with this attack, we were able to understand and get more details about what the attackers are using. Now, let's try the remote code execution. The remote code execution is actually on Windows you need DLL. We need to deliver that DLL to the attacker's machines, to the client, to be able to trigger it. So, we started to think, how do we deliver this code? Again, DLL doesn't need to be triggered on the client. We are triggering through the remote code execution. What we did is we collected the fingerprint, the actual commands that the server, the client, is running, is trying to run on the server. And we can see that what they are trying to do is they are trying to download the malicious code on the server. So, they are running an FTP server on their own machine. And we know the password, the username, and the port of the server. So, we started creating the simulation. Here's our plan of attack. We will upload the DDL to a public location on the client. On the actual server, Windows 2003. And then we will run the honeypot, wait for the connection, and through the connection we will trigger that DLL so we will have the remote code execution. So, we created this RCE via the simulation. So, this is how it could work. First of all, we have, we are connecting to FTP server here. Simulating that we are connecting to the actual machine. We, we do the demo demo, now we will put our evil DLL. And now, after we put the evil DLL in a public location, then we will start the server, the honeypot. So, we will start the server. Uh, this is the startup script. We specify the plugin dir, public documents, and then this thing will actually trigger the execution of our DLL via the directory traversal. I don't have much time to explain this attack, but this has been explained, uh, last year. You can actually see the recording from the HIDBI. Basically, there is a plugin dir in my SQL and the file name, and we use the directory traversal to actually trigger DLL open, which, or, or load library on Windows, which is in the server. Now, I'm listening on the port, and now here's my DDL. My DDL is displaying the, um, the text and actually create, uh, the, um, um, uh, dialogue. Here's how it works. So, we have this MySQL command line utility, and we have the evil DLL, uh, uploaded to the client. Now, the client in this simulation, that's the bad actor, they are connecting to us. And here's, here we go. We actually executed the code, remote code execution. Thank you. Alright, so this is done. We demonstrated arbitrary file read, we demonstrated remote code execution, uh, with a plugin. So, the second attack is even more interesting. Now, from the fingerprint, what do we see? We see this is later versions of MySQL client. We know that this remote code execution via plugin will not work. But, what we see immediately is that it's using MySQL dump. This is the utility, we actually found a way to, to do the, the code execution. And then again, we were scratching our heads, and then we decide, well, let's collect more information. Let's understand how this attack is being, uh, executed. So, this is what we see. The, the application that connects to, uh, our server, right? It, um, uh, connects to the server, do the show databases, and then what it will do is it will run, it will execute MySQL dump utility and, uh, pass the database and the table name. So, basically what it do, the, the goal of this thing is to download the database so that they can actually claim that they download your data. But, we can see that they're only downloading ten records. So, don't pay, obviously, right? Don't pay. Those guys don't have your data. They claim that they have downloaded, backed it up, backed your database, but they didn't. They only have ten records. Right? And then, from here, we were started brainstorming. Can we download the code via arbitrary file rate? No. Can we execute code via plugin? Actually, no as well. Right? We know because this is the newer versions. So, we started looking again, how this attack is being handled. So, we see that they're using MySQL, MyADB connector, right? This is from the fingerprint. This should be some application there, right? And then suddenly, MySQL dump connects to our server. So, they probably do some execution of the MySQL dump and then we see back, we see that the application connects back. So, we also see this. Again, we are providing the server. Whatever client will execute, we will see immediately. And this is what we see. This is our table that we generated. It's sending it up, up, back to us. So, maybe, if this is what they're doing, maybe we can actually do a command injection. And, we started experimenting with this. We created a fake database. A schema name is a database in MySQL. We created this, a classical command injection. And, uh, we were surprised. It actually worked. So, we use the command injection on this client attack, right? On this bot, just like this, and we receive all the information, uh, out of this command back to us. So, we downloaded the evil code from those attackers. This is how it is looking like. It's a MySQL dump. We have a command injection here and here's what we see. We got the evil code. So, it's a Python script. It's a Python script that connects to your database, try to brute force the password, and then, uh, execute the MySQL dump. The multiple injections. We were looking at this code and we were like, well, there are multiple places where you can execute the command. Alright, so, we successfully, we achieved our goal, but not the way we thought originally. We executed the command injection. How do you try that at home? Uh, I'm pretty sure this will be fixed shortly, so you need to try it right now if you want to see what it looks like. Uh, and you don't even need the tool. You can start a MySQL database server, any version. You will create a root with no password. This is a born version of, of MySQL server, right? You don't care if they will be downloading your data. Uh, I'm done almost. And then you open that and this is the injections that you will do. Create database, put it in a backticks, and that's it. This is how you will be able to attack, uh, the bad guys. Alright, this is done. All done. So, new CV, details, and thank you.