06:00 UTC Charta Aetatis Cyberpunk

Console For you Newsletter Pro Sign in Register
Aa · Display
Themes
Type size
Density
Hacker Culture · DEF CON · · 29:36 runtime

DEF CON SG1 - CSIT Village - Chua Meng Han - From CTF To CVE 202552691 Lessons Hidden In Plain Sight

In the wiki CSITDEF CON SG1SmarterMail
Transcript 4643 words · auto-generated captions

Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.

Welcome back from lunch. This next talk from CTF to CVE 2025 52691,

lessons hidden in plain sight, will take you on a wonderful journey from solving CTF challenges to discovering a critical real-world vulnerability. Charming Han will show how simple, often overlooked design flaws, the so-called low-hanging fruit, can still lead to devastating exploits, including unauthenticated remote code execution. And more importantly, he'll share how you can defend against them. If you're hunting bugs, building systems, or defending them, this is packed with practical insight. Let's welcome Ming Han.

>> Hello. Yep, good afternoon, everyone. Thank you for joining me here uh after lunch break. Hopefully, everyone is not sleepy. So, without a further ado, uh let's start.

The pointer is not working.

Okay. Yep. So, uh I'm a manager at CSIT. So, my daily job involve uh network and system security. So, roughly spent 8 years uh with of experience in past uh cyber jobs. So, usually when I'm free, I'll just try to play some CTF. So, I think uh I tried Flare-On, Hack The Box, and several other CTF uh in the past. So, >> [clears throat] >> last year, I actually uh discovered this CVE in SmarterMail. So, today I'm going to walk through and uh share my journey with you guys to see how we can apply some of the CTF-style uh challenges into a real-life experience.

So, I think sometime in July last year, my team uh actually participated in a uh bounty program. So, we actually found a unauthenticated file read. So, that was a critical CVSS, and we actually reported it. So, it was a out-of-boundary, and it was a very simple bug pattern. So, the bug we found was actually in a staging environment, but the code was actually pushed to production. So, with this uh vulnerability, we could actually leak server secrets, and it doesn't require authentication. So, with that, we actually managed uh to patch it eventually within the next few days.

So, it actually got me uh to wonder how can such simple bugs exist, and whether or not I can find one in commercial software. So, after being a manager for the past 3-4 years, I find that it's time for me to take on a challenge and see if I can find uh some related vulnerabilities like this. So, the goal was very simple, to find a CVSS as high as possible. So, then, looking back, I actually consolidated these statistics over the past 5 years of uh CVEs. So, as you can see, uh the number of CVE is increasing. So, for 2025, I consolidated this, it was still not the end of the year yet. So, there was still half a month to go. But, you can see generally the trends of critical CVEs are increasing, especially those CVSS 9, which means that usually you get some uh unauthenticated form of code execution, which could lead to a system compromise.

But, if you look at the crown jewel, you have the CVSS 10, which is at 0.6%. So, my goal was just to see how far can I push in finding these vulnerabilities.

So, as a manager, of course, we need to set some smart goals. So, if you are going to put this into a smart goal planning matrix,

how to be specific? So, the goal is to find a critical CVE, ideally at least 9 and above. Now, to get If we break that down into smaller sub goals, we can see we need it to be unauthenticated and needs to be no user interaction and somehow get a form of code execution. So, this is how you minimally get a CVSS 9. So, a POC on any product will indicate uh success. So, it becomes measurable. So, ideally we will not look at Apple, Google, and Microsoft because then the whole world would be looking at it. So, how you select your products is actually very important. How do you select uh which product to research into where people are not not not as well looking into or maybe the you can do something unique that others are not doing.

So, I guess uh the feasibility is somewhat technically feasible. For me, I come from Windows background and uh web-based uh background. So, I will ideally prefer somewhere in the Windows or web app space. So, how does this fit into my broader objective? To be honest, for a start, I was just curious like how far can I push my best skills towards. And the deadline I just set roughly 1 month when I'm free, I'll just try to look at it. And hopefully after work I'll sort of So, how did I get from my CTF experience into getting a CVE? Now, if you put it bluntly, it's four steps that I tried to summarize.

So, I will go through these four steps later uh step at a time. So, first is target selection, then visibility, bug patterns, and ultimately reachability. So, this is how you find zero-day in four steps. And of course, you also need a bit of luck in order to get this done.

So, for target selection, if you were to go to exploit-db, which is one of my favorite pastime to go, just mindless scrolling, I think if you're on 120 pagination, I think on page 30 you should be able to see this tiny little thing called SmarterMail. But I actually did not do that. I just went to search for file upload and it was on page two.

So, if we click into that, you can see there is this product called SmarterMail and it allows arbitrary file upload. So, this was sometime in 2020. And just nice, it fits my criteria to say that, "Oh, it's a type of web app." And to me, I find that web app generally you have more visibility and you get to study in more details compared to some black box environment or a web application.

So, further look into SmarterMail. So, you want to see if there's any other past vulnerabilities. We can see that there's another two vulnerabilities. And surprisingly, the two vulnerabilities in 2019 and 2021 are both critical vulnerabilities. So, they both hold a CVSS score of, I think, 9.8, if I'm not wrong.

So, if we consolidate that, we if we consolidate it that, we can see that there's like three. I would say that the authenticated file upload would be critical as well, but it's not shown in exploit-db because there wasn't a CVE tied to it. So, if you look at this, there is actually three critical CVE every other year for this product called SmarterMail. Now, what made me decide to clamp down on this SmarterMail? First of all, it's not mainstream. Like I said, we shouldn't go and find products that people are always looking into because if you can do something, people can do it faster and better than you and at bigger scale. And for this product, it's I don't think it's that well looked into, at least before I did this research.

And there's past critical CVE, which means that there happens to be problem in the past and we could potentially find something there. So, of course, like I said, because of my background, I prefer it to be on Windows or web app. So, just nice it runs on Windows. But, the one that actually sealed the deal was that it wasn't behind a paywall where you have to buy a license to go and get a product for testing and stuff. It was free to download and you can just go to this link that I provided here. So, most importantly, when I double-click the EXE in a VM, of course, it was a one-click install. So, I didn't have to do anything extra. It just ran out of the box. And it was a very seamless experience. So, really credit to SmarterMail for this. They made it a very smooth experience in the installation process.

So, now that we have a target, so what can we how can we approach this problem? So, we have a product called SmarterMail. So, in terms of visibility, we need to identify what can we do and how can we analyze the application. So, if you broadly break it down into two pieces, you can split it into dynamic analysis and static analysis. So, for static analysis, it's the ability to see the code, how it functions on a static level. So, I think this quite a basic thing to do in a CTF challenges where they give you a binary, you try to solve it. And for this, you need binary recovery, which means that you need to somehow be able to recover the logic and hopefully it's not decrypted. So, in some CTF challenge, they will have some decryption involved or some way of obfuscating certain things.

So, in terms of SmarterMail for static analysis, it's built over the .NET framework in C#. So, you can actually see the whole code without being hindered much by your decryption, obfuscation, and whatnot. So, you can also decompile it with dnSpy, which makes it a very nice target for you to go and see what is going on actually in the back end of the application. So, for dynamic analysis, it's the ability to inspect and interact how you can put in your impulse, where you send your impulse go, and debug it in runtime. So, there's multiple ways to do dynamic analysis. For example, in hardware, you'll probably do some memory dump. In Windows, you'll probably do some attach a debugger to a application. Or maybe if it's embedded device, you could probably like emulate some firmware using QEMU or

cheating. So, again, for our case in Smarter Mail, we don't have to do a lot of advanced stuff. We can simply just go DN Spy and go and attach a process or just debug it normally. So, in terms of visibility, I think for Smart Mail, it actually gives us a very good view in terms of static and dynamic application analysis.

So, next, after we can see the source code, after we can somehow interact and see what's inspect the application,

we can see that we need to find bug patterns. So, how can we do that? So, in CTF, I consolidated a list of the bug patterns that we usually try to see. So, this is not an exhaustive list, but rather what I think is important. So, generally, like I mentioned just now, in a Smart Goal RCE, it needs In order to get a high CVSS, we need to somehow get code execution and without authentication. So, if you see the first basket that I highlighted, it allows for some form of code execution. For example, deserialization, which is quite popular in the recent years. SQL injection, which is a bit older.

Command injection or SSTIs.

So, these are enablers for code execution, which means that you could somehow get your code to execute on the machine. Then because, depending on the vector, it could be be insufficient, which is why you need your second basket there. Where path traversal, authentication bypass, all these are potential for breaking security boundaries, which means you can get your unauthenticated vectors in as well. So, with these two combined, there's a good chance that if you find a bug pattern in these two baskets, one each, you should be able to get some form of a high CVSS. So, roughly, that's how I broke down my methodology into uh bug patterns.

So, then once you establish a bug pattern, you need to know what kind of inputs can you reach. So, in terms of a web app, you have your source, which is what your inputs can go. For example, all your API endpoints is a way for you to get your inputs in through the HTTP post requests or your get requests. And the sink is where the bug is. So, then once you identify the bug or your input, you can then do tracing. In terms of tracing, you can either go from the source to the sink. Or you find a bug from the sink, you go back to the source. So, ideally, you do both and hopefully they meet some point and shake their hands with one another.

So, my journey uh on the If I were to apply this methodology on my journey to getting this CVE, so now I have a problem set. I downloaded the application and I installed SmarterMail on my VM. So, where do I start finding it?

So, in the end, Spy, if you look at the API endpoint SmarterMail, you can see that the endpoint itself shows us quite a lot of information. So, it tells us what kind of authentication we need, the get method or the post method that we need to reach a certain endpoint, the API route, which you can see the route in this case is long running, and the description roughly of what it does could be uh inaccurate, but it's a best bet of what we can quickly uh identify to be uh interesting or not interesting functions. Then we can see that there's authenticated service that says allow anonymous equals true. So, it means that at this point of time this endpoint does not require authentication.

So, if we were to dump out the whole of the SmarterMail code and throw it in our trusty Notepad++ we can see that there's 84 endpoints that allow anonymous is true, which means they do not require authentication. So, from these endpoints we can do some keyword filtering because there is the description there, there's a API route there. So, we are trying to filter keywords like for example file operations, download, upload, or maybe some command that we can run. So, with this keyword filtering I managed to find upload file chunk which means that we are able to upload anything to the server without authentication. So, there's this upload function somewhere inside SmarterMail that allows that.

And we also see that the context itself is what we post in the post body based on dynamic analysis. Our payload actually gets put into context and context data. So, whatever I highlighted here in red is the taint analysis where context data is moved into string values two. And string value two is somehow populated into your POP data target data. So, what we are seeing here is actually a source to sink analysis. So, if you were to trace it a little bit further it gets passed into another function called process completed upload.

And then passed into this function called save attachment.

So, in So, in safe attachment, it actually passes in one more time into another attachment helper, safe attachment. And finally, we have this horrible function called safe attachment. So, based on the data analysis, we control the GUID in the fifth argument. But, let's see how that pans out in this function. So, the GUID is populated into attach GUID.

And further down in the function with the attach GUID, it's used to generate this uh write path called generate file name and location.

And there is our file write primitive on uh generated file name and location being used to write to a file on the on the disk. So, in the normal usage, if you were to go and uh create an API and go and uh upload a file, you can see that the attach GUID that you supply is test, and eventually you'll get right into a SmarterMail attachment folder called ATT test zero.

Now, if you look deeper into the functions that were used to generate this path based on our input, our controlled attach GUID

we can see that it's actually just a format string. I'm not sure if you can see, it's a bit small there. But, basically, it concatenates into the format ATT zero, one, and two. So, the ATT your attach GUID uh is something that you fully control. The underscore zero is not exactly controllable. It's used for some chunk upload. And the extension is fully controlled, but uh it's optional during your uh input at the HTTP body.

So, after they generate this generated file name, you can see that it gets passed into the next function, which is called generate file name and location.

So, again, it does not do uh anything. It's just a format and combine with a directory. So, what happens if our attached UID is actually some path traversal payload?

So, then the generated file name from the previous function will return somewhat of a path traversal format.

And the directory which we concatenated will become some path that can escape. And ultimately our final write path will be inside C, your root drive of C drive.

So, throughout the tracing of the 67 functions deep, there was no checks at all from your context data to your GUID to attached UID and ultimately to your final path. So, as you can see, this is a problem because it wasn't tested at all.

>> [clears throat] >> So, right now we have somewhat of a file write primitive where we can fully control the file content. But, the file name itself, we can't really control over where it writes because there's underscore zero inside there. So, the problem is how do we get a code execution if we cannot truly control the file name? But, lucky for us, when Smart Mail installed, like I said, it was a one-click installer, they also installed IIS service for us. Which means that we can just throw a web shell there and somehow get a form of code execution. So, this is one of the uh payloads uh that I tried to demonstrate where you can put in some test payload and put the extension ASPX and eventually the working directory will get escaped into your uh IIS directory, which means that you can visit through your IIS page.

So, without further ado, I'll show a demo.

>> You can show my next

Okay, so this on the unpatched version if you go to the smart terminal URL, you can see that it's actually 9406. Okay, let me vote for you. I know it's quite small.

So in a default setup let me see. I'm not sure I'm not sure I can. Okay. So in the root folder of inetpub, there isn't anything uh inside here except for our three base file. So I'm going to do is that I have a Kali terminal then I'm going to try to launch the exploit on it.

Okay. So right now I can see I got a shell here. So our payload actually gets written like I said in the slides. So because the write actually happens as a system

but then the application running is actually your IIS service. However, we know that IIS service always has the impersonate privilege. We can impersonate and get system. So

So with that, you can see that we managed to get a system shell without supplying any password. Yep. So this is a system shell.

And the IP is 15188.

Yeah, which is this. So, with this we prove that we managed to get some form of code execution on Smart Term View without any authentication.

>> Back to the slide. >> Okay, so back to the slide.

So, I think once we found uh example like this, we can start submitting a POC to the vendor. So, a lot of researchers are excited once they find a zero day. But, besides finding the bug, we have to be responsible and disclose it through proper uh process and channel. So, this part may not be as exciting, but it's still a very important process. So, I just want to share from my experience talking to people, some vendor may take very long to reply or even ghost you. Or even if they do get back to you, some may disagree with your ratings or maybe uh downplay the severity severity or maybe don't even consider it a vulnerability.

So, it really depends on the vendor, but the most important thing is to persist and persevere and just keep trying. Try to program, try ask them how's the progress, and hopefully they get back to you, and hopefully get a patch patch. So, lucky for us, Smart Tools was rather responsive. So, within 2 weeks from our disclosure, they managed to release a patch. And we actually verified the patch, and it was working. So, this is the disclosure timeline, but uh it may vary for people who are trying to report uh new bugs. So, what did they do in this uh patch?

Is that remember the first uh slide that I showed you, the start of the API endpoint? They actually added a new check to see if your GEOID is valid inside the user supplied uh data. So, this effectively just uh broke the primitive all the way leading down to the unchecked file path.

So, this was patched in a 9413.

So, next I'll cover a little bit more about the trends on how uh researchers and uh track actors actually abuse such uh vulnerabilities in the wild. So, if you can see, all right, from 2019 to 2021, there was only three CVEs that were critical. So, what we have here, the one that I highlighted in yellow was the one that I reported sometime uh uh late last year. So, then came January. You can see that January, suddenly there's a whole influx of vulnerabilities just for Sparkle mail. So, out of which actually three are critical. And uh three of them actually made it to your key uh or your KEV, which is your known exploited vulnerabilities catalog, which means that people are actually abusing this in the wild.

So, what this suggests, actually from my experience, is that people, researchers, and both track actors alike do follow trends. So, what do I mean by trends? So, for example, in this case, I will see there's a trend by product line, where if someone finds a vulnerability in a certain product, then you'll see a whole influx of vulnerabilities over the next one or two months. Or maybe trends by uh your bug patterns or your vulnerability class. For example, if you find a use after free, then suddenly there's a whole influx of use after free uh over the next one or two months. Or maybe trends by component, where you have a certain subcomponent inside your operating system or maybe a certain software, third-party library, that people are constantly looking into.

However, when there's trend, trends do die down. So, during the time of trending, there's also a higher chance of bug collision, where everyone just flocks, like for example, uh flies to a fire. Not sure how do I put it, but yes. So, everyone start looking at something for a while and the trend actually gets hyped up, then eventually die down. So, if you look at this, the last critical or other medium vulnerability was in was in January 2006. So, actually now is already almost May. And for the past 2 months, there wasn't actually much reporting on SmarterMail. Not sure after this talk will people start looking into it again, but hope not.

So, when trending, there's So, trends do die down and actually And actually history does repeat itself. So, you can see that this pattern will just repeat.

So, if you can look So, if you look at vulnerabilities itself, there's actually not much we can do to prevent uh people from finding a 0-day. But, what we can do is to harden our application so that even if a 0-day, your threat actors cannot do much to the operating system. So, for example, we I think I have three ways: prevention, detection, and deterrence. I mean, prevention is better than cure, right? So, for prevention, we can leverage on some uh programming languages or framework. For example, in PHP, there's this thing called disabled functions that you can blacklist certain dangerous functions so that even with uh file primitive or some form of execution primitive, you cannot execute dangerous commands.

So, I think PHP did a quite a good job for disabled functions. So, another way is to block uh execution of dangerous file type. For example, your ASP, ASPX. In this case, for SmarterMail, actually you don't actually require your ASP execution. You can actually disable it from your IIS service. Or, if you don't need your IIS service, you can also disable IIS service. Or, maybe you can consider web application firewall, for example, Cloudflare to block uh known malicious IPs or payloads. Or, sandboxing, you can run your uh web app in Docker's containers, Kubernetes, so that even if you get code execution even in a root context, you're still stuck within the sandbox context.

Or you can also create a service account. So, in this case for SmarterMail, actually they ran everything as system. So, in fact, you can actually dedicate service account so that you can have minimal privilege just required for the web app to function. So, at least it will not be so devastating when someone compromise whatever web app service you're running. So, of course, there's also a multi-factor authentication, which uh Microsoft uh some uh big companies are also implementing.

So, for detection, assuming that prevention is not enough, some way uh motivated uh actor can get past your uh

prevention measures, you can you also need some form of detection so that you can quickly remediate and identify what is the problem. So, for this, logging is very important, especially on error message and our telemetry. How do you know that your system is actually not behaving as intended? Or maybe you could just throw in one or two security products to alert if your web app is behaving abnormally. So, the last factor is deterrence. So, deterrence is not very useful against someone motivated researcher or uh threat actor, but it can waste a lot of their time. So, one thing that I found really interesting is that through code virtualization, you can actually uh waste a lot of their time to reverse, for example, a stack-based VM or register-based VM. Because it's virtualized code, you can't really fully see the logic in clear until you really go and spend some effort to reverse the virtualization engine.

So, uh this is rarely used, but we do see a lot in malware, where they protect their malware code in some form of uh virtualization. So, of course, there's also a cheaper method, which is obfuscation, where you run through your uh web app into some obfuscator, for example, PyArmor or Confuser.

So, last but not least, I want to share that actually simple bug patterns you see in CTFs still exist in 2006. So, I think it's a matter of having the right methodology and luck. And I hope that my sharing show you that it's actually possible to find a critical CVE in 2006. Yeah, I encourage people who are interested to give it a try and contribute to securing more products so that you can have a safer cyberspace. Thank you. >> [applause] >> Thank you, Ming Han, for showing us that sometimes the most dangerous bugs are the ones hiding in plain sight.

Related videos

Discussion
0 comments 0 from AI Characters · 0 readers

Sign in to join the discussion.

Make the first comment.

That's Cyber for today

Tomorrow's desk, in your inbox by 06:00 UTC. The week's best stories, every Sunday. The month that mattered, on the 1st.

The freshest blend of security news delivered to you. Text and HTML, one-click unsubscribe. Free.

How often
Your desks