WEBVTT

00:00.000 --> 00:00.940
Hi.

00:01.480 --> 00:04.240
Yeah, it's good to be back.

00:04.400 --> 00:08.700
Nowadays, virtual private network becomes more and more prevalent.

00:08.700 --> 00:16.100
For enterprise, SSL VPN is the most convenient way for their employee to connect the corporation network.

00:16.840 --> 00:21.900
For hackers, it's also the shortest path to compromise your intranet.

00:21.900 --> 00:27.700
So, today, let's take a look at how your SSL VPN could be wrong.

00:28.200 --> 00:30.000
Oh, before that, let's talk about security .

00:30.000 --> 00:32.300
Is there any NSA here?

00:33.640 --> 00:36.040
Okay, sorry for the title.

00:37.920 --> 00:39.720
Hi, I'm Orange.

00:39.720 --> 00:43.120
We are from Def Core Research Team in Taiwan.

00:43.120 --> 00:48.540
I'm now a zero-day researcher and focusing on web and application security.

00:48.780 --> 00:54.720
Apart from that, I'm also a speaker, CTF player, and a bug bounty hunter.

00:57.060 --> 00:59.580
Hello everyone, I'm Mei Zhang.

00:59.580 --> 01:06.820
I'm a security researcher from Def Core Research and I play CTF in Hikon and 217 CTF team.

01:06.820 --> 01:09.720
I mainly focus on binary exploitation.

01:12.680 --> 01:15.160
Here is the highlights today.

01:15.160 --> 01:21.660
We will discuss pre-auth remote code execution on both Fortinet and ProSecure SSL VPN.

01:21.900 --> 01:31.400
In the Fortinet cast, we will show you the hard-core but reliable binary exploitation with the magic string to open the door.

01:31.680 --> 01:44.960
In the ProSecure, we will present the out-of-box web hacking and how we bypass the two uh bypass the two-factor authentication on Twitter and hack into their most important server.

01:45.500 --> 01:56.280
Last but not least, we will introduce how we leverage a hidden feature to take over not only your SSL VPN but also all of your clients.

01:57.160 --> 01:59.580
And this is the agenda.

01:59.580 --> 02:04.580
We first introduce the SSL VPN and why we focus on that.

02:05.020 --> 02:08.420
Most of the SSL VPN don't provide a shell.

02:08.420 --> 02:15.560
We will elaborate how we jailbreak the app- appliance and introduce the attack vectors to discover bugs.

02:15.660 --> 02:19.400
Of course, we will have case studies and demonstration.

02:20.000 --> 02:25.160
And the last is the SSL VPN weaponization and recommendations.

02:25.640 --> 02:26.820
We will start with SSL VPN .

02:26.820 --> 02:29.920
So, what is SSL VPN?

02:30.300 --> 02:42.100
Compared to the side-to-side VPN such as the IPsec or PPTP, SSL SSL VPN is more ease of use and compatible with any network environments.

02:42.100 --> 02:44.740
All you need is just a browser.

02:45.140 --> 02:52.140
Because of the convenience, SSL VPN becomes the most popular remote access way for enterprise.

02:53.620 --> 02:59.800
SSL VPN are everywhere and protect corporation access from internet exposure.

02:59.960 --> 03:05.820
They are trust to be secure and consider as the only way to your private network.

03:05.900 --> 03:10.660
But what if your trusted SSL VPN are insecure?

03:11.540 --> 03:15.840
They will become your virtual public network.

03:17.320 --> 03:19.160
Yes, public.

03:20.440 --> 03:23.860
So, that's why we focus on SSL VPN.

03:23.880 --> 03:27.100
They are important but a blind spot.

03:27.360 --> 03:34.080
They are widely used by corporations of all size but only few vendor dominate the market.

03:34.560 --> 03:43.840
According to our survey on Fortune 500, the top 3 SSL VPN vendors dominate about 75 percent market share.

03:43.880 --> 03:51.980
So, if you find a high impact vulnerability on one of the leading SSL VPN, you can hack the planet.

03:52.700 --> 03:58.160
The most important is SSL VPN must be exposed to outside.

03:58.160 --> 04:01.720
So, it must have direct intranet access.

04:03.540 --> 04:12.320
Due to its importance, even NSA is hunting for SSL VPN bugs, such as the equation group leaks.

04:13.280 --> 04:25.440
SSL VPN is trust by large corporations, industry leaders, and tech giants, such as the Facebook, Twitter, and Marvel.

04:25.860 --> 04:27.980
Yeah, the logo is very cool.

04:29.480 --> 04:32.580
Even the NSA use the SSL VPN.

04:33.980 --> 04:37.500
They are everywhere but usually forgotten.

04:37.500 --> 04:41.860
Sometimes even hacker knows your SSL VPN more.

04:43.060 --> 04:49.800
For example, we disclose a pre-auth remote code execution on Palo Alto SSL VPN one month ago.

04:49.800 --> 04:53.220
We find a-we find a bug accidentally.

04:53.640 --> 04:58.340
However, while reproducing on the latest version, we failed.

04:58.900 --> 05:02.400
So, we start to doubt if this is a known vulnerability.

05:03.420 --> 05:07.840
We search all over the internet but could not find anything related.

05:07.860 --> 05:13.260
There's no CVE, adversary, or any official announcement.

05:14.040 --> 05:17.720
Therefore, we believe this is a silent fix one day.

05:18.980 --> 05:24.580
We surveyed all over the world and find-and find Uber suffered from this .

05:24.580 --> 05:27.340
So, we reported their bug bounty program.

05:28.160 --> 05:30.240
This is not a fault on Uber.

05:30.240 --> 05:31.960
They are also the victim.

05:33.140 --> 05:39.080
We also report this to the Palo Alto Peace Search, but we got a follow-up reply.

05:39.220 --> 05:43.460
They do not CVE items find internally.

05:43.680 --> 05:48.060
So, that's the reason why there is no official adversary.

05:49.880 --> 05:52.320
Okay, this is fine.

05:53.060 --> 05:57.020
There is no CVE, so there is no vulnerability.

06:01.620 --> 06:05.800
Anyway, Palo Alto still assign a CVE for that.

06:05.800 --> 06:09.140
Just right after we publish all the story.

06:10.480 --> 06:17.740
So, once we decide to research into SSL VPN, the next question is how to choose the target.

06:17.760 --> 06:21.580
We did a little survey on leading SSL VPN.

06:21.820 --> 06:31.280
As you can see, even in the high-severity label CVE, the ProSecure and Fortinet are-are still the most secure one.

06:32.200 --> 06:35.200
We want to challenge the mission impossible.

06:35.200 --> 06:39.800
So, so we put our priority on ProSecure and Fortinet more.

06:40.160 --> 06:46.600
ProSecure is the most famous VPN solution in the world and has the least high-level CVE.

06:46.600 --> 06:52.680
It's trusted by large corporations, service providers, and government departments.

06:53.300 --> 06:57.940
Fortinet is more used by end-users, uh medium-sized enterprise.

06:57.940 --> 07:00.740
It's common in Asia and Europe.

07:01.160 --> 07:09.080
Both vendors have little high-level CVEs, so our mission is to find the pre-auth remote code execution on them.

07:10.100 --> 07:12.660
So, let's start hacking.

07:13.080 --> 07:17.200
To kickstart a new research is always not easy.

07:17.200 --> 07:21.380
SSL VPN is a black box and closing source appliance.

07:21.380 --> 07:28.300
They usually build their own architecture stack from scratch and don't provide a shell to dive into.

07:28.500 --> 07:35.740
So the drawback is the essential step for researchers to turn the black box into the gray box.

07:36.840 --> 07:42.640
As you can see, most of the SSL VPN only provide a restricted shell.

07:42.640 --> 07:46.240
So, let's talk about how to jailbreak them.

07:47.240 --> 07:53.380
We are not a hardware guys, so we start researching from the virtual appliance.

07:53.800 --> 07:59.480
All the virtual appliance can be classified into the typical one and the encrypted one.

08:00.320 --> 08:04.820
It's trivial for typical one, so we don't pay a lot of time here.

08:04.820 --> 08:12.400
You can just enter the single user mode or mount a virtual disk on your box to modify the file system to get a shell.

08:13.640 --> 08:18.260
But what if you- what if the disk has been encrypted?

08:18.980 --> 08:22.220
Without a booting process, we cannot see anything.

08:22.220 --> 08:27.220
So today, we will show you a trick to bypass the encryption.

08:29.890 --> 08:32.390
Here is the Linux booting process.

08:32.390 --> 08:41.730
The common way in past to break the encryption is to analyze or reverse the VM Linux kernel to get the encryption key.

08:42.250 --> 08:45.610
However, we focus on another stage.

08:45.790 --> 08:51.590
Here we give an example to show how memory forensics take us to the wing.

08:54.160 --> 09:04.220
As we know the booting process, it starts from the BIOS, bootloader, and the kernel to drop the first process to initialize the operating system.

09:05.020 --> 09:09.140
In Perl Secure, the initial process show you a prompt.

09:09.140 --> 09:13.700
Press enter to view or update your appliance settings.

09:13.960 --> 09:23.960
And once we press the enter, the initial process spawned another process to allow you modify and view the settings.

09:24.340 --> 09:28.360
So we suspend the virtual machine at this time.

09:29.500 --> 09:35.060
And scan the entire memory to do the memory forensics on the host OS.

09:35.620 --> 09:41.200
From the memory forensics, we observe that the spawned process is a Perl script.

09:41.200 --> 09:44.160
The name is dsconfig.pl.

09:44.680 --> 09:49.460
And since it can be the weak point of whole the booting process.

09:49.820 --> 09:52.780
So, it's time to show the magic.

09:52.880 --> 09:57.420
We will just patch a few bytes to pop out the shell.

09:58.320 --> 10:04.580
We patch the memory and replace the dsconfig.pl to the bin sh.

10:05.380 --> 10:11.240
Once the modification is done, the only thing we need is just press the enter.

10:11.340 --> 10:13.340
And we got a shell.

10:14.500 --> 10:17.120
Now, thank you.

10:19.760 --> 10:26.520
So now we have the full control of the system and can do further debugging and analyzing.

10:28.440 --> 10:32.920
Okay, so now we can start hacking SSL VPNs.

10:32.920 --> 10:35.580
But, where's the bug?

10:35.840 --> 10:38.940
There are many demons running on the server.

10:38.940 --> 10:42.400
They're usually complicated and hard to analyze.

10:42.480 --> 10:45.660
Digging at the correct place is important for us.

10:46.320 --> 10:51.080
So we propose some attack vectors specific for SSL VPNs.

10:51.080 --> 10:54.620
We'll talk about a special feature called WebVPN.

10:54.620 --> 10:58.060
It's powerful but also vulnerable sometimes.

10:58.060 --> 11:01.180
We got lots of bounty from this feature.

11:01.180 --> 11:03.740
It's like our slot machine.

11:04.220 --> 11:11.680
The next one is the native script language extensions on SSL VPNs and how they can be dangerous.

11:12.120 --> 11:16.420
And we also introduce some multi-layered architecture problems.

11:18.020 --> 11:21.480
WebVPN is a convenient proxy feature.

11:21.480 --> 11:23.560
It's portable and clandestine.

11:23.560 --> 11:27.660
It proxies all kinds of traffic through the web browser.

11:28.320 --> 11:33.740
It supports various protocols like HTTP, FTP, and RDP.

11:33.740 --> 11:40.300
It also handles many web resources such as WebSocket, JavaScript, and Flash.

11:40.480 --> 11:43.040
We don't need to install any software.

11:43.040 --> 11:47.420
Only click on the browser and we can connect to other services.

11:47.940 --> 11:50.380
Sounds powerful, right?

11:50.380 --> 11:54.020
Apparently it's not easy to implement this feature.

11:55.320 --> 11:58.880
Some vendors choose to implement by themselves.

11:58.880 --> 12:03.920
However, protocols and web resources handling are prone to memory bugs.

12:04.300 --> 12:08.980
Think about SSL VPN processing SMB or Flash.

12:08.980 --> 12:10.560
You know how hard it could be.

12:10.560 --> 12:14.660
We also this requires high security awareness.

12:14.660 --> 12:24.320
For example, we found some debug functions and sensitive data without encryption and information exposed carelessly.

12:25.820 --> 12:29.660
Some vendors decided not to reinvent the wheel.

12:29.660 --> 12:33.460
They modify from an open source project directly.

12:33.460 --> 12:37.940
But they copy the code and also copy the bugs.

12:38.420 --> 12:43.660
This kind of software are hard to maintain, update, or patch.

12:44.380 --> 12:48.460
Or some vendors choose to call existing libraries.

12:48.460 --> 12:52.040
But the vendors often neglect to update these libraries.

12:52.040 --> 12:56.660
We found libcurl and libxml from over 10 years ago.

12:57.560 --> 13:05.920
Implementing web VPN is really hard .

13:06.060 --> 13:13.200
During our research, we found out most SSL VPNs have their own native script language extensions.

13:13.200 --> 13:20.020
Like PHP extensions written in C or extensions written in C++.

13:20.800 --> 13:28.100
Vendors like to use these extensions to do encoding, decoding, or other operations to improve efficiency.

13:28.100 --> 13:30.500
Which may be vulnerable.

13:30.740 --> 13:35.160
And it's really prone to type confusion between different languages.

13:36.180 --> 13:40.980
As we know, string operation is always difficult for C.

13:40.980 --> 13:48.960
Like buffer size calculation, dangerous functions such as string copy, or misunderstood functions.

13:49.380 --> 13:55.760
For example, do you really know how the return value of a smprintf should be?

13:55.900 --> 13:58.440
Can it exceed the buffer size?

13:59.780 --> 14:01.680
Actually, it's possible.

14:01.680 --> 14:06.480
So calculation like this can cause an integer overflow.

14:08.180 --> 14:11.840
The type of these extensions are also confusing.

14:11.840 --> 14:17.440
Although they seem the same, but do you really know what type it is?

14:18.000 --> 14:20.560
Do you know if you are using it safely?

14:21.260 --> 14:22.800
Who knows?

14:22.800 --> 14:25.480
And this may cause serious problems.

14:26.200 --> 14:30.020
The last one is the multi-layered architecture problems.

14:30.020 --> 14:37.780
When there are different standards for processing the same thing, the inconsistency between them will lead to problems.

14:37.780 --> 14:42.940
Such as the attack surface on reverse proxy and Java web backend.

14:42.940 --> 14:46.800
The talk from Orange in DEFCON last year.

14:47.140 --> 14:50.340
And here we gave another case.

14:51.240 --> 14:53.960
This is also an SS control bypass.

14:54.180 --> 14:57.660
It's on C web server and RESTful backend.

14:58.480 --> 15:09.260
The regular expression dot plus matches too much, so we can leverage this to match the dot dot slash to access the privileged pages.

15:10.400 --> 15:16.520
Okay, so here is the special attack vectors we found on the SSO VPNs.

15:16.520 --> 15:20.600
Following, we're going to talk about two case studies.

15:21.000 --> 15:27.720
We will show how we get the pre-auth remote code execution on FortiGate and PostSecure.

15:29.140 --> 15:30.860
Here's a disclaimer.

15:30.860 --> 15:37.780
All the CVEs mentioned below have been reported and patched by Fortinet, PostSecure, and Twitter.

15:37.780 --> 15:42.600
So, please go update your SSO VPNs as soon as possible.

15:44.140 --> 15:46.940
The case one is FortiGate.

15:47.720 --> 15:48.540
We first show you how FortiGate works .

15:48.540 --> 15:51.780
First , we shall break the FortiGate and look into the binaries.

15:52.200 --> 15:57.760
We try to list the binaries in slash bin and we found there are all symbolic links.

15:57.760 --> 16:01.920
Point to slash bin slash init, just like this snapshot.

16:03.160 --> 16:08.260
FortiGate compiles all the programs and configurations into one single binary.

16:08.260 --> 16:12.220
This makes the init program really huge and annoying.

16:12.220 --> 16:18.160
The IDB file of init is up to 500 megabytes with 85,000 functions.

16:18.160 --> 16:21.220
And they are all stripped, no symbol.

16:21.840 --> 16:28.900
It contains plenty of function tables to manage each programs, including the web daemon.

16:29.820 --> 16:35.120
Through our investigation, we found the web service is modified from a patch.

16:35.120 --> 16:38.320
But it's a patch from 2002.

16:38.740 --> 16:45.200
So, the web server running on your SSO VPN, it's actually as old as your grandmother.

16:47.870 --> 16:56.430
Compared to the admin page, the user login interface is the only one that definitely exposed to the internet.

16:56.930 --> 16:58.570
It looks like this.

16:58.570 --> 17:02.670
A simple login page, no other buttons or functions.

17:02.670 --> 17:07.030
So, we're gonna explore through this interface without authentication.

17:08.650 --> 17:11.850
We will talk about three bugs today.

17:11.850 --> 17:14.790
First is the pre-auth remote code execution chain.

17:14.790 --> 17:16.950
We combine two bugs.

17:17.630 --> 17:24.570
A pre-auth arbitrary file reading to log in and a post-auth heap overflow to get a shell.

17:25.030 --> 17:33.630
We also introduce an interesting bug, the magic backdoor, which can modify any user's password with a magic key.

17:34.750 --> 17:37.550
Let's start with the file reading part.

17:37.750 --> 17:42.870
It was a function used to show corresponding language for users.

17:42.870 --> 17:47.410
It concatenates strings directly without a dot dot slash filter.

17:47.410 --> 17:51.830
But, a JSON extension appended automatically.

17:51.950 --> 17:56.630
So, it seems like we can only read JSON files.

17:57.110 --> 18:02.610
Think about it, can we remove the JSON and read any file we want?

18:04.430 --> 18:06.370
The answer is yes.

18:06.370 --> 18:10.090
We can utilize the feature of smprintf.

18:10.230 --> 18:15.470
According to the main page, it writes at most size minus one.

18:15.550 --> 18:21.070
The buffer size is fixed here so we only need to make it exceed the buffer size.

18:21.070 --> 18:22.670
Like this.

18:23.250 --> 18:26.150
We fill it up with slashes.

18:26.150 --> 18:30.630
So, the path after smprintf becomes like this.

18:31.910 --> 18:38.550
The appended JSON exceeds the buffer size and is stripped by the smprintf.

18:38.970 --> 18:41.690
Then we can read however we want.

18:43.190 --> 18:47.890
After getting arbitrary file reading, we found something interesting.

18:47.890 --> 18:50.610
We call it an SSL VPN mystery.

18:50.670 --> 18:57.210
It appears in many products, not only FreudGate, but ProSecure or other vendors.

18:57.530 --> 19:04.290
The mystery is they hold an excessively detailed session file on the SSL VPN.

19:04.290 --> 19:07.430
The file is called SSL VPN web session.

19:07.430 --> 19:08.930
What's the content?

19:09.430 --> 19:10.230
Session token?

19:10.230 --> 19:11.190
Of course.

19:11.190 --> 19:12.290
IP address?

19:12.290 --> 19:13.310
Sure.

19:13.310 --> 19:14.030
User name?

19:14.030 --> 19:15.170
Indeed.

19:15.670 --> 19:17.610
Plantex password?

19:17.810 --> 19:19.970
Are you kidding?

19:21.090 --> 19:24.570
You should never store any Plantex password.

19:24.990 --> 19:27.850
We really wonder how this become popular.

19:27.850 --> 19:29.070
Let me guess.

19:29.070 --> 19:36.510
Maybe they learned it from Google or Facebook or Twitter.

19:36.570 --> 19:37.450
Who knows?

19:37.450 --> 19:38.590
Just kidding.

19:39.510 --> 19:43.410
Anyway, these Plantex passwords are really convenient.

19:43.470 --> 19:47.610
We don't need to crack password anymore and we can log in easily.

19:47.950 --> 19:52.070
Today, we're going to utilize the web VPN feature.

19:52.490 --> 19:55.350
As you can see, it supports many protocols.

19:55.350 --> 19:57.330
Let's try the HTTP.

19:57.910 --> 20:04.050
We only need to type the URL and we can connect to the website through a VPN.

20:05.590 --> 20:07.970
And we look at the URL.

20:07.970 --> 20:11.690
We can see that we're still connecting to the SSL VPN.

20:11.730 --> 20:14.510
So, it proxies the whole website for us.

20:15.350 --> 20:22.770
And if we look into the elements, we can find the URL of resources are also from SSL VPN.

20:22.770 --> 20:26.030
It rewrites all the URLs for us.

20:26.110 --> 20:30.370
As you can imagine, this involves a heavy string operation.

20:31.050 --> 20:33.710
So, here is the heap overflow.

20:33.950 --> 20:40.850
It occurs in JavaScript parsing and it's simply because lack of check while memory copy.

20:40.970 --> 20:46.090
The buffer is only 0x2000 but the input string is unlimited.

20:46.810 --> 20:56.130
Generally, we do some heap function to overflow a nice target and control a program counter and do code execution.

20:56.270 --> 21:00.290
But the situation is difficult in FortiGate.

21:00.290 --> 21:02.950
We face something destabilizing.

21:03.430 --> 21:07.830
First of all, the web daemon handles connections with EPO.

21:07.890 --> 21:10.610
So, it's a single thread process.

21:10.610 --> 21:14.470
And the main process and libraries use the same heap.

21:14.850 --> 21:22.730
It means all the memory allocations of all the operations in all the connections are the same heap.

21:22.730 --> 21:25.230
So, the heap is really unstable.

21:25.690 --> 21:29.690
Moreover, there are some operations regularly triggered.

21:29.690 --> 21:33.950
They interfere the heap arrangement and it's uncontrollable.

21:34.290 --> 21:38.530
Therefore, we cannot arrange the heap allocation carefully.

21:38.530 --> 21:40.590
That would just make a mess.

21:40.730 --> 21:43.870
And there is something even more ironic.

21:44.250 --> 21:47.670
Apache implements an additional memory management.

21:47.670 --> 21:52.070
So, there's no free until the connection end.

21:52.450 --> 21:56.250
We cannot arrange the heap in a single connection.

21:57.870 --> 22:01.010
The allocator also limits our exploit.

22:01.010 --> 22:02.410
It's called Jemelo.

22:02.410 --> 22:02.990
Jemelo is a block .

22:02.990 --> 22:05.690
It centralizes small objects.

22:06.070 --> 22:13.950
It calls a block of allocated memory or region and then maintain these regions in a round with a bitmap.

22:14.030 --> 22:19.990
This effectively reduces the interference between small and large objects.

22:20.250 --> 22:23.970
It's- it also limits our target options.

22:23.970 --> 22:28.050
It's hard to put small objects nearby our buffer.

22:28.750 --> 22:38.290
So, we're stuck at that time and we cannot and therefore we started to fuzz the server and it crashed.

22:38.290 --> 22:41.770
And we almost control the program counter.

22:42.750 --> 22:46.210
And yet, this is why we love fuzzing.

22:48.580 --> 22:53.960
We crushed a function table pointer in an SSL structure.

22:53.960 --> 22:57.460
This structure stores information of each connection.

22:57.460 --> 23:03.420
It's used for connection handling and it's an ideal target for our heap exploit.

23:04.160 --> 23:08.380
First, every new connection allocates an SSL structure.

23:08.380 --> 23:10.920
So, we can trigger it easily.

23:10.920 --> 23:14.500
And its size is close to our JavaScript buffer.

23:14.500 --> 23:19.520
And therefore, it can be placed nearby our buffer with a regular offset.

23:20.120 --> 23:25.240
The most important is, it ha- it has some useful structure members.

23:26.420 --> 23:30.440
It contains a function table pointer and code method.

23:30.440 --> 23:33.180
And this is how we triggered the crash.

23:33.180 --> 23:35.240
But we found one even better.

23:35.340 --> 23:39.360
It's a function pointer called handshake function.

23:40.200 --> 23:43.080
With this, the exploit can be much easier.

23:43.080 --> 23:45.560
We don't need a whole function table anymore.

23:45.560 --> 23:48.280
We only need a function address.

23:50.060 --> 23:52.720
All the connections are on the same heap.

23:52.720 --> 23:57.380
So, we can mess up connections and overflow the SSL structure.

23:57.480 --> 24:05.340
So, we send lots of ro- normal requests and attack the server with an overflow request in the meantime.

24:06.940 --> 24:12.260
If we look into the heap, there may be several SSL structures on the heap.

24:12.260 --> 24:17.220
For example, here are 3 SSL structures for 3 connections.

24:17.240 --> 24:20.380
And the SSL structure is like this.

24:21.000 --> 24:24.820
Some basic information and the function table.

24:24.820 --> 24:30.240
And the function pointer is now pointing to an SSL function, SSL accept.

24:30.860 --> 24:48.640
Now, if we trigger the JavaScript parsing, and the JavaScript buffer is located ahead of this SSL structures, then we can trigger the overflow and override the SSL structure members like this.

24:50.340 --> 24:57.140
So, now we fill up the SSL structure with capital A's and make the program crashes.

24:57.760 --> 25:01.120
What we need to do next is clear.

25:02.020 --> 25:09.540
We only need to forge the SSL structure with a fake function pointer, like the address of system.

25:09.980 --> 25:16.960
So, when the victim connection is trying to do handshake, the program executes whatever we want.

25:18.440 --> 25:24.960
Anyway, the heap is unstable, so we need to send fuzzy connections to meet the condition.

25:25.120 --> 25:28.240
The server may crash sometimes, but it's fine.

25:28.240 --> 25:30.680
Fort gate has a reliable watchdog.

25:30.780 --> 25:35.940
We just need several attempts, taking about 1 to 2 minutes to get a shell.

25:37.120 --> 25:41.780
So, this is the whole details of how we achieve remote co-execution.

25:41.940 --> 25:49.260
Maybe some of you are not binary guys, so you may wonder, is there any other way to get into a server?

25:50.160 --> 25:54.600
So, why not find another door to make your life easier?

25:55.660 --> 26:00.140
We found a magic backdoor in the log-in page.

26:00.160 --> 26:05.060
This function was originally used to update outdated password.

26:05.340 --> 26:08.160
However, they failed to authenticate.

26:08.160 --> 26:15.780
So, we can simply use this secret key, which is called magic, to reset any user's password.

26:18.950 --> 26:25.630
Now, we're going to demonstrate how we pop a root shell from the only exposed HTTP export.

26:30.420 --> 26:36.580
We put our PHP exploit on an HTTP server, and this is our export.

26:36.800 --> 26:44.920
In order to control the parameter of system, we first do a stack pivot and make our buffer become the stack.

26:45.320 --> 26:49.720
After that, we do an ROP chain to call system.

26:52.020 --> 26:54.760
And here is the reverse shell command.

26:54.760 --> 26:58.080
We use Python to build a reverse shell.

27:01.530 --> 27:07.070
And we concatenate these strings to overflow the SSL structure.

27:11.040 --> 27:13.500
Now, we can start hacking.

27:13.500 --> 27:19.380
In the first panel, we open a port to receive the reverse shell.

27:22.380 --> 27:28.180
And we start a fuzzing thread to build multiple normal connections.

27:33.800 --> 27:36.400
Then we attack the server.

27:36.780 --> 27:42.620
We first try to leak username and 10 hex password from the web session.

27:47.030 --> 27:55.880
As you can see, we found an username, main, and password.

27:55.880 --> 27:58.120
This is password for main.

27:58.600 --> 28:05.240
We can use this account to login and make a SSL VPN proxy or PHP export.

28:05.240 --> 28:07.940
We only need to wait a few seconds.

28:12.730 --> 28:15.130
Okay, here we got the root shell.

28:15.130 --> 28:16.530
Thank you very much.

28:38.110 --> 28:42.090
Okay, the next test we talk about is Perl Secure.

28:42.090 --> 28:49.490
Perl Secure is the market leader of SSL VPN and was from a diversity of juniper networks.

28:49.490 --> 28:54.350
They are a Perl lover and built all the architecture stack from scratch.

28:54.570 --> 28:58.630
The architecture is old but stable and secure.

28:59.350 --> 29:05.710
And it's worth to mention, Perl Secure hooks all the process by LD preload.

29:05.730 --> 29:09.450
Due to the uh due to the monitor and security consideration.

29:09.710 --> 29:12.050
Uh we will discuss this later.

29:13.270 --> 29:16.250
Here is the vulnerabilities we find.

29:16.450 --> 29:22.310
Among them we will introduce a pre-auth arbitrary file reading and a post-auth command injection.

29:22.510 --> 29:26.530
We train these two bugs into the pre-auth remote core execution.

29:29.110 --> 29:32.390
The first bug is a pre-auth file reading.

29:32.990 --> 29:40.430
Perl Secure introduce a new feature called HTML5 access since version 8.2.

29:40.430 --> 29:46.690
It can access the telnet, SSH, and remote desktop by browsers.

29:47.050 --> 29:55.790
In order to adapt the new feature, Perl Secure create a new if condition to handle all static resources.

29:56.690 --> 30:02.830
Thanks to the new feature, the original strict validation has been bypassed.

30:04.090 --> 30:07.030
So, am I affected by this?

30:07.790 --> 30:12.910
All unpatched version except the end of life version are affected.

30:13.470 --> 30:17.370
Here is the payload for you to check your SSL VPN.

30:18.110 --> 30:24.650
When there is a special pass in the end of the URL, the pass validation become loose.

30:26.570 --> 30:29.730
And uh what can we get from this?

30:30.270 --> 30:37.610
We can get numerous useful information such as the server private key to decrypt the SSL connection.

30:37.610 --> 30:47.230
We can also get information configure uh we can also get important configuration such as the radius and LL depth password.

30:47.530 --> 30:58.550
And all users password hash and sensitive cookies which are cached in the web VPN like Google, Dropbox, and iCloud.

30:59.390 --> 31:05.330
The last and the most important is the cached plaintext password.

31:05.790 --> 31:08.110
Yes, plaintext again.

31:11.150 --> 31:17.270
For now, we get a credential so we are able to access the corporation network easily.

31:17.850 --> 31:23.610
However, our goal is to get co-execution for persistent and first actions.

31:24.110 --> 31:30.270
So, here we send a command injection in manag- management interface together.

31:30.630 --> 31:35.530
From this code fragment, it's very obvious and straightforward.

31:35.570 --> 31:42.790
If we can control the options, we can inject arbitrary command to this Perl function.

31:43.830 --> 31:46.210
And of course we can.

31:46.210 --> 31:50.570
We can control the options from the troubleshooting patch.

31:50.970 --> 31:53.270
So, is that simple?

31:53.910 --> 31:56.370
No, I don't think so.

31:56.730 --> 32:04.890
In order to avoid potential vulnerabilities, Perl secure applied a lot of hardening on their products.

32:04.930 --> 32:17.550
Such- such as the system integrity check and the read-only file system to protect the backdoor from uh to protect from backdoors in Chrome tab or web root.

32:18.010 --> 32:22.790
The most effective hardening is the DSF module.

32:22.790 --> 32:27.850
It's like the safeguard to protect Perl from dangerous operations.

32:29.430 --> 32:34.770
The DSF is a Perl module which is written in C++.

32:34.870 --> 32:45.330
The module implement its own command parser and hooks several dangerous functions such as the system, open, and backstick.

32:45.950 --> 32:53.270
It also disallow numbers, bad characters, and re-implement the DNS IO redirection in Perl.

32:53.710 --> 32:59.710
So, due to the hardening, we cannot perform any command injection.

33:01.290 --> 33:04.910
We tried several ways to bypass the hardening.

33:04.910 --> 33:09.510
Of course, the first come out of my mind is the argument injection.

33:10.350 --> 33:14.410
However, the TCP dump in Perl secure is too old.

33:14.410 --> 33:22.530
So, we failed because it didn't support several juicy features such as the post load tab command.

33:23.710 --> 33:30.070
While examining the system, we find Perl secure store the template cache in a directory.

33:30.170 --> 33:33.210
We tried to write into this directory.

33:33.610 --> 33:39.990
But we can't use standard out because it's already directed to the newer device.

33:40.290 --> 33:45.050
What we can do is only abusing the set file argument.

33:45.110 --> 33:52.690
But it seems there is no way to generate a polyglot file in both Perl and PCAP format.

33:54.530 --> 33:57.450
So, it's time to dig deeper.

33:57.450 --> 34:03.670
We dive into the DSF implementation to see is there anything we can leverage.

34:04.390 --> 34:07.790
We found a flaw in the command parser.

34:08.070 --> 34:16.090
When there is an incomplete IO redirection, the rest of the IO part will be truncated.

34:17.230 --> 34:25.910
However, also we can re-control the standard out, we still can't find any way to generate a valid Perl.

34:27.770 --> 34:31.030
So, let's think out of the box.

34:31.450 --> 34:34.130
Standard out is uncontrollable.

34:34.130 --> 34:38.090
But, could we write a script by a standard error?

34:40.100 --> 34:49.580
When you force the TCP dump to open a non-existent file, it will show the error, no such file or directory.

34:50.340 --> 34:54.820
From the error, it seems we can partial control the message.

34:54.920 --> 35:01.000
We try to pipe the standard error to Perl, but we still get nothing.

35:03.120 --> 35:16.040
However, when we try to use another file name, such as the print 1, 2, 3 with a hashtag, we try to pipe the standard error to Perl again, and the magic happens.

35:16.680 --> 35:20.600
The Perl print out the 1, 2, 3 result errors.

35:23.020 --> 35:25.620
So, okay, the Perl 101.

35:26.240 --> 35:33.280
Perl supports the go-to label, so the TCP dump with a colon becomes a label in Perl.

35:33.460 --> 35:37.700
And we use the hashtag to comment the rest of the part.

35:37.700 --> 35:41.800
So, the standard error becomes a valid Perl now.

35:43.720 --> 35:45.980
This is our final exploring.

35:45.980 --> 35:48.660
We will explain the payload one by one.

35:49.860 --> 35:54.700
The first is to make the TCP dump open a non-existent file.

35:54.700 --> 36:00.360
The file name will be part of the error message in, in standard error.

36:01.320 --> 36:06.600
And then we redirect the standard error into the cache directory.

36:06.860 --> 36:12.240
Here we name the file as set cookie dot THT and error dot TTC.

36:13.380 --> 36:16.540
The last is the incomplete IO symbol.

36:16.540 --> 36:22.140
This symbol abuse the command parser to ignore the rest of the IO redirection.

36:22.760 --> 36:33.380
Once our standard error has been written into the cache directory, we can just fetch the corri- corresponding patch to execute our command.

36:33.880 --> 36:40.080
By training these two vulnerabilities, we can get a reliable pre-auth remote co-execution.

36:42.360 --> 36:47.200
We have a report all of our finding to Perl secure Pcert.

36:47.200 --> 36:50.140
And this is the response from them.

36:50.200 --> 36:53.720
They fixed all the bugs within a month.

36:53.780 --> 36:57.100
Their reaction is very quick and professional.

36:57.280 --> 36:59.740
It's a great time to work with Perl secure.

36:59.740 --> 37:02.960
They are such a really responsible vendor.

37:06.270 --> 37:14.350
After Perl secure released all the patches, we kept monitoring the internet to see the large corporations response time.

37:14.890 --> 37:16.350
Twitter is one of them.

37:16.350 --> 37:20.310
They are known for their bug bounty program and nice to hackers.

37:21.070 --> 37:26.770
However, it's not good to exploit a one day right after the patch released.

37:26.850 --> 37:31.590
So, we wait 30 days for Twitter to upgrade their SSO VPN.

37:33.810 --> 37:36.450
This is the Twitter SSO VPN.

37:36.830 --> 37:39.330
It's just a simple login patch.

37:40.870 --> 37:46.530
From the reconnaissance, we know the last time Twitter upgrade is in last December.

37:46.650 --> 37:49.750
So, Twitter is likely vulnerable.

37:51.150 --> 37:58.050
We have verified the bug and got a bunch of user credentials in plain text.

37:58.910 --> 38:05.390
However, we encountered some problems while trying to pop our shell from Twitter.

38:07.010 --> 38:11.150
Yes, the first problem is the two fact authentication.

38:12.910 --> 38:18.170
Due to the two fact authentication, also we can get a plain text password.

38:18.170 --> 38:20.470
We still can't do anything.

38:20.710 --> 38:25.110
So, the first thing we need is to find a way to bypass that.

38:26.810 --> 38:30.170
We observe Twitter enable the loaming session.

38:30.330 --> 38:34.190
Loaming session is a feature to enhance the mobility.

38:34.430 --> 38:38.490
It allows a session from multiple IP locations.

38:39.490 --> 38:47.190
So, once we know that, we download the database and force the session to bypass the two fact authentication.

38:49.230 --> 38:52.430
And finally, we log into their system.

38:53.770 --> 38:58.290
The next problem is the SS control in management interface.

38:58.650 --> 39:03.530
As we mentioned before, we have a command injection here.

39:03.810 --> 39:11.130
However, for security consideration, most of the corporation disable this interface on public.

39:11.150 --> 39:15.770
So, we need to find another way to access the interface.

39:17.150 --> 39:22.750
We leverage the web VPN feature again to connect to itself.

39:22.750 --> 39:25.290
It's just like the SSRF.

39:25.670 --> 39:33.330
We use the zero to bypass the SSR- SSRF protection and access the management interface.

39:33.670 --> 39:36.470
And finally, we got there.

39:39.220 --> 39:47.000
However, the last problem is that we don't find any manager's plain text password in cache.

39:47.480 --> 39:53.640
Practically, most of the manager only log into their system at the first time.

39:53.840 --> 40:01.920
The only thing we have is the password hash in sorted md5crypt and SHA-256 format.

40:02.620 --> 40:08.580
So, we launch a 70-code AWS to crack the hash.

40:11.620 --> 40:16.620
And uh, see ours later.

40:18.040 --> 40:24.380
We crack the hash and s- and successfully log into their management interface.

40:24.520 --> 40:29.560
We are lucky because the length of the password is only 10.

40:29.560 --> 40:32.940
And the first character is capital B.

40:33.160 --> 40:36.840
It's a very early stage of our cracking queue.

40:38.080 --> 40:43.400
We exploit our command injection and try to run the command ifconfig.

40:43.800 --> 40:45.800
And we got a shell.

40:47.240 --> 40:50.080
We report all of our findings.

40:51.880 --> 40:53.440
Thank you.

40:57.660 --> 41:01.860
We report all of our findings to their bug bounty program.

41:03.020 --> 41:06.160
And got the highest bounty from Twitter.

41:14.480 --> 41:16.960
Also, we cannot prove that.

41:16.960 --> 41:21.160
It seems this is the first remote code execution on Twitter.

41:22.620 --> 41:26.020
Okay, the last is the bonus for you.

41:26.040 --> 41:31.680
Our company, Def Core, provides the most professional rating service in Asia.

41:31.760 --> 41:36.960
So, let's talk about how to make the rating more red.

41:38.540 --> 41:43.800
In a rating operation, the personal computer is more valuable.

41:43.800 --> 41:50.240
So, in order to take control of all the clients, we need to weaponize the SSO VPN.

41:50.800 --> 41:58.580
There are several old school methods before, such as the waterhole attack and repress the VPN installer.

41:59.180 --> 42:02.700
But here, we propose a new method.

42:02.700 --> 42:04.700
It's the logon script.

42:05.020 --> 42:09.540
Logon script is the feature in almost every SSO VPN.

42:09.540 --> 42:16.580
It can execute corresponding script to mount a network file system or change the routing table.

42:17.380 --> 42:24.180
So, here we will show you a demo to show you that how we compromise the VPN clients.

42:30.760 --> 42:33.840
Okay, this is our demonstration.

42:34.020 --> 42:37.340
As you can see, the exploit needs one argument.

42:37.340 --> 42:41.440
So, we append our target right after the exploit.

42:46.420 --> 42:50.140
Here we got a username and hash of admin.

42:50.520 --> 42:53.700
Also, we could not find the plain text password.

42:53.700 --> 42:58.520
We can still change our cookie to the session ID of admin.

43:15.210 --> 43:21.570
Okay, once our modification is done, we can access the management in the fast.

43:26.880 --> 43:29.720
And we have become the admin.

43:32.910 --> 43:34.510
Thank you.

43:36.330 --> 43:42.470
Here we leverage the feature on the user loads and the VPN tunneling.

43:42.790 --> 43:45.770
We find a logon script section.

43:45.890 --> 43:53.010
Here you can see the logon script supports not only Windows, but also Linux and Mac OS.

43:53.210 --> 43:57.210
So, we use the calculator as our backdoor.

44:05.140 --> 44:11.400
And once our modification is done, we change to the laptop of our victim.

44:16.020 --> 44:17.860
Yeah, it's cute.

44:18.780 --> 44:29.120
The victim launch the Perl secure agent and try to connect to the SSO VPN with his username and password.

44:34.720 --> 44:40.340
And once the connection has been established, the calculator will be popped automatically.

44:49.540 --> 44:53.380
Okay, here we finish all of our slides.

44:53.380 --> 44:56.360
But how to mitigate such attacks?

44:56.360 --> 44:58.920
Here we give several recommendations.

44:59.180 --> 45:02.580
The first is to- is the client sign certificate.

45:02.780 --> 45:09.100
Without a certificate, the malicious connection will be dropped during SSO negotiation.

45:09.180 --> 45:12.720
The next is to enable multi-factor authentication.

45:12.720 --> 45:15.960
It can decrease numbers of text service.

45:16.100 --> 45:24.640
And the last, remember to enable full log audit and subscribe the vendor's advisory to keep your system updated.

45:25.500 --> 45:30.980
This is the end of our presentation and here is our contact information.

45:30.980 --> 45:33.780
We will- okay.

45:40.450 --> 45:42.130
Okay.

45:42.310 --> 45:47.250
Okay, so, we will post all the detail right after our talks.

45:47.250 --> 45:52.070
So, please check that and let us know if you have any further questions.

45:52.070 --> 45:53.370
Thank you for being here.

45:53.370 --> 45:54.570
Again, thanks.

