00:00:00.000,00:00:05.005 >>Hi, Ya, it’s good to be back. Nowadays, Virtual Private Network becomes more and more 00:00:07.574,00:00:13.747 prevalent. For enterprise, SSL VPN is the most convenient way for their employee to connect 00:00:13.747,00:00:20.521 the corporation network. For hackers, it’s also the shortest path to compromise your 00:00:20.521,00:00:25.525 internet. So, today let’s take a look at how your SSL VPN could be wrong. Oh, before that, is 00:00:29.663,00:00:34.668 there any NSA here? [Laughter] Okay, sorry for the title. Hi, I’m Orange, we are from DEVCORE 00:00:41.141,00:00:46.146 research team in Taiwan. Another 0Dayh researcher and focusing on web application security. Apart 00:00:49.216,00:00:54.221 from that, I’m also a speaker, CTF player and a bug bounty hunter. >>Hello everyone, I am 00:00:58.625,00:01:03.563 Meh Chang. I’m a security researcher from DEVCORE and I play CTF in HITCON in 217 CTF 00:01:06.033,00:01:11.038 team. I mainly focus on binary exploitation >>Here is the highlights today. We will 00:01:15.609,00:01:22.416 discuss pre-auth remote code execution and both Fortinet and Pulse Secure SSL VPN. In the 00:01:22.416,00:01:27.421 Fortinet case, we will show you the hardcore but reliable binary exploitation with a magic string 00:01:29.556,00:01:34.561 to open the door. In the Pulse Secure, we will present all of back web hacking. And how we 00:01:36.630,00:01:43.403 bypass the two, ah, bypass the two-factor authentication on Twitter and hack into their most 00:01:43.403,00:01:48.408 important server. Last, but not least, we will introduce how we leverage a hidden feature to 00:01:50.744,00:01:55.749 take over not only your SSL VPN but also all of your clients. And this is the agenda, we first 00:02:00.220,00:02:05.225 introduce the SSL VPN and why we focus on that? Most of the SSL VPN don’t provide a shell. We 00:02:08.662,00:02:13.667 will elaborate how we jailbreak the clients and introduce the attack vectors to discover bugs. 00:02:15.869,00:02:22.342 Of course, we will have case studies and demonstration. And the last is the SSL VPN 00:02:22.342,00:02:28.582 weaponization and recommendations. So, what is SSL VPN? Compared to the 00:02:28.582,00:02:33.587 site-to-site VPN saturates the IPsec or PPTP. SS-SSL VPN is more is of use and compatible 00:02:39.259,00:02:44.264 with any network environments. All you need is just a browser. Because of the convenience SSL 00:02:47.501,00:02:52.506 VPN becomes the most popular remote SS way for enterprise. SSL VPN are everywhere and 00:02:55.809,00:03:02.682 protect the corporation access from internet exposure. They are trust to be secure and consider 00:03:02.682,00:03:07.687 is the only way to your private network. But what if your trusted SSL VPN are insecure? 00:03:11.591,00:03:16.596 They will become your virtual public network. [Audience laughter] Yes, public. So, 00:03:21.201,00:03:26.206 that’s why we focus on SSL VPN, they are important but a blind spot. They are widely used by 00:03:28.575,00:03:33.580 corporations of all size but only few vendor dominate the market. According to our survey 00:03:35.982,00:03:40.987 on Fortune 500, the top three SSL VPN vendors dominate about 75 per cent market share. So, if 00:03:44.791,00:03:50.764 you find a high impact vulnerability and one of the leading SSL VPN, you can hack 00:03:50.764,00:03:55.769 the pre-net. The most important is SSL VPN must be exposed to our site, so it must have direct 00:03:59.973,00:04:04.911 internet access. Due to its importance, if an NSA is hunting for SSL VPN bugs, such as the 00:04:10.584,00:04:15.589 Equation Group leaks. SSL VPN is trust by large corporations, industrial leaders and tech 00:04:18.091,00:04:23.096 giants. Such as the Facebook, Twitter and Marvel. Yeah, the logo is very cool. Even NSA use 00:04:30.871,00:04:35.876 the SSL VPN. They are everywhere but usually forgotten, sometimes even hacker knows your SSL VPN 00:04:40.914,00:04:45.919 more. For example, we disclosed a remote code execution on Palo Alto SSL VPN one month ago. We 00:04:50.223,00:04:56.463 find a, we find a bug accidentally, however, while reproducing on the latest 00:04:56.463,00:05:01.401 version, we failed. So, we start to doubt if this is a known vulnerability. We search all 00:05:04.471,00:05:09.476 over the internet but could not find anything related. There’s no CVE, advisory or any official 00:05:12.078,00:05:17.083 announcement. Therefore, we believe this is a silent fixed 1-day. We surveyed all over the 00:05:20.253,00:05:26.226 world and find-find Uber suffered from this. So, we reported their bug bounty 00:05:26.226,00:05:31.231 program. This is not a fault on Uber, they also the victim. We also report this to the Palo 00:05:35.368,00:05:40.373 Alto PSIRT, but we got the following reply. They do not CVE items found internally. So, 00:05:44.711,00:05:49.716 that’s the reason why there’s no official advisory. Okay, this is fine. [Audience laughter] There 00:05:53.753,00:05:58.758 is no CVE, so there’s no vulnerability. [Laughter] Anyway, Palo Alto still a sign 00:06:04.197,00:06:09.202 CVE for that, just like after we publish older story. Once we decide to research into SSL VPN, 00:06:14.474,00:06:20.413 the next question is how to choose the targets? We did a little survey on leading SSL 00:06:20.413,00:06:25.418 VPN. As you can see even in the highest severity level CVE, the Pulse Secure and Fortinet 00:06:28.188,00:06:33.193 are-are still the most secure one. We want to change the mission impossible. So-so we put 00:06:36.463,00:06:43.203 our priority on Pulse Secure and Fortinet more. Pulse Secure is the most famous VPN solution in 00:06:43.203,00:06:49.809 the world. And has the latest high-level CVE. It’s trusted by large corporations, service 00:06:49.809,00:06:56.483 providers and government departments. Fortinet is more used by any users and med-medium 00:06:56.483,00:07:01.421 sized enterprise. It’s common in Asia and Europe. Both vendors have little high-level CVE’s, so 00:07:04.924,00:07:09.929 our mission is to find the most remote code execution on them. So, let’s start hacking. To 00:07:13.700,00:07:18.705 kickstart new research is always not easy. SSL VPN is a black box and closed source appliance. 00:07:21.474,00:07:26.246 They usually built their own architectures stack from scratch, and don’t provide a 00:07:26.246,00:07:32.852 shell to dive into. So, the Jailbreak is the essential step for researchers to turn the 00:07:32.852,00:07:37.857 black box into the great box. As you can see, most of the SSL VPN only provide a restricted shell. 00:07:42.696,00:07:47.701 So, let’s talk about how to Jailbreak then. We are not hardware guys, so we start 00:07:50.503,00:07:56.443 researching from the virtual appliance. All the virtual appliance can be classified into 00:07:56.443,00:08:03.249 the typical one and the encrypted one. It’s trivial for typical one, so we don’t spend a 00:08:03.249,00:08:09.356 lot of time here. You can just enter the single-user mode or mount a virtual disk on your box 00:08:09.356,00:08:14.361 to modify the file system to get a shell. But what if you, what if the disk has been encrypted? 00:08:18.965,00:08:25.372 We saw the booting process, we cannot see anything. So, today we will show you a trick to 00:08:25.372,00:08:30.377 bypass the encryption. Here is the linux booting process. The common way in passed to break 00:08:34.581,00:08:39.586 the encryption, is to analyze or reverse the v-vmlinuz kernel to get an encryption key. However, 00:08:43.223,00:08:48.228 we focus on another stash. Here we give an example to show how memory forensics take us to the 00:08:50.630,00:08:55.635 win. As we know, the booting process is stuff round the bios, reloader, and the kernel to drop 00:09:00.040,00:09:05.045 the first process to initialize the operating system. In Pulse Secure, the initial process show 00:09:07.647,00:09:12.652 you’re point. Press enter to view or update your appliance settings. And once we press the 00:09:15.688,00:09:22.662 enter, the initial process spawned another process to allow you modify and view the 00:09:22.662,00:09:27.667 settings. So, we suspend the virtual machine at this time. And scan the entire memory to do 00:09:31.971,00:09:36.976 the memory forensics on the host or s. From the memory forensics, we observe that the spawned 00:09:39.145,00:09:44.150 process is a Perl script. The name is disconfig dot pl. And since it can be the weak point 00:09:47.487,00:09:52.492 of whole booting process. So, it’s time to show the magic. We will just patch a few bytes to 00:09:55.662,00:10:00.667 pop out a shell. We patch the memory and repress the dsconfig dot pl to the bin SH. Once the 00:10:06.172,00:10:11.177 modification is done, the only thing we need is just press the enter. And we got a shell. Now, 00:10:16.483,00:10:21.488 [Applause] thank you. So, now we have the full control of the system and can do further 00:10:24.224,00:10:29.229 debugging and analyzing. >>Okay, so now we can start hacking SSL VPN’s. But where’s the bug? 00:10:34.834,00:10:39.839 There are many daemons running on the server. They’re usually complicated and hard to analyze. 00:10:42.509,00:10:47.514 Digging at the correct place, is important for us. So, we propose attack vectors, specific for SSL 00:10:50.183,00:10:56.589 VPN’s. We’ll talk about a special feature called WebVPN. It’s powerful, but also 00:10:56.589,00:11:02.495 vulnerable sometimes. We got lots of bounty from this feature. It’s like our slot 00:11:02.495,00:11:07.500 machine. The next one is the native script language extensions on SSL VPN’s, and how 00:11:09.836,00:11:14.841 they can be dangerous. And we also introduce our multi-layered architectural problems. Why VPN 00:11:18.978,00:11:25.718 is a convenient proxy feature. It’s portable and clientless, it proxy’s all kinds of traffics 00:11:25.718,00:11:30.723 through the web browser. It supports various protocols like HTTP, FTP and RDP. It also 00:11:34.227,00:11:39.232 handles many web resources, such as WebSocket, JavaScript and Flash. We don’t need to install 00:11:41.734,00:11:48.541 any software, only click on the browser and we can connect to all the services. Sounds 00:11:48.541,00:11:53.546 powerful, right? Apparently, it’s not easy to implement this feature. Some of them choose to 00:11:56.950,00:12:02.422 implement by themselves. However, protocols and web resources handling are prone to 00:12:02.422,00:12:07.427 memory bugs. Think about it as a VPN processing as SMB or Flash. You know how hard it could be. 00:12:11.631,00:12:18.404 Also, this requires high security awareness. For example, we filed some Debug functions in 00:12:18.404,00:12:23.409 sensitive data, we filed encryption and information exposed carelessly. Some winners 00:12:27.046,00:12:32.986 decided not to reinvent the wheel, they modified frontend open source project directly. 00:12:32.986,00:12:37.991 But they copy the code, and also copied the bugs. This kind of software are hard to maintain, 00:12:41.327,00:12:46.332 update or patch. Or, some winners choose to call existing libraries. But the winners often 00:12:49.569,00:12:54.574 neglect to update these libraries. We file Libcurl and Libxml from over ten years ago. 00:12:57.644,00:13:03.483 Implementing Web VPN is very not easy. This is the most serious attack vector we’ve found under 00:13:03.483,00:13:08.488 SSL VPN’s. During our research, we’ve found out most SS-SSL VPN’s have their own native 00:13:11.357,00:13:13.493 script language extensions. Like PHP extensions retaining C, or Perl extensions retaining C plus 00:13:13.493,00:13:18.498 plus. Winners like to use these extensions to do encoding, decoding or all operations to 00:13:26.406,00:13:31.411 improve efficiency. Which may be vulnerable. And it’s really prone to type confusion between 00:13:33.646,00:13:38.651 different languages. As we know, string operation is always difficult for C. Like buffer 00:13:41.854,00:13:46.859 size calculation, dangerous functions such as drink copy, or misunderstood functions. For 00:13:49.796,00:13:54.801 example, do you really know how the return value of a-a snprintf should be? Can you exceed the 00:13:57.136,00:14:02.075 buffer size? Actually. It’s possible, so a calculation like this can-will cause an image 00:14:05.278,00:14:10.283 overflow. The type of list extensions are also confusing. Although they seems so thin, but 00:14:14.387,00:14:19.392 do you really know what type it is? Do you know if you’re using safety? Who knows, and this may 00:14:23.362,00:14:28.367 cause serious problems. The last one, is the multi-layered architectural problems. When 00:14:30.503,00:14:36.175 there are different standards for processing the same thing, the inconsistency between them 00:14:36.175,00:14:43.149 will get you problems. Such as the attack surface on reverse proxy and JavaWeb backend. The 00:14:43.149,00:14:48.154 talk from Orange in DefCon last year. And here we gave another case. This is also an ssl 00:14:52.625,00:14:57.630 control bypass. It’s on C web server in RESTful backend. The regular expression, that plus 00:15:00.867,00:15:07.306 matches too much, so we can leverage this to match the dot dot slash to access the 00:15:07.306,00:15:12.311 privileged pages. Okay, so here is the special attack vectors, we found on the SSL VPN’s. 00:15:15.615,00:15:20.620 Following, we’re going to talk about two case studies. We will show we get pre-auth remote code 00:15:24.957,00:15:29.962 execution on Fortigate and Pulse Secure. Here is a disclaimer, all the CVE’s mentioned below 00:15:32.698,00:15:39.405 have been reported and patched by Fortinet, Pulse Secure and Twitter. So, please go update 00:15:39.405,00:15:44.410 your SSL VPN’s as soon as possible. Look, case one is Fortigate. We first jailbreak 00:15:48.948,00:15:55.588 the Fortigate and look into the binaries. We try to list the binaries in stash backend, we 00:15:55.588,00:16:01.494 found they are all symbolic links. Point to stash bin slash init. Just like this snapshot. 00:16:01.494,00:16:06.499 Fortigate compiles all the programs and the configurations into one single binary. This 00:16:08.501,00:16:15.041 makes the, init program really huge and annoying. Like, the big file of init is up to 500 00:16:15.041,00:16:20.046 megabytes with 85000 functions and they are all stripped, no symbol. It contains plenty of 00:16:23.249,00:16:30.256 function tables to manage it’s programs. Including the web daemon. Through our 00:16:30.256,00:16:35.261 investigation, we found the web service is modified from apache. But it’s the apache from 2002. 00:16:38.764,00:16:43.769 So, the web server running on your SSL VPN, is actually as old as your grandmother. [Laughter] 00:16:48.241,00:16:55.214 Compared to the admin page, the user login interface is the only one that definitely exposed to 00:16:55.214,00:17:00.152 the internet. It looks like this, a simple looking page no other buttons or functions. So, 00:17:03.089,00:17:09.595 we’re gonna exploit do the interface without authentication. We will talk 00:17:09.595,00:17:15.835 about three bugs today. First is the Pre-auth Remote Code Execution Chain, we combine two 00:17:15.835,00:17:20.840 bugs. A Pre-Auth arbitrary file reading to login and a Post-auth heap overflow to get a shell. We 00:17:25.311,00:17:31.951 also introduce an interesting bug, the magic back door, which can modify any users password 00:17:31.951,00:17:36.956 with a magic key. Let’s start with the file reading part. It was a function used to show 00:17:40.092,00:17:46.499 corresponding language for users. It concatenates strings directly with the dot dot slash 00:17:46.499,00:17:51.504 filter. But adjacent extension appended automatically. So, it’s things like we can only read 00:17:55.107,00:18:00.046 json files. Think about it, can we remove the json and read any file we want? The answer is yes, 00:18:06.419,00:18:11.424 we can utilise the feature of snprintf. According to the main page, it writes at most sites 00:18:13.893,00:18:18.898 minus one. The bar size is fixed here, so we only need to make it fit the buffer size. Like this. 00:18:23.636,00:18:25.838 We fill it up with slashes. So, the parse after snprintf becomes like this. The appended json 00:18:25.838,00:18:27.840 exceeds the buffer size and is stripped by snprintf. Then we can read whatever we want. After 00:18:27.840,00:18:32.845 getting arbitrary file reading, we found something interesting. We call it a SSL VPN mystery. It 00:18:36.115,00:18:41.120 appears in many products, not only Fortigate but Pulse Secure or other vendors. The mystery is 00:18:59.171,00:19:05.811 they hold an excessively detailed session file, on the SSL VPN. The file is called SSL 00:19:05.811,00:19:12.585 VPN web session. What’s the content? Session token, of course. IP address, sure, 00:19:12.585,00:19:17.590 username indeed, plain text password. [Laughter] Are you kidding? [Laughter] Yeah, you 00:19:21.961,00:19:28.034 should never store any plaintext passwords. We really know how this become popular, let me 00:19:28.034,00:19:33.039 guess. Maybe they learned it from Google, or Facebook or Twitter. Who knows, just 00:19:37.576,00:19:42.581 kidding. Anyway, these plaintext passwords are really convenient. We don’t need to crack password 00:19:44.984,00:19:49.989 anymore and we can login easily. Today, we’re going to utilise the Web VPN feature. As you can 00:19:53.192,00:19:58.197 see, it’s the pro os menu protocols. Let’s try the HTTP. We only need to type url and we 00:20:00.666,00:20:05.671 can connect to the website through Web VPN. And we look at the url, we can see that we’re 00:20:08.974,00:20:13.979 still connecting to the SSL VPN. So, it proxy’s the whole website for us. And if we look into 00:20:17.450,00:20:22.455 elements, we can find the url of resources are also from SSL VPN. It rewrites all the urls for us. 00:20:26.325,00:20:32.731 As you can imagine, this involves in hair string operation. So, here is a heap 00:20:32.731,00:20:38.604 overflow. It occurs in JavaScript parsing. And it’s simply because lack of length 00:20:38.604,00:20:43.609 check while memory copy. The buffer is only zero x 2000, but the input string is unlimited. 00:20:47.146,00:20:53.452 Generally, we do some heap function to overflow a nice target and control a program 00:20:53.452,00:20:58.457 counter and do code execution. But the situation is difficult in Fortigate, we found something 00:21:01.160,00:21:06.165 destabilizing. First of all, the web daemon handles connections with epoll. So, it’s a single 00:21:09.301,00:21:14.306 straight process. And the main process and libraries use the same heap. It means, all the 00:21:16.809,00:21:22.781 memory locations of all the operations, in all the connections are the same heap. 00:21:22.781,00:21:29.755 So, the heap is really unstable. Moreover, there are some operations regularly triggered. 00:21:29.755,00:21:35.161 They interfere the heap arrangement and is uncontrollable. Therefore, we 00:21:35.161,00:21:40.166 cannot arrange the heap location carefully. That would just make a mess. And there is something 00:21:42.168,00:21:47.173 even more ironic. Apache implements an additional memory management.So, there is no free 00:21:49.775,00:21:54.780 until the connection end. We cannot arrange the heap in a single connection. The 00:21:58.384,00:22:03.322 l-allocator also limits our export, it’s called Jemalloc. It centralize small objects. It 00:22:06.492,00:22:11.497 calls a back of locating memory origin in the maintainless regions in a run with a bitmap. 00:22:14.099,00:22:19.104 This effectively reduce interference between small and large objects. Is-It also limits 00:22:21.974,00:22:26.979 our target options. It’s hard to put small objects nearby our buffer. So, we’re stuck at that 00:22:31.317,00:22:36.322 time and therefore we started to fast server and it crashed. And we almost control the program 00:22:40.526,00:22:45.531 counter. And yeah, this is why we love fuzzing. We crushed a fountain table pointer in an SSL 00:22:52.705,00:22:58.644 structure. This structure stores information of each connection. It’s used for connection 00:22:58.644,00:23:03.582 handling and is an ideal target for our hit export. First, every new connection allocates an SSL 00:23:07.453,00:23:12.458 structure, so we can trigger it easily. And its size is close to our JavaScript buffer. And 00:23:14.827,00:23:19.832 therefore it can be placed nearby our buffer with a regular offset. The most important is 00:23:22.001,00:23:27.006 it-it has some useful structure members. It contains a function table pointer, called method and 00:23:30.876,00:23:37.216 this is how we triggered the crash. But we found one even better, its a function pointer 00:23:37.216,00:23:44.156 called handshake function. With this, the export can be much easier. We don’t need a whole 00:23:44.156,00:23:49.161 function table anymore, we only need a function adjust. All the connections are on the same 00:23:52.231,00:23:59.204 heap. So, we can mess up connections and overflow the SSL structure. So, we send lots of 00:23:59.204,00:24:04.143 n-normal requests and attack the server with an overflow request in the meantime. if we look into 00:24:08.347,00:24:14.887 a heap, there may be several SSL structures on the heap. For example, here are three SSL 00:24:14.887,00:24:21.627 structures for three connections. In the SS structure, is like this. Some 00:24:21.627,00:24:27.633 basic information in the function table. And the function pointer is now pointing to a SSL 00:24:27.633,00:24:32.638 function, SSL accept. Now, if we retrieve a JavaScript parsing, in the JavaScript buffer is 00:24:36.542,00:24:41.547 located ahead of this SSL structures. Then we can trigger an overflow and override the SSL 00:24:45.217,00:24:50.222 structure members, like this. So, now we fill up the SSL structure with capital A’s. And 00:24:55.294,00:25:00.232 make the program crashes. What we need to do next is clear. We only need to forge the SSL 00:25:04.169,00:25:09.174 structure with a fake fountain pointer, like the address of system. So, when you make the 00:25:11.276,00:25:16.281 connection, is trying to do handshake, the program executes whatever we want. Anyway, the 00:25:19.184,00:25:25.758 heap is unstable, so we need to send fuzzy connections to meet the condition. The server may 00:25:25.758,00:25:31.897 crash sometimes, but it’s fine. Fortigate has a reliable watchdog. We just need several 00:25:31.897,00:25:36.902 attempts taking about one to two minutes to get a shell. So, this is the whole details of how we 00:25:39.538,00:25:46.211 achieve remote code execution. Maybe some of you are not binary guys, so you may wonder, is 00:25:46.211,00:25:51.216 there any other way to get into your server? So, why not find another door to make your life 00:25:53.485,00:25:58.490 easier. We found a magic backdoor in the log-login page. This function was originally 00:26:01.894,00:26:06.899 used to update outdated password. However, they failed to authenticate. So, we can 00:26:09.168,00:26:14.173 simply use this secret key, which is called magic to reset any user’s password. Now we’re 00:26:19.711,00:26:24.716 going to demonstrate how we pop a root shell from the only exposed HTTPS port. We put our 00:26:31.557,00:26:36.562 PHP export on the end HTTP server and SSR export. In order to control the parameters of 00:26:39.031,00:26:44.036 this one, we first do a stack pivot and make our buffer become the stack. After that, we do an 00:26:47.072,00:26:52.077 ROP chain to whole system. And here is the reverse shell command. We use Python to build 00:26:56.548,00:27:01.487 a reverse shell. And we concatenate this strings to overflow the SSL structure. Now 00:27:11.697,00:27:16.702 we can start hacking. In the first panel, we open a port to receive the reverse shell. And 00:27:23.141,00:27:28.146 we start a fuzzing thread to build multiple no more connections. Then we attack the 00:27:35.187,00:27:40.192 server. We first try to log username and pentex password from the web sesion. As you can 00:27:48.066,00:27:53.071 see, we found a username, Meh. And password, this is password for Meh. We can use this account 00:27:59.978,00:28:04.983 to login and make the SSL VPN proxy our PHP export. We only need to wait a few seconds. 00:28:13.058,00:28:18.063 Okay, here we got the root shell. Thank you very much. [applause] >>Okay, the next case 00:28:39.885,00:28:46.558 we talk about is Pulse Secure. Pulse Secure is the market leader of SSL VPN and was from a 00:28:46.558,00:28:53.131 divestiture of Juniper Networks. They are a Perl lover and build all the architecture stack from 00:28:53.131,00:28:58.136 scratch. The architecture is old but stable and secure. And it’s worth to mention, Pulse Secure 00:29:02.107,00:29:08.246 works all the process by LD Preload. Due to the, ah due to the monitor and security 00:29:08.246,00:29:13.251 consideration. Ah, we will discuss this later. Here is the vulnerabilities we find. Among 00:29:16.722,00:29:21.159 them we were introduced a pre-auth arbitrary file reading and the post-auth command 00:29:21.159,00:29:26.164 injection. We chain these two bugs into the parse remote code execution. The first bug is a 00:29:30.469,00:29:35.474 pre-auth file reading. Pulse Secure introduced a new feature called HTML5 Access since 00:29:38.143,00:29:43.148 version eight point two. It can access the Telnet, SSH and remote desktop by browsers. In 00:29:47.386,00:29:53.792 order to adapt a new feature, Pulse Secure create a new IF-condition to handle all 00:29:53.792,00:29:58.797 static resources. Thanks to the new feature, the original strict validation has been bypassed. 00:30:04.536,00:30:09.541 So, am I affect by this? All Un- patch version accept the end of life version, are affected. Here 00:30:13.679,00:30:18.684 is the payload for you to check your SSL VPN. When there is a spatial pass in the end of the 00:30:20.819,00:30:25.824 url, the pass validation become loose. And, ah what can we get from this? We can get numerous 00:30:31.763,00:30:38.603 useful informations, such as the server private key to decrypt the SSL connection. We can also 00:30:38.603,00:30:43.475 get the information config, ah, we can also get the infor-important configurations 00:30:43.475,00:30:48.480 such as the radius and LDAP password. And all user password hashed and sensitive cookies 00:30:51.883,00:30:56.888 which are cached in the WebVPN. Like Google, Dropbox and iCloud. The last and most the important 00:31:01.493,00:31:06.498 is the cached plaintext password. Yes, plaintext again. For now, we get the credential, 00:31:13.071,00:31:19.878 so we are able to access the corporation network easily. However, our goal is to get 00:31:19.878,00:31:26.718 co-execution for persistent and further actions. So, here we show a command injection and 00:31:26.718,00:31:31.723 manage-management in the fast together. From this co-fragment, is very obvious and 00:31:34.059,00:31:39.064 straightforward. If we can control the options,we can inject arbitrary command to this 00:31:41.166,00:31:46.171 Perl function. And, of course, we can. We can control the options from the trouble 00:31:48.874,00:31:53.879 shooting patch. So, it’s that simple? No, I don’t think so. In order to avoid potential 00:31:59.117,00:32:04.055 vulnerabilities, Pulse Secure applied a lot of hardening on their products. Such-such as the 00:32:06.591,00:32:13.431 system integrity check and the read only file system to protect the back door, fro, ah to 00:32:13.431,00:32:18.436 protect from back doors in crontab or webloot. The most effective hardening is the 00:32:21.139,00:32:26.144 DSSafe module, it’s like the safeguard to protect Perl from dangerous operations. The DSSafe 00:32:31.049,00:32:37.289 is the Perl module, which is written in C plus plus. The module implement is on command 00:32:37.289,00:32:42.294 parser. And hold several dangerous functions, such as the system, open and backstick. It 00:32:46.231,00:32:51.236 also disallow numbers bad characters and re-implement the Linux I/O redirection in Perl. 00:32:54.105,00:32:59.110 So, due to the hardening, we cannot perform any command injection. We try several ways 00:33:03.081,00:33:08.887 to bypass the hardening. Of course, the first come out of my mind is the argument injection. 00:33:08.887,00:33:13.892 However, the tcpdump in Purse Secure is too old. So, we f-failed because it didn't 00:33:16.995,00:33:22.000 support several juicy features, such as the postrotate command. While examining the system, we 00:33:25.604,00:33:31.276 find Pulse Secure stole the temporary cache in the directory. We tried to write 00:33:31.276,00:33:36.281 into this directory. But we can’t use extend it out because it’s already directed to the new 00:33:38.683,00:33:43.688 device. What we can do, is only abusing the set file argument. But since there’s no way to 00:33:47.459,00:33:52.464 generate polyglot file in both Perl and PCAP format. So, it’s time to dig deeper. We type into 00:33:58.670,00:34:03.608 the DSSafe implementation to see is there anything we can leverage. We found a flaw in the 00:34:06.044,00:34:11.049 command parser. When there’s a, when there’s a incomplete I/O redirection. The rest of the I/O 00:34:13.818,00:34:18.823 part will be truncated. However, also we can re-control the sender out. We still can’t find 00:34:22.961,00:34:27.966 any way to generate a valid Perl. So, let’s think out of the box. Standard Out is 00:34:32.437,00:34:37.442 uncontrollable, but can we write a script by Standard Error? When you force the tcpdump to open a 00:34:43.081,00:34:48.086 non-existent file, it will show the error, no such file or directory. From the error it 00:34:51.456,00:34:54.659 seems we can parser control the message. We tried to pipe the extender error to Perl. Though 00:34:54.659,00:34:56.661 we still get nothing. However, when we try to use another file name, such as the print one two 00:34:56.661,00:35:01.600 three with a hashtag. We tried to pipe the extender error to Perl again and the magic 00:35:14.813,00:35:19.818 happens. The Perl print out the one two three without errors. So, okay the Perl and the one. 00:35:26.291,00:35:31.296 Perl suppose to go to label, so the tcpdump done with a column becomes a label in Perl. And we 00:35:34.199,00:35:40.472 use the hashtag to command the rest of the part. So, the extender error becomes a valid 00:35:40.472,00:35:45.477 Perl now. This is our final exploit, we will explain the pay load one by one. The first is to 00:35:51.016,00:35:56.021 map the tcpdump over the the non-existent file. The file will be part of the error message 00:35:59.391,00:36:04.329 in-in extender error. And then we-we direct the extender error into the cache directory. Here 00:36:07.165,00:36:12.170 in-in the file, ah set cookie dot thtml dot tcc. The rest is the in-complete I/O symbol. This 00:36:16.775,00:36:21.780 symbol appears to come in parser to ignore the rest of the I/O redirection. Once our extender 00:36:24.015,00:36:29.020 error has been written into the cache directory, we can just fetch the co-corresponding patch 00:36:31.322,00:36:37.095 to ask it our command. By chaining these two vulnerabilities, we can get a 00:36:37.095,00:36:42.100 reliable pre-auth remote code execution. We have report all of our finding to Perl Secure 00:36:46.271,00:36:51.276 PSIRT. And this is the response from them. They fixed all the bugs we sent them. Their 00:36:54.012,00:36:59.951 reaction is very quick and professional. It’s a great time to work with Purse Secure and 00:36:59.951,00:37:04.956 they are such a really responsible vendor. After Purse Secure release all the patches, 00:37:08.893,00:37:15.734 we kept monitoring the internet to see the large corporations response time. Twitter is one of 00:37:15.734,00:37:20.739 them. They are known for their bug bounty program and nice to hackers. However, it’s not good 00:37:22.841,00:37:29.414 to exploit one day right after the patch released. So, we wait thirty days for Twitter to 00:37:29.414,00:37:34.419 upgrade their SSL VPN. This is the Twitter SSL VPN. It’s just a simple looking patch. From the 00:37:41.326,00:37:46.331 reconnaissance, we know the last time Twitter upgrade is in last December. So, Twitter is likely 00:37:50.468,00:37:55.473 vulnerable. We have v-verified the bug and got a bunch of user credentials in plaintext. 00:37:57.509,00:38:02.447 However, we encounter some problems while trying to pop our shell from Twitter. Yes, the 00:38:08.186,00:38:13.191 first problem is the two factor authentication. Due to the two factor authentication, and so we 00:38:16.027,00:38:22.634 can get the plaintext password, we still can’t do anything. So, the first thing we need is to 00:38:22.634,00:38:27.639 find a way to bypass that. We observe Twitter enable the roaming session. Roaming session 00:38:30.975,00:38:35.980 is a feature to enhance the mobility. It allows a session from multiple IP locations. So, 00:38:40.552,00:38:45.990 once we know that we download the database and force the session to bypass the two factor 00:38:45.990,00:38:50.995 authentication. And finally we login to their system. The next problem is the SS control in 00:38:56.534,00:39:01.472 management interface. As we mentioned before, we have a command injection here. However, 00:39:04.709,00:39:09.714 for security consideration most of the corporation disable this interface on public. So, we need 00:39:12.250,00:39:17.255 to find another way to access the interface. We leverage the Web VPN feature again to connect 00:39:21.159,00:39:26.164 to itself. It’s just like the SSRF. We use the zero to bypass the SSI-SSI protection and 00:39:30.768,00:39:35.773 access management in the fast. And finally we got there. However, the last problem is 00:39:41.479,00:39:46.484 that we don’t find any managers plaintext password in cache. Practically, most of the manager 00:39:50.188,00:39:57.095 only look into their system at the first time. The only thing we have is the password hash in 00:39:57.095,00:40:02.100 sorted in find crypt in sha256 format. So, we launch a 72-core AWS to crack the hash. And, ah 00:40:13.611,00:40:18.616 three hours later We crack the hash and success-successfuly log into their management interface. 00:40:24.756,00:40:29.761 We are lucky because the length of the password is only ten. And the first character is capital 00:40:31.929,00:40:36.935 B. It’s in the very early stage of our cracking cue. We exploit our command injection and try to 00:40:40.571,00:40:45.576 run the command ifconfig, and we got a shell. We report all our findings [applause] Thank you. 00:40:52.817,00:40:57.822 We report all of our finding to their bounty bug program. And got the highest bounty from 00:41:05.129,00:41:10.134 Twitter. [applause] Also, we cannot prove that. It seems this is the first remote code 00:41:19.077,00:41:24.082 execution on Twitter. Okay, the last is the bonus for you. Our company DEVCORE provides the 00:41:28.386,00:41:33.391 most professional Red team service in Asia. So, let’s talk about how to make the Red team 00:41:35.660,00:41:40.665 more Red. In a Red team operation, the personal computer is more valuable. So. in order 00:41:44.869,00:41:49.874 to take control of all the clients, we need to weaponize the SSL VPN. There are several 00:41:51.876,00:41:56.881 old school methods before, such as the waterhole attack and the replace VPN installer. But here, 00:42:00.518,00:42:05.523 we propose a new method. It’s the logon script. Logon script is the feature in almost every 00:42:07.892,00:42:12.897 SSL VPN. It can ask it the corresponding script to mount a network file system or change 00:42:14.966,00:42:19.971 the loading table. So, here we will show you a demo, to show you that how we compromise all 00:42:22.407,00:42:27.412 the VPN clients. Okay, this is our demonstration. As you can see, they exploit one argument, 00:42:37.388,00:42:42.393 so we append our target right after the exploit. Here we got a username and hash of admin. 00:42:50.568,00:42:56.707 Also, we could not find a plaintext password. We can still change our cookie to the station 00:42:56.707,00:43:01.646 id of admin. Okay, once our modification is done we can access the management interface. 00:43:27.271,00:43:32.276 And we have become the admin. [applause] Thank you. Here we leverage the feature on the user 00:43:39.016,00:43:44.021 laurels and the VPN tunneling. We find a local script section. Here you can see the logon 00:43:47.325,00:43:52.330 script suppose not only Windows but also Linux and Mac OS. So, we use the calculator as our 00:44:02.673,00:44:07.678 backdoor. And, once our modification is done, we change to the laptop of our victim. 00:44:11.849,00:44:16.854 [Laughter] Ya, it’s cute. The victim launch the Perl Secure agent. And try to connect to the 00:44:25.029,00:44:30.034 SSL VPN with his username and password. And once the connection has been established, 00:44:37.508,00:44:42.513 the calculator will be popped automatically. [applause] Okay, here we finish all of our 00:44:52.590,00:44:59.430 slides. But how do we mitigate such attacks. Here we give several recommendations. The 00:44:59.430,00:45:04.769 first is to, if the client sign certificate, we saw the certificate the malicious 00:45:04.769,00:45:11.542 connection will be dropped during SSL negotiation. The next is to enable multi-factors 00:45:11.542,00:45:18.382 authentication, it can decrease numerous attacks service. And the last, remember to enable 00:45:18.382,00:45:23.387 full log audit and subscribe the vendors advisory to keep your system updated. This is the end 00:45:26.891,00:45:31.896 of our presentation, and here is our contact information. We will [applause] Okay. Okay, we will 00:45:43.608,00:45:50.514 post all the detail right after our talks. So, please check that and let us know if you have any 00:45:50.514,00:45:55.519 further questions. Thank you for being here again, thanks. [applause]