WEBVTT

00:00.000 --> 00:02.400
Good afternoon, DEF CON.

00:03.520 --> 00:07.160
Our next talk is Zero Trust Total Bust.

00:07.160 --> 00:11.500
Please give a big welcome to our next speakers, Dave and Rich.

00:18.280 --> 00:23.900
Hey everyone, thanks for coming to our talk about zero trust network access.

00:24.180 --> 00:26.020
I'm Dave, this is Rich.

00:26.140 --> 00:32.040
We both work at Amberwolf, which is a UK-based consultancy specialising in red teaming and bone research.

00:32.040 --> 00:40.380
We're covering a lot of bugs in this 45 minutes, but all of the technical details will be on our blog within the next few weeks, some of them straight after this talk.

00:41.840 --> 00:43.560
So everyone's heard of zero trust.

00:43.560 --> 00:47.060
The theory is that no user, device or request is inherently trusted.

00:47.120 --> 00:50.820
Everything must be continuously evaluated against a set of access controllers.

00:50.820 --> 00:55.300
So even if you've got valid creds, you won't get access unless all the criteria are met.

00:56.760 --> 00:59.460
There's some terminology that we'll be using in the presentation.

00:59.740 --> 01:07.840
If you think of SaaS as like checking whether the user and device are permitted to access a resource, acting like a traffic controller.

01:07.920 --> 01:13.860
And then you've got steering, which is routing traffic based on conditions, so like ACLs.

01:13.920 --> 01:16.060
Identity providers feature in this.

01:16.060 --> 01:17.320
It's not their fault.

01:17.500 --> 01:20.660
And we've included a definition of privacy just as a reference.

01:22.440 --> 01:27.800
So the number one question we got asked after our last presentation was, what about Zscaler?

01:29.040 --> 01:36.180
And we've all seen adverts similar to this saying that legacy VPNs are dead, need to move to the cloud, zero trust network access.

01:36.260 --> 01:42.420
We also routinely see these products on red team engagements, so we thought we'd better take a look at whether they live up to their claims.

01:45.230 --> 01:46.470
So a picture of the scene.

01:46.470 --> 01:50.190
Everyone's panicking over the latest Advanti bug and they want to move to ZTNA.

01:50.290 --> 02:02.050
So what happened is that people just replaced their VPN with a ZTNA product but then just used it just like a VPN, so no granular access controls, just brokering connections into the internal network.

02:02.410 --> 02:16.090
And actually, even worse, we've seen a lot of this trusted corporate LAN concept used in the ZTNA world, but instead this time, you're sharing an IP space with every other customer of that ZTNA product.

02:17.610 --> 02:28.550
So we see conditional access policies like this, where there's an exclusion for MFA from the ZTNA public IP ranges to reduce authentication friction.

02:28.970 --> 02:32.570
And this means that we can just bypass MFA by coming from those ranges.

02:32.830 --> 02:39.870
A lot of the vendors do have a concept of dedicated IPs, so if you do have to do this, then maybe look at that.

02:40.470 --> 02:43.390
But enough of the preamble, let's get into some actual bugs.

02:45.050 --> 02:47.650
So checkpoint ZTNA offering is called Harmony.

02:48.270 --> 02:55.790
We cracked open the Windows client and immediately saw a reference to an encrypted private key within an upload to SFTP function.

02:55.990 --> 02:56.730
Interesting.

02:56.730 --> 03:01.870
This function is called whenever a customer chooses to upload log files to the checkpoint supporting.

03:02.830 --> 03:13.110
And that decode resource function you saw, that just decrypts a resource from within the binary with a hard coded AES key and IV, and the result is your standard open SSH private key.

03:13.770 --> 03:22.090
The log files were also encrypted before being uploaded to the SFTP server, but the encryption key was predictable and brute forceable.

03:22.630 --> 03:38.390
The log files contained JWTs that lived for 30 days, so the impact is that any customer that had uploaded logs, um, was, could, could just be compromised because those JWTs can be used or, or straight to the, uh, ZTNA service.

03:38.750 --> 03:44.250
Um, read access to the SFTP file system was removed immediately upon reporting to checkpoint.

03:44.310 --> 03:45.210
That's pretty quick.

03:45.390 --> 03:49.870
Um, we've got some more bugs in this product as well, but they are still in disclosure at this point.

03:52.230 --> 03:59.010
When we start this research, we made like a little wish list of, uh, what are the best bugs we could possibly get, uh, in all of these products.

03:59.110 --> 04:02.950
So we're going to keep this table updated as we go through the presentation.

04:05.780 --> 04:10.840
So next we're going to take a look at Zscaler, which is a very popular ZTNA product.

04:10.840 --> 04:12.900
Um, you see this a lot in red teams.

04:12.980 --> 04:15.820
And we'll start from a completely unauthenticated perspective.

04:16.180 --> 04:20.440
So the first thing that happens when you launch a Zscaler client is you put in your email address.

04:21.160 --> 04:25.660
As soon as you do that, the client's going to start making requests to the mobile API.

04:25.860 --> 04:39.380
So the first request it makes is, uh, it's encrypted here and, um, we don't have time to go through reversing the exact encryption routine here, but to summarize, essentially it generates a random AS key.

04:39.620 --> 04:45.940
It combines that with a hard coded key and then it encrypts that with RSA and adds it to an auth token header.

04:46.180 --> 04:50.720
And then that blob that you see there in the post request is encrypted with AS.

04:51.100 --> 04:52.920
So we'll just decrypt that now.

04:53.600 --> 05:00.700
So you can see here it sends a device type and a user email and then that uses that to fetch the cloud endpoint host name.

05:01.560 --> 05:04.100
And then the next request is this get AEP.

05:04.600 --> 05:07.020
And again, we just decrypt this.

05:07.520 --> 05:14.400
Uh, and so before you put in a password, it pulls down this policy, uh, pre-auth, and it's called the pre-auth configuration for the tenant.

05:15.460 --> 05:17.720
So what does a pre-auth config contain?

05:18.300 --> 05:33.440
So this can include configuration details such as the authentication settings, such as whether the tenant is using IDP, or it can contain things like the cloud features that are enabled, whether they're using ZPA, uh, Zscaler private access, or just ZAA,

05:33.440 --> 05:36.680
uh, and what features in the ZCC client are enabled.

05:36.680 --> 05:42.540
So things that we might be able to potentially abuse once we get a shell for things like privilege escalation.

05:45.510 --> 05:52.470
So this has been fixed now, but the pre-auth config also used to contain a URL for the pack file.

05:52.570 --> 05:55.170
And this is something that we'd commonly see on red teams.

05:55.530 --> 06:09.650
So, um, they usually look something like this one here with lots of misconfigurations in, so it might be things such as like, misconfigured wildcards in domains, expired domains, uh, or abusable services like Azure.

06:09.870 --> 06:17.050
And what we're looking for here is domains that we can use to bypass inspection and we can use those potentially for C2.

06:18.710 --> 06:25.110
So another way that Zscaler can be configured without a, uh, the ZCC client is in this explicit proxy mode.

06:25.130 --> 06:34.870
So the idea here is that users traffic is steered to Zscaler's cloud proxies either by explicitly setting a proxy in their browser or via a pack file.

06:35.430 --> 06:40.970
And what happens here is the user's HTTP requests get pushed through the Zscaler cloud proxy.

06:41.130 --> 06:43.530
Uh, the proxy then checks for a gateway cookie.

06:43.590 --> 06:48.230
If no cookie is found, the user's redirected to their IDP to do auth.

06:48.750 --> 06:56.290
The user is then sent back through the proxy and then the proxy checks that gateway cookie and strips that from the request and forwards it back to Zscaler .

06:58.670 --> 07:09.670
So it might not be a surprise if we can steal the gateway cookie from a user's device, then we can also authenticate to the Zscaler gateway and make our traffic appear as if it's coming from a Zscaler IP.

07:10.490 --> 07:12.650
But what about if we don't have a gateway cookie?

07:13.550 --> 07:19.190
Well, unfortunately we can't show you the next slide, because Zscaler asks us to remove it while they fix it.

07:20.690 --> 07:23.890
But the good news is, we've got a different bug to show you.

07:23.970 --> 07:25.030
A better bug.

07:25.350 --> 07:35.010
Uh, so to pick up where you left off on the Zscaler client flow, if a tenant is configured for SAML auth, the client makes a request to the CL star end point.

07:35.530 --> 07:46.830
This get request includes the domain parameter, a code challenge which is used for PKC, so this is essentially a client chosen sha256 hash, which the user has the plain text for.

07:47.430 --> 07:54.630
And then the server responds with a SAML form, with a SAML request relay state parameter, fairly standard SAML flow.

07:54.730 --> 07:59.690
This is then submitted by the client browser and redirected to the IDP.

08:00.770 --> 08:09.350
So once the user signed into their identity provider, the SAML response and the relay state are posted back to this SFC SSO end point.

08:10.010 --> 08:20.770
This then responds with a 302 redirect, redirecting the client back to the mobile end point test.html end point containing a JWT in the redirected URL CKE parameter.

08:21.950 --> 08:24.790
This JWT can then be used to register a device.

08:24.790 --> 08:28.830
And that's summarized as a typical SAML login flow.

08:29.590 --> 08:32.870
But let's take a step back and have a look at that last step again.

08:33.570 --> 08:37.750
So the client sends back this SAML response to the Zscaler service provider.

08:38.190 --> 08:47.590
The server should then decode the SAML response, extract the user details from the SAML assertion and validate that the signature is valid for that assertion.

08:47.770 --> 08:51.110
For the one that's been configured by the admin in the portal.

08:51.230 --> 08:52.530
All fairly standard.

08:53.470 --> 09:01.310
However, what we found is that the signature on the SAML assertion was only checked for presence and it wasn't validated against the IDP's public key.

09:01.310 --> 09:06.330
So we could just sign it with any key we wanted or even one with an invalid signature.

09:06.950 --> 09:11.430
So this gives us an auth bypass for any Zscaler tenant using SAML for authentication.

09:13.330 --> 09:19.670
So we reported this to Zscaler on the 18th of July and they were very quick, fixed it within about four hours.

09:20.230 --> 09:25.670
On Tuesday the 22nd of July, we tried the POC again and it worked.

09:25.990 --> 09:34.170
So we reported this regression to Zscaler and they confirmed that they had to roll back the patch due to a more critical issue that was introduced.

09:35.590 --> 09:41.370
So this has now been fixed and there's a CB so it's a CB 2025 54982.

09:41.450 --> 09:47.610
And it's fully resolved, doesn't require any interaction by Zscaler clients.

09:49.110 --> 09:51.370
So we're going to show a demo of this now.

09:52.470 --> 09:57.570
So what we're going to do is we're going to run our script which is going to forge the SAML assertion.

10:01.930 --> 10:08.350
And this contains now, we've got our JWT back and we've got our code challenge which we need to redeem the JWT.

10:14.720 --> 10:22.040
And then we're going to use our Pyscaler tool which is just going to take that JWT and then register a fake machine in Zscaler.

10:23.100 --> 10:32.640
So you can see now in the admin portal this is our machine that we've registered using that JWT and you can see that the hardware ID that we chose to register with them.

10:38.310 --> 10:40.450
So let's take a look at that wish list again.

10:40.530 --> 10:42.930
We can tick off off bypass Zscaler.

10:44.830 --> 10:46.530
So moving on.

10:46.750 --> 10:52.490
Another way that Zscaler can be configured is with this authentication mode called device token authentication.

10:52.830 --> 11:05.550
So this isn't enabled by default but it enables admins to allow a token to be distributed to machines or mobile devices that use, that can use Zscaler as the identity provider.

11:06.170 --> 11:08.550
This is documented in Zscaler's docs.

11:08.590 --> 11:13.250
So on Windows you simply specify the token and user as MSI arguments during install.

11:13.310 --> 11:19.190
But the problem here is that it only validates that the token is valid for that tenant.

11:19.270 --> 11:22.810
There's no association with a specific user.

11:23.210 --> 11:31.730
So if an attacker or a malicious user is able to extract that token from an endpoint, they can then register as a machine with any user name.

11:33.670 --> 11:41.970
Or simply by changing the user name on an existing device, they can potentially bypass steering policies by simply changing the user name and registering as anyone they want.

11:43.590 --> 11:45.950
So where is the device token stored?

11:46.310 --> 11:50.650
So when installing with the MSI arguments, this actually ends up in the registry.

11:50.650 --> 11:56.130
So there's a device token that's stored in the registry in clear text and a user name parameter.

11:56.130 --> 12:00.110
For mobile devices, this is typically deployed by an MDM config.

12:01.710 --> 12:06.650
So we're going to show a demo now of device token extraction and replay.

12:11.680 --> 12:17.440
So the user, this is on the victim's machine, so we're going to extract that device token from the registry.

12:21.020 --> 12:25.700
And then on our attacker VM, we're now going to import that token.

12:26.220 --> 12:28.380
So we're going to pause that scaler.

12:32.470 --> 12:35.690
We've then imported those tokens and user name.

12:39.530 --> 12:42.390
Then we'll just kill that scaler so it picks up that new token.

12:50.100 --> 12:53.400
So you see now, we're logged in as user 1 with just the token.

12:54.300 --> 12:59.060
And if we try and access the internet, we can't get to the internet because this user doesn't have internet access.

12:59.460 --> 13:01.640
So let's try a different user.

13:07.390 --> 13:11.030
So again, we suspend it and we'll just go in and change the user name in the registry.

13:13.210 --> 13:16.190
So we'll try admin 1, they've probably got better access.

13:25.700 --> 13:27.620
Registers as admin 1.

13:28.400 --> 13:31.200
You can see now we've got the network admin policy.

13:32.940 --> 13:34.460
And we can access the internet.

13:43.240 --> 13:45.340
So move on to Netscape.

13:45.380 --> 13:50.940
We came across this on a red team engagement and it seemed quite architecturally similar to Zscaler.

13:51.840 --> 13:56.560
There's a couple of specific bits of terminology to talk about here.

13:56.560 --> 13:58.700
So we've got an org key.

13:59.400 --> 14:02.080
And that's assigned to your tenant.

14:02.080 --> 14:03.060
It's immutable.

14:03.220 --> 14:05.300
So it's always going to be the same one.

14:05.300 --> 14:08.880
And we've got a user key which is assigned to the user.

14:09.280 --> 14:10.400
Also immutable.

14:10.400 --> 14:13.300
So always going to be the same for that user.

14:13.300 --> 14:14.360
Not revocable.

14:17.040 --> 14:19.920
Recon, again, very similar to Zscaler.

14:19.920 --> 14:21.340
The tenant name's sent.

14:21.760 --> 14:26.880
And if the tenant's configured to hand off to another identity provider, a SAML request is returned.

14:27.240 --> 14:29.280
And that contains the org key.

14:30.440 --> 14:34.000
So, you know, we've already kind of leaked that at that point.

14:35.200 --> 14:42.840
If they're not configured to use SSA, then there's a high chance that their kind of customer admin portal bit is.

14:42.900 --> 14:48.580
So if you go to like customer.goscope.com, there's the same kind of SAML request flow.

14:49.040 --> 14:50.600
And again, it leaks the org key.

14:50.680 --> 14:54.380
So I think we've established at this point that the org key isn't really a secret value.

14:57.940 --> 15:00.100
Recon, again, very similar to Zscaler.

15:00.100 --> 15:04.900
You can use this org key to pull parts of the tenant configuration or the pack file.

15:04.960 --> 15:06.940
And this is before you supply the password.

15:08.860 --> 15:13.480
There's actually more information that's leaked to Netscape than there is through Zscaler.

15:13.820 --> 15:15.880
And you can see some of the end points there.

15:16.800 --> 15:21.100
And you can kind of get the steering config and everything before you've even supplied credits.

15:22.320 --> 15:30.580
We're going to go through the flow of a publicly disclosed authentication bypass in Netscape to set the scene for kind of what comes afterwards.

15:31.040 --> 15:38.020
So here we start with our first request, exchanging our knowledge of the tenant name for a SAML request.

15:38.020 --> 15:41.060
And remember that SAML request contains our org key.

15:42.360 --> 15:46.980
As is convention, the next step sends the SAML request to the identity provider.

15:47.460 --> 15:49.980
And the SAML response is received.

15:50.020 --> 15:52.020
So it's all fairly normal so far.

15:53.060 --> 15:55.840
That SAML response is exchanged for JWT.

15:55.840 --> 15:57.740
Again, all fairly standard.

15:59.300 --> 16:03.020
Then the org key and the email address are exchanged for a user key.

16:03.900 --> 16:09.420
And as we said, that user key is just a long immutable string that's tied to the user.

16:10.300 --> 16:11.720
Uh, but hang on.

16:11.820 --> 16:14.660
This request has got no authentication at all.

16:15.180 --> 16:20.800
We can just see that we're supplying the org key that we have already leaked, uh, and an email address.

16:21.340 --> 16:30.440
So in actual fact, we can skip that whole SAML IDP stage and go straight to pretending that we're whoever we want, providing we know the org key and the valid email address.

16:30.900 --> 16:32.260
So we're Mclover.

16:34.080 --> 16:39.640
The authentication flow then continues by exchanging the org key and that user key for a configuration .

16:40.920 --> 16:45.780
And finally ends with exchanging that same information for a certificate that's used to set up the tunnel.

16:45.780 --> 16:54.600
And remember, this is for Netscape's private access solution, which in the scenarios we came across was, uh, equivalent to VPN access to the target network.

16:56.910 --> 17:08.230
So we got our exploit working, exploited the bug on the red team, network access, um, report the issue to Netscape, point out that it's already been reported, fixed, and even had a CVE advisory.

17:08.390 --> 17:12.770
Uh, so firstly, big props to Sander DeWitt for being the original discoverer of this issue.

17:12.910 --> 17:19.070
Um, we're a bit confused because if it had been fixed and had a CVE, why were we still exploiting this a year on?

17:19.270 --> 17:37.200
Um, I suppose the important takeaway is that Netscape's recommendations here are use secure enrollment, uh, and make sure you use, sorry, make sure you use device compliance, um, so that red devices can't connect.

17:40.070 --> 17:42.570
So we'll just talk through the fix for that quickly.

17:42.570 --> 17:50.710
So, uh, according to Netscape's advisory, this issue was first reported to Netscape, um, by the original discoverer on the 18th of April, 2024.

17:51.030 --> 17:58.370
Uh, they released an advisory on August the 26th, 2024, and assigned CVE 2024 7401.

17:58.510 --> 18:04.970
Uh, so this describes a new enrollment method called secure enrollment, and this was first introduced in release 11610.

18:04.970 --> 18:12.210
So interestingly in this advisory that they released, it also states that the issue was exploited in the wild by bug bounty hunters.

18:12.970 --> 18:20.130
Uh, so despite a CVE and advisory, we're still running this mode in, um, February 2025 when they made secure enrollment the default.

18:20.170 --> 18:26.330
Um, and even now in August 2025, we're still finding organizations who don't have secure enrollment enabled.

18:30.040 --> 18:31.600
So what about secure enrollment?

18:31.600 --> 18:32.580
How does that work?

18:32.580 --> 18:39.280
So this uses a secure enrollment token, and this has to be deployed via MDM to user's devices before registration.

18:39.640 --> 18:47.040
Uh, as a side note, we're not really sure why they didn't go for just validating the JWT that you could get in, in the offload, but we'll go through it now anyway.

18:47.880 --> 18:59.620
So we can see they've added an authorization header here, and this authorization header contains a JWT, and we're still specifying an org key in the URL, but we've now got this signed JWT in the authorization header.

19:00.440 --> 19:02.200
So how is this JWT made?

19:02.880 --> 19:14.900
It's signed with the secure enrollment token, and it contains the UPN and the user key, uh, along with the org key and, um, in the JWT as claims, uh, which you can see on the right here.

19:15.020 --> 19:22.240
As mentioned, this JWT is signed using secure enrollment token with HS256, but there's also an org key in the URL.

19:23.040 --> 19:25.040
So which one will the server use?

19:25.280 --> 19:27.700
The one in the JWT or the one in the URL?

19:28.860 --> 19:30.640
There's only one way to find out.

19:32.880 --> 19:35.080
That's right, get parameter wins.

19:36.260 --> 19:45.080
The server only checked the JWT was signed correctly for the org key within the JWT itself, but it actually uses the org key in the URL when it enrolls into the tenant.

19:46.020 --> 19:54.420
So if we supply a valid JWT for any Netscape tenant, and then we can tamper with the org key in the URL and begin secure enrollment process for any other tenant.

19:54.760 --> 20:01.280
This negates the need to know the secure enrollment token for the target org, as long as you have an enrollment token for an entirely different org.

20:01.500 --> 20:04.440
And we can specify the target user in the signed JWT.

20:04.900 --> 20:11.780
We even found leaked enrollment tokens online, so you don't necessarily need to be a Netscape customer to exploit this.

20:13.200 --> 20:14.740
So what about the fix?

20:15.160 --> 20:19.100
We reported this cross-tenant bug to Netscape on the 14th of March, 2025.

20:19.540 --> 20:24.080
They released a server-side fix in version 126 on May the 12th.

20:24.080 --> 20:27.800
This fix now checks that the org key in the URL matches the one in the JWT.

20:28.100 --> 20:35.340
Unfortunately there's no CV for this vulnerability, and despite Netscape being a CNA, they don't issue CVs for server-side fixes.

20:37.600 --> 20:41.700
So we're going to show a demo of the cross-tenant exploit now.

20:43.500 --> 20:53.460
So the attacker is going to run a script and they're going to provide the target tenant details, the EPN for the target tenant, and the org key for the target tenant, which remember can be leaked pre-auth.

20:53.660 --> 21:01.480
They're going to provide the org key and the secure enrollment token for the source org, and then this gets back a cert and a branding file.

21:02.100 --> 21:08.180
Then on the attacker's VM, they can then just import this, the branding file and the cert.

21:17.510 --> 21:19.690
So now we just restart Netscape.

21:34.080 --> 21:36.020
And now we have MPA access.

21:43.610 --> 21:46.150
So that's Netscape auth bypass completed.

21:51.300 --> 21:55.380
So we've seen how secure enrollment can be bypassed, but how should it work?

21:55.380 --> 22:04.240
As Rich said, it's usually kind of rolled out via MDM, like an in-tuned install argument or SCCM or something.

22:04.300 --> 22:11.420
The token's then stored in the registry in this location, and it's encrypted using DPAPI.

22:11.800 --> 22:21.720
But it's encrypted using flag 4, which equates to local machine, which in fact means that any user on the machine can decrypt it.

22:21.960 --> 22:30.300
It does have a little bit of entropy, and that's hard-coded as this is global entropy string, and yeah, that really is the entropy.

22:33.880 --> 22:46.180
We'll just show a quick demo just to show you that, yeah, you can actually extract that string as a low-pref user, and what you end up with is the decrypted enrollment key.

22:51.580 --> 22:53.560
That's what an enrollment key looks like.

23:00.030 --> 23:01.750
So what does all this mean?

23:02.750 --> 23:09.650
If you're an XSCAPE customer and you're still using IDP mode, there's still a complete auth bypass for enrollment.

23:10.510 --> 23:28.730
In secure enrollment mode, this has been fixed, but if your secure enrollment token is leaked, for example, from someone compromising your in-tuned environment and getting the install arguments, then you can still auth as any user and bypass string restrictions,

23:28.730 --> 23:35.270
and it's still possible if you've got an auth key, which is very easy to obtain to, to do loads of recon on a target environment.

23:37.920 --> 23:40.080
So we covered, covered the auth bypasses.

23:40.080 --> 23:41.340
What if you've already got a shell?

23:41.820 --> 23:53.000
If you're up against EDR, we might want to spend as little time as possible on a monitored endpoint, and actually a good option is to steal the ZTNA config, move it to our machine, and then we can access the internal network from a non -monitored endpoint.

23:56.520 --> 24:01.640
So both Zscaler and Netscape can store their configs as DPAPI encrypted blobs.

24:01.660 --> 24:04.060
Only Zscaler actually does this by default.

24:04.680 --> 24:08.640
But in theory, zero trust should stop you from stealing the config.

24:08.640 --> 24:10.460
The posture check should fail.

24:10.840 --> 24:13.580
The hardware ID should mismatch.

24:13.580 --> 24:17.260
But as we'll show, all these checks can be spoofed.

24:20.250 --> 24:23.130
So we'll have a quick primer on the Zscaler config.

24:23.490 --> 24:32.930
It's stored in a file, and it's encrypted, well, it's XORed with a fixed key after some kind of convoluted XOR shuffle.

24:34.990 --> 24:41.330
But to dump the config, you do require a system , and that means we need at least admin privileges to read it.

24:41.370 --> 24:48.990
Luckily, we've got two privesks in Zscaler as well, one of which we reported in 2023 and still isn't fixed.

24:50.410 --> 24:59.790
We can actually do, like, a whole other talk on the privesks, but we don't have time to, like, cover all the technical details in this bit.

25:00.410 --> 25:06.930
But we do have some demos to show you in a second after we've explained how they kind of roughly work.

25:06.930 --> 25:11.410
But if we go back to our table here, we can tick off config theft.

25:14.280 --> 25:21.640
So about these privesks, all of the ZTNA products we looked at shared a very similar architecture.

25:21.640 --> 25:26.680
They've got a low-privileged system tray and a high-privileged service or broker.

25:27.180 --> 25:30.460
And those two kind of communicate via IPC.

25:30.460 --> 25:36.540
That might be TCP socket and then pipe, RPC, but they all have one thing in common.

25:36.540 --> 25:41.300
They failed to properly validate the calling process.

25:41.380 --> 25:49.180
There's some attempts to do this by checking signing or path-based checks, but you can bypass that by injecting it into a relevant process.

25:49.440 --> 25:54.280
And there's also some kind of tamper proof stuff, but we bypass that, too.

25:54.460 --> 25:58.920
But just because you can call IPC methods, that doesn't automatically give you a system shell.

25:59.140 --> 26:10.820
But luckily for us, every product we looked at had a vulnerable IPC method that we could exploit to run code or system, whether that was directly via , like, process starting or via file writing.

26:14.350 --> 26:16.090
So I'll show a couple of quick demos.

26:16.090 --> 26:17.810
Here's our Netscape LP.

26:18.370 --> 26:21.270
You can see the attack is using a custom IPC client.

26:21.270 --> 26:26.350
Injects a TCP proxy into a legitimate process to bypass the path signature check.

26:26.830 --> 26:43.110
And then after this, the client actually enrolls Nacho VPN style, if you've seen that, into a malicious server, and it gets delivered an MSI update, and that MSI update gets run as system, and ping, we've got a system shell.

26:49.320 --> 26:52.420
So next up we've got Zscaler.

26:52.580 --> 26:55.860
This is version 4.7, which I think is the latest version.

26:55.880 --> 27:03.280
Again, using process injection to bypass the signer check and then trigger a vulnerable IPC method to load some malicious code.

27:03.760 --> 27:08.560
And then once we've got our system shell, we can dump the user's config, as we previously discussed.

27:11.480 --> 27:21.860
And then finally, we use a script to dump the various source values needed to spoof the hardware ID, which will be important later on when we discuss, um, hardware ID spoofing.

27:25.060 --> 27:26.780
So back to the wish list.

27:26.920 --> 27:31.640
We can tick off, and this is starting to look quite scary now, but let's carry on.

27:34.710 --> 27:35.510
Cool.

27:35.550 --> 27:38.350
So you've stolen the config and even rolled, now what?

27:38.510 --> 27:44.070
So we mentioned at the start of the talk that zero trust involves verification of the device as well as the user.

27:44.170 --> 27:47.250
Uh, and one of the ways that this is achieved is through processor checks.

27:47.350 --> 27:53.550
Uh, so these have been around for decades as, in SSL VPNs as well, and they're really no different in, um, in the ZTNA space.

27:53.650 --> 28:00.530
Uh, so the specific checks that are carried out vary vendor to vendor, but, um, they typically involve the ones we've listed here.

28:02.010 --> 28:14.510
Uh, in the ZTNA products that we assessed, the processor checks were retrieved over HTTP from the ZTNA server before being processed locally via the ZTNA client, and then the results were returned back to the, over HTTP to the server.

28:15.170 --> 28:27.490
So Netscape bypassing these checks was really simple, we just had to, uh, put an intercepting proxy between the client and the server and change status equals false to status equals true, and we could bypass the processor checks.

28:29.090 --> 28:37.630
Whilst this was mildly amusing, in practice, having an intercepting proxy between the client and the server is impractical due to things like DTLS and mutual TLS.

28:37.710 --> 28:45.870
Uh, so we took a different approach here, and instead of, we injected a DLL into the client and then used API hooking to spoof the checks at a Windows API level.

28:47.710 --> 28:51.430
So another piece of information that we had to fake was the hardware ID.

28:51.590 --> 29:02.750
The hardware ID is essentially a hash of information that's derived from various components in the operating system and hardware, um, and then this is sent during registration and later on during keep live or device assessment requests.

29:03.010 --> 29:13.270
Uh, it's supposed to be unique per user and per machine, um, and if the hardware ID mismatches, the server might refuse the connection or class it as a new device and force re-registration.

29:13.910 --> 29:21.470
Uh, in reality, all of the values that make up a hardware ID can be spoofed and we can generate the correct expected hardware ID.

29:21.470 --> 29:26.010
Uh, in the game cheat world, this would be called a spoofer and it's really no different for ZTNA.

29:26.990 --> 29:36.670
Uh, so we quickly realized this would make a great generic tool for tricking software that evaluated these various operating system components to, to trick these compliance checks.

29:36.770 --> 29:43.390
Uh, so we made this configurable D, DLL that could be injected into the ZTNA process and allow us to hook these API calls.

29:43.710 --> 29:50.110
Uh, for hooking the Windows API methods, we mainly use MinHook because it's a simple library and it's widely used.

29:50.130 --> 29:59.410
Um, for DLL injection, we mainly use the app, app init DLLs, um, method for DLL injection, but we also have the option to use a sign driver.

30:01.230 --> 30:05.570
So for most checks, a simple Windows API hook was all that was needed.

30:05.590 --> 30:08.710
Uh, however, to spoof some other checks, things that are slightly harder.

30:09.110 --> 30:14.290
Um, so one of the things that normally makes up the, the, uh, hardware ID check is CPU ID.

30:14.290 --> 30:17.730
So they use this as a way to get a unique fingerprint of the hardware.

30:17.930 --> 30:28.030
And the way this works is they'll execute a CPU ID instruction to extract the processor info and the feature bits, um, by saying EAX to one and then executing the CPU ID instruction.

30:28.310 --> 30:30.730
Uh, so we can't hook this because it's an instruction.

30:30.730 --> 30:32.910
It's not a, um, a method.

30:32.910 --> 30:35.710
Uh, so instead what we do is we use a page guard hook.

30:35.850 --> 30:41.370
So the way this works is we search through the, the, the memory and looking for the CPU ID instructions.

30:41.550 --> 30:44.090
And then we find the, the page that they're in.

30:44.090 --> 30:45.550
We set the page as page guard.

30:45.570 --> 30:51.890
And then when that instruction gets executed, it triggers an exception, which we can catch with a custom exception handler.

30:51.890 --> 30:58.150
And then we can swap the, the register values out just after the CPU ID instruction gets executed.

30:58.990 --> 31:02.610
The downside to this is it's slightly slower than an inline hook.

31:02.930 --> 31:09.470
Uh, another option would be to use a custom hypervisor to spoof this, but in reality, we didn't need to do this.

31:10.290 --> 31:17.370
So we then created this small GUI application to control the hook settings, allow us to spoof all these various values dynamically.

31:17.370 --> 31:24.170
Um, and this allows us to import the config and it'll automatically adjust the spoofing settings to the posture profile inside the config.

31:24.170 --> 31:32.510
Um, although some vendors offer the ability to perform cryptographically verified compliance checks or server side checks, they're not turned on by default.

31:32.550 --> 31:37.990
And some vendors don't actually support this feature at all, meaning that compliance checks can always be bypassed in this manner.

31:38.570 --> 31:41.150
Um, yep.

31:41.150 --> 31:47.830
Uh, also we got a side note here that, um, we called it red scaler, but it makes more sense in British English than American English.

31:47.830 --> 31:49.770
Otherwise, I guess we would have called it rescaler.

31:51.390 --> 31:53.410
Uh, we're going to do a demo of this now.

31:56.440 --> 31:58.360
So this picks up where we left off.

31:58.360 --> 32:03.720
So we, we privest, we stole the config and this is what the config looks like in plain text.

32:03.780 --> 32:06.420
So you can see it contains all the posture checks.

32:10.780 --> 32:13.900
So now we're going to import that config into our red scaler GUI.

32:20.550 --> 32:23.850
This is going to re-encrypt the config and put it in the right place.

32:23.950 --> 32:28.630
You can see here, it's picked up some of the posture checks and asked if we want to apply those automatically.

32:30.350 --> 32:33.870
Then it restarts red scaler and

32:46.180 --> 32:47.080
we're logged in.

32:53.790 --> 32:55.170
But we can't get to the internet.

32:56.250 --> 32:56.710
Oh, it's okay.

32:56.710 --> 32:58.490
We forgot to spoof BitLocker.

32:58.930 --> 33:00.030
So we'll just spoof that.

33:01.130 --> 33:03.210
Just to show you the posture checks are working.

33:10.720 --> 33:12.160
You sunk my battleship.

33:13.800 --> 33:15.940
That's a full house for all the products we looked at.

33:15.940 --> 33:18.400
Bar the, uh, checkpoint side quest.

33:21.750 --> 33:24.870
So let's have a couple of minutes on this privacy thing.

33:24.890 --> 33:34.570
So due to the way these products work, they have to install , uh, a root CA in order to inspect less traffic and provide you some of the security benefits that, that they offer.

33:34.670 --> 33:40.110
Um, I quite long lived here, like 2065, it's quite a long time for a set.

33:40.130 --> 33:47.270
Um, the way these are pushed down typically either with the policies or they're installed with the client.

33:47.890 --> 33:53.590
It's not really particularly difficult, uh, different to a traditional VPN appliance or, or a web proxy.

33:53.790 --> 33:58.150
Um, but the difference here is that the zero trust engine is, is very much an unknown.

33:58.150 --> 34:01.970
Your traffic enters there, it's decrypted and processed , that leaves again.

34:01.970 --> 34:06.310
You're trusting that it's routed correctly, um, that nothing else happens.

34:06.310 --> 34:15.030
Um, and we're sure this hasn't happened, but the compromise, a ZTN provider would allow some additional processing to be performed on the deep decrypted traffic.

34:15.070 --> 34:16.950
Um, and you would never know.

34:21.190 --> 34:24.310
So we'll talk through a couple of, uh, defense and mitigations here.

34:24.310 --> 34:31.510
So the most important one is if you are an Xcode customer and you're not using secure enrollment, please enable it now.

34:31.910 --> 34:37.530
Um, also ensure that clients are always updated, even if there's no CV published.

34:37.530 --> 34:41.610
Just because there's no CV doesn't mean there's no bugs, so make sure you're always up to date.

34:41.650 --> 34:46.990
Enable cryptographically secure checks or server side validated checks where they're supported.

34:47.430 --> 34:52.450
Um, as far as we know, there's nothing for Netscape, but, um, ZTN do support this since version 4.4.

34:52.490 --> 35:02.190
Uh, we've also shared some general hardening tips here and some mitigations to help limit the impact of config theft, for example, requiring re-authentication with a, a small re-authentication period.

35:02.470 --> 35:10.110
And to minimize the attack surface for privilege escalation, disable client side access to features such as debugging and verbose logging.

35:10.290 --> 35:19.270
Um, and finally, if you do use app based or domain based steering bypasses, ensure that these are appropriate for, and narrowly scoped, and they're reviewed on a regular basis.

35:20.450 --> 35:35.490
To detect malicious behavior, you can look at vendors provided logs from newly registered devices, devices that perhaps quickly switch from passing failures and fa- passing posture checks and failing posture checks, and make sure that you're ingesting these logs into your scene.

35:36.190 --> 35:49.710
You might also see devices coming from unexpected locations or, um, from unexpected operating systems, so for example, if a user normally uses a Mac, and then suddenly enrolls a Windows device, uh, you can also use EDR to detect activities on end points,

35:49.710 --> 35:58.010
such as reading sensitive registry keys or files, uh, and some of the techniques we've discussed require process injection, for example, bypassing those signature checks.

35:58.070 --> 36:09.750
Uh, equally, some vulnerabilities might cause a ZTNA process to spawn an unexpected child process, so using, uh, EDR to detect on unexpected child processes can be useful, too.

36:11.590 --> 36:16.070
So, there's a couple of techniques that are good for detecting token and config theft.

36:16.070 --> 36:21.650
Uh, Google have this brilliant blog that, uh, explains how to configure auditing from deep, for deep happy events.

36:21.750 --> 36:25.430
Uh, this is actually aimed at detecting browser cookie theft, but also applies here.

36:25.490 --> 36:38.010
So, if the data is, uh, flagged as auto, auditable during encryption, then the, the 4693 event will be raised during decryption, or when an attacker attempts to decrypt the value on the, on the machine.

36:38.330 --> 36:45.370
But, unfortunately, none of the vendors actually flag the data as auditable when it's created, uh, so we can't use this 4693 event type.

36:45.470 --> 36:52.950
However, we can use the very, very memorably named Microsoft Windows Crypto Deep Happy Log if we turn on debug locking.

36:53.030 --> 36:55.330
And this is also detailed in the, in the Google blog.

36:55.330 --> 37:04.030
And then this gives us a new event, event ID 16385, and we can use this to correlate the data description and the caller process ID to identify any potential misuse.

37:04.310 --> 37:15.370
Uh, so in the case of Zscaler, you can see here, uh, when we installed Zscaler config earlier, uh, you can see the data description is client configuration, uh, which is the description that's set by Zscaler during encryption.

37:16.250 --> 37:28.770
Uh, another option for audit, auditing access to sensitive registry keys and config files is to configure SACLs, uh, which will raise, uh, another event in the event security log, so this is, uh, event ID 4663.

37:29.010 --> 37:35.610
Uh, and you can see here the event that was raised when we exported the secure token from, um, from the registry for Netscape.

37:38.600 --> 37:43.680
So in conclusion, well it turns out there are no magic said TNA beans.

37:44.100 --> 37:48.000
We've got the same old bug classes reimagined for a new technology stack.

37:48.000 --> 37:53.600
Rather than zero trust, we're actually putting a lot of trust into these vendors and to process our data securely.

37:53.620 --> 37:57.860
And we expect them to clearly and effectively communicate when they do fix vulnerabilities.

37:58.060 --> 38:03.580
Even if those bugs are server side, so clients can make informed decisions regarding risk profile.

38:04.020 --> 38:07.460
When the bugs exist only in one place though, at least patching them is efficient.

38:07.660 --> 38:13.440
But even in that case, if the patch still requires you to change a setting, we think that this could be communicated more effectively.

38:14.040 --> 38:24.140
Vendors are still putting far too much trust into client side components as we saw with authentication bypass and posture profile bypasses, which doesn't really fit the zero trust principle.

38:24.360 --> 38:31.720
In summary, we found that in practice, rather than being never trust, always verify, we found it was more always trust, never verify.

38:33.700 --> 38:35.060
So thanks for watching our talk.

38:35.060 --> 38:35.880
We hope you enjoyed it.

38:35.880 --> 38:37.200
We've got a link here to our blog.

38:37.200 --> 38:39.860
We'll be publishing write ups over the next few weeks and days.

38:40.060 --> 38:43.060
And you can come up and speak to us and we'll take some questions.

