1 00:00:00,000 --> 00:00:02,400 Good afternoon, DEF CON. 2 00:00:03,520 --> 00:00:07,160 Our next talk is Zero Trust Total Bust. 3 00:00:07,160 --> 00:00:11,500 Please give a big welcome to our next speakers, Dave and Rich. 4 00:00:18,280 --> 00:00:23,900 Hey everyone, thanks for coming to our talk about zero trust network access. 5 00:00:24,180 --> 00:00:26,020 I'm Dave, this is Rich. 6 00:00:26,140 --> 00:00:32,040 We both work at Amberwolf, which is a UK-based consultancy specialising in red teaming and bone research. 7 00:00:32,040 --> 00: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. 8 00:00:41,840 --> 00:00:43,560 So everyone's heard of zero trust. 9 00:00:43,560 --> 00:00:47,060 The theory is that no user, device or request is inherently trusted. 10 00:00:47,120 --> 00:00:50,820 Everything must be continuously evaluated against a set of access controllers. 11 00:00:50,820 --> 00:00:55,300 So even if you've got valid creds, you won't get access unless all the criteria are met. 12 00:00:56,760 --> 00:00:59,460 There's some terminology that we'll be using in the presentation. 13 00:00:59,740 --> 00: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. 14 00:01:07,920 --> 00:01:13,860 And then you've got steering, which is routing traffic based on conditions, so like ACLs. 15 00:01:13,920 --> 00:01:16,060 Identity providers feature in this. 16 00:01:16,060 --> 00:01:17,320 It's not their fault. 17 00:01:17,500 --> 00:01:20,660 And we've included a definition of privacy just as a reference. 18 00:01:22,440 --> 00:01:27,800 So the number one question we got asked after our last presentation was, what about Zscaler? 19 00:01:29,040 --> 00: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. 20 00:01:36,260 --> 00: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. 21 00:01:45,230 --> 00:01:46,470 So a picture of the scene. 22 00:01:46,470 --> 00:01:50,190 Everyone's panicking over the latest Advanti bug and they want to move to ZTNA. 23 00:01:50,290 --> 00: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. 24 00:02:02,410 --> 00: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. 25 00:02:17,610 --> 00: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. 26 00:02:28,970 --> 00:02:32,570 And this means that we can just bypass MFA by coming from those ranges. 27 00:02:32,830 --> 00: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. 28 00:02:40,470 --> 00:02:43,390 But enough of the preamble, let's get into some actual bugs. 29 00:02:45,050 --> 00:02:47,650 So checkpoint ZTNA offering is called Harmony. 30 00:02:48,270 --> 00: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. 31 00:02:55,990 --> 00:02:56,730 Interesting. 32 00:02:56,730 --> 00:03:01,870 This function is called whenever a customer chooses to upload log files to the checkpoint supporting. 33 00:03:02,830 --> 00: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. 34 00:03:13,770 --> 00: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. 35 00:03:22,630 --> 00: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. 36 00:03:38,750 --> 00:03:44,250 Um, read access to the SFTP file system was removed immediately upon reporting to checkpoint. 37 00:03:44,310 --> 00:03:45,210 That's pretty quick. 38 00:03:45,390 --> 00:03:49,870 Um, we've got some more bugs in this product as well, but they are still in disclosure at this point. 39 00:03:52,230 --> 00: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. 40 00:03:59,110 --> 00:04:02,950 So we're going to keep this table updated as we go through the presentation. 41 00:04:05,780 --> 00:04:10,840 So next we're going to take a look at Zscaler, which is a very popular ZTNA product. 42 00:04:10,840 --> 00:04:12,900 Um, you see this a lot in red teams. 43 00:04:12,980 --> 00:04:15,820 And we'll start from a completely unauthenticated perspective. 44 00:04:16,180 --> 00:04:20,440 So the first thing that happens when you launch a Zscaler client is you put in your email address. 45 00:04:21,160 --> 00:04:25,660 As soon as you do that, the client's going to start making requests to the mobile API. 46 00:04:25,860 --> 00: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. 47 00:04:39,620 --> 00: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. 48 00:04:46,180 --> 00:04:50,720 And then that blob that you see there in the post request is encrypted with AS. 49 00:04:51,100 --> 00:04:52,920 So we'll just decrypt that now. 50 00:04:53,600 --> 00: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. 51 00:05:01,560 --> 00:05:04,100 And then the next request is this get AEP. 52 00:05:04,600 --> 00:05:07,020 And again, we just decrypt this. 53 00:05:07,520 --> 00: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. 54 00:05:15,460 --> 00:05:17,720 So what does a pre-auth config contain? 55 00:05:18,300 --> 00: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, 56 00:05:33,440 --> 00:05:36,680 uh, and what features in the ZCC client are enabled. 57 00:05:36,680 --> 00:05:42,540 So things that we might be able to potentially abuse once we get a shell for things like privilege escalation. 58 00:05:45,510 --> 00:05:52,470 So this has been fixed now, but the pre-auth config also used to contain a URL for the pack file. 59 00:05:52,570 --> 00:05:55,170 And this is something that we'd commonly see on red teams. 60 00:05:55,530 --> 00: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. 61 00:06:09,870 --> 00: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. 62 00:06:18,710 --> 00:06:25,110 So another way that Zscaler can be configured without a, uh, the ZCC client is in this explicit proxy mode. 63 00:06:25,130 --> 00: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. 64 00:06:35,430 --> 00:06:40,970 And what happens here is the user's HTTP requests get pushed through the Zscaler cloud proxy. 65 00:06:41,130 --> 00:06:43,530 Uh, the proxy then checks for a gateway cookie. 66 00:06:43,590 --> 00:06:48,230 If no cookie is found, the user's redirected to their IDP to do auth. 67 00:06:48,750 --> 00: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 . 68 00:06:58,670 --> 00: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. 69 00:07:10,490 --> 00:07:12,650 But what about if we don't have a gateway cookie? 70 00:07:13,550 --> 00:07:19,190 Well, unfortunately we can't show you the next slide, because Zscaler asks us to remove it while they fix it. 71 00:07:20,690 --> 00:07:23,890 But the good news is, we've got a different bug to show you. 72 00:07:23,970 --> 00:07:25,030 A better bug. 73 00:07:25,350 --> 00: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. 74 00:07:35,530 --> 00: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. 75 00:07:47,430 --> 00:07:54,630 And then the server responds with a SAML form, with a SAML request relay state parameter, fairly standard SAML flow. 76 00:07:54,730 --> 00:07:59,690 This is then submitted by the client browser and redirected to the IDP. 77 00:08:00,770 --> 00: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. 78 00:08:10,010 --> 00: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. 79 00:08:21,950 --> 00:08:24,790 This JWT can then be used to register a device. 80 00:08:24,790 --> 00:08:28,830 And that's summarized as a typical SAML login flow. 81 00:08:29,590 --> 00:08:32,870 But let's take a step back and have a look at that last step again. 82 00:08:33,570 --> 00:08:37,750 So the client sends back this SAML response to the Zscaler service provider. 83 00:08:38,190 --> 00: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. 84 00:08:47,770 --> 00:08:51,110 For the one that's been configured by the admin in the portal. 85 00:08:51,230 --> 00:08:52,530 All fairly standard. 86 00:08:53,470 --> 00: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. 87 00:09:01,310 --> 00:09:06,330 So we could just sign it with any key we wanted or even one with an invalid signature. 88 00:09:06,950 --> 00:09:11,430 So this gives us an auth bypass for any Zscaler tenant using SAML for authentication. 89 00:09:13,330 --> 00: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. 90 00:09:20,230 --> 00:09:25,670 On Tuesday the 22nd of July, we tried the POC again and it worked. 91 00:09:25,990 --> 00: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. 92 00:09:35,590 --> 00:09:41,370 So this has now been fixed and there's a CB so it's a CB 2025 54982. 93 00:09:41,450 --> 00:09:47,610 And it's fully resolved, doesn't require any interaction by Zscaler clients. 94 00:09:49,110 --> 00:09:51,370 So we're going to show a demo of this now. 95 00:09:52,470 --> 00: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. 96 00:10:01,930 --> 00: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. 97 00:10:14,720 --> 00: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. 98 00:10:23,100 --> 00: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. 99 00:10:38,310 --> 00:10:40,450 So let's take a look at that wish list again. 100 00:10:40,530 --> 00:10:42,930 We can tick off off bypass Zscaler. 101 00:10:44,830 --> 00:10:46,530 So moving on. 102 00:10:46,750 --> 00:10:52,490 Another way that Zscaler can be configured is with this authentication mode called device token authentication. 103 00:10:52,830 --> 00: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. 104 00:11:06,170 --> 00:11:08,550 This is documented in Zscaler's docs. 105 00:11:08,590 --> 00:11:13,250 So on Windows you simply specify the token and user as MSI arguments during install. 106 00:11:13,310 --> 00:11:19,190 But the problem here is that it only validates that the token is valid for that tenant. 107 00:11:19,270 --> 00:11:22,810 There's no association with a specific user. 108 00:11:23,210 --> 00: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. 109 00:11:33,670 --> 00: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. 110 00:11:43,590 --> 00:11:45,950 So where is the device token stored? 111 00:11:46,310 --> 00:11:50,650 So when installing with the MSI arguments, this actually ends up in the registry. 112 00:11:50,650 --> 00:11:56,130 So there's a device token that's stored in the registry in clear text and a user name parameter. 113 00:11:56,130 --> 00:12:00,110 For mobile devices, this is typically deployed by an MDM config. 114 00:12:01,710 --> 00:12:06,650 So we're going to show a demo now of device token extraction and replay. 115 00:12:11,680 --> 00: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. 116 00:12:21,020 --> 00:12:25,700 And then on our attacker VM, we're now going to import that token. 117 00:12:26,220 --> 00:12:28,380 So we're going to pause that scaler. 118 00:12:32,470 --> 00:12:35,690 We've then imported those tokens and user name. 119 00:12:39,530 --> 00:12:42,390 Then we'll just kill that scaler so it picks up that new token. 120 00:12:50,100 --> 00:12:53,400 So you see now, we're logged in as user 1 with just the token. 121 00:12:54,300 --> 00: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. 122 00:12:59,460 --> 00:13:01,640 So let's try a different user. 123 00:13:07,390 --> 00:13:11,030 So again, we suspend it and we'll just go in and change the user name in the registry. 124 00:13:13,210 --> 00:13:16,190 So we'll try admin 1, they've probably got better access. 125 00:13:25,700 --> 00:13:27,620 Registers as admin 1. 126 00:13:28,400 --> 00:13:31,200 You can see now we've got the network admin policy. 127 00:13:32,940 --> 00:13:34,460 And we can access the internet. 128 00:13:43,240 --> 00:13:45,340 So move on to Netscape. 129 00:13:45,380 --> 00:13:50,940 We came across this on a red team engagement and it seemed quite architecturally similar to Zscaler. 130 00:13:51,840 --> 00:13:56,560 There's a couple of specific bits of terminology to talk about here. 131 00:13:56,560 --> 00:13:58,700 So we've got an org key. 132 00:13:59,400 --> 00:14:02,080 And that's assigned to your tenant. 133 00:14:02,080 --> 00:14:03,060 It's immutable. 134 00:14:03,220 --> 00:14:05,300 So it's always going to be the same one. 135 00:14:05,300 --> 00:14:08,880 And we've got a user key which is assigned to the user. 136 00:14:09,280 --> 00:14:10,400 Also immutable. 137 00:14:10,400 --> 00:14:13,300 So always going to be the same for that user. 138 00:14:13,300 --> 00:14:14,360 Not revocable. 139 00:14:17,040 --> 00:14:19,920 Recon, again, very similar to Zscaler. 140 00:14:19,920 --> 00:14:21,340 The tenant name's sent. 141 00:14:21,760 --> 00:14:26,880 And if the tenant's configured to hand off to another identity provider, a SAML request is returned. 142 00:14:27,240 --> 00:14:29,280 And that contains the org key. 143 00:14:30,440 --> 00:14:34,000 So, you know, we've already kind of leaked that at that point. 144 00:14:35,200 --> 00: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. 145 00:14:42,900 --> 00:14:48,580 So if you go to like customer.goscope.com, there's the same kind of SAML request flow. 146 00:14:49,040 --> 00:14:50,600 And again, it leaks the org key. 147 00:14:50,680 --> 00:14:54,380 So I think we've established at this point that the org key isn't really a secret value. 148 00:14:57,940 --> 00:15:00,100 Recon, again, very similar to Zscaler. 149 00:15:00,100 --> 00:15:04,900 You can use this org key to pull parts of the tenant configuration or the pack file. 150 00:15:04,960 --> 00:15:06,940 And this is before you supply the password. 151 00:15:08,860 --> 00:15:13,480 There's actually more information that's leaked to Netscape than there is through Zscaler. 152 00:15:13,820 --> 00:15:15,880 And you can see some of the end points there. 153 00:15:16,800 --> 00:15:21,100 And you can kind of get the steering config and everything before you've even supplied credits. 154 00:15:22,320 --> 00: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. 155 00:15:31,040 --> 00:15:38,020 So here we start with our first request, exchanging our knowledge of the tenant name for a SAML request. 156 00:15:38,020 --> 00:15:41,060 And remember that SAML request contains our org key. 157 00:15:42,360 --> 00:15:46,980 As is convention, the next step sends the SAML request to the identity provider. 158 00:15:47,460 --> 00:15:49,980 And the SAML response is received. 159 00:15:50,020 --> 00:15:52,020 So it's all fairly normal so far. 160 00:15:53,060 --> 00:15:55,840 That SAML response is exchanged for JWT. 161 00:15:55,840 --> 00:15:57,740 Again, all fairly standard. 162 00:15:59,300 --> 00:16:03,020 Then the org key and the email address are exchanged for a user key. 163 00:16:03,900 --> 00:16:09,420 And as we said, that user key is just a long immutable string that's tied to the user. 164 00:16:10,300 --> 00:16:11,720 Uh, but hang on. 165 00:16:11,820 --> 00:16:14,660 This request has got no authentication at all. 166 00:16:15,180 --> 00:16:20,800 We can just see that we're supplying the org key that we have already leaked, uh, and an email address. 167 00:16:21,340 --> 00: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. 168 00:16:30,900 --> 00:16:32,260 So we're Mclover. 169 00:16:34,080 --> 00:16:39,640 The authentication flow then continues by exchanging the org key and that user key for a configuration . 170 00:16:40,920 --> 00:16:45,780 And finally ends with exchanging that same information for a certificate that's used to set up the tunnel. 171 00:16:45,780 --> 00: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. 172 00:16:56,910 --> 00: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. 173 00:17:08,390 --> 00:17:12,770 Uh, so firstly, big props to Sander DeWitt for being the original discoverer of this issue. 174 00:17:12,910 --> 00: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? 175 00:17:19,270 --> 00: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. 176 00:17:40,070 --> 00:17:42,570 So we'll just talk through the fix for that quickly. 177 00:17:42,570 --> 00: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. 178 00:17:51,030 --> 00:17:58,370 Uh, they released an advisory on August the 26th, 2024, and assigned CVE 2024 7401. 179 00:17:58,510 --> 00:18:04,970 Uh, so this describes a new enrollment method called secure enrollment, and this was first introduced in release 11610. 180 00:18:04,970 --> 00: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. 181 00:18:12,970 --> 00: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. 182 00:18:20,170 --> 00:18:26,330 Um, and even now in August 2025, we're still finding organizations who don't have secure enrollment enabled. 183 00:18:30,040 --> 00:18:31,600 So what about secure enrollment? 184 00:18:31,600 --> 00:18:32,580 How does that work? 185 00:18:32,580 --> 00:18:39,280 So this uses a secure enrollment token, and this has to be deployed via MDM to user's devices before registration. 186 00:18:39,640 --> 00: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. 187 00:18:47,880 --> 00: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. 188 00:19:00,440 --> 00:19:02,200 So how is this JWT made? 189 00:19:02,880 --> 00: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. 190 00:19:15,020 --> 00: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. 191 00:19:23,040 --> 00:19:25,040 So which one will the server use? 192 00:19:25,280 --> 00:19:27,700 The one in the JWT or the one in the URL? 193 00:19:28,860 --> 00:19:30,640 There's only one way to find out. 194 00:19:32,880 --> 00:19:35,080 That's right, get parameter wins. 195 00:19:36,260 --> 00: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. 196 00:19:46,020 --> 00: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. 197 00:19:54,760 --> 00: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. 198 00:20:01,500 --> 00:20:04,440 And we can specify the target user in the signed JWT. 199 00:20:04,900 --> 00:20:11,780 We even found leaked enrollment tokens online, so you don't necessarily need to be a Netscape customer to exploit this. 200 00:20:13,200 --> 00:20:14,740 So what about the fix? 201 00:20:15,160 --> 00:20:19,100 We reported this cross-tenant bug to Netscape on the 14th of March, 2025. 202 00:20:19,540 --> 00:20:24,080 They released a server-side fix in version 126 on May the 12th. 203 00:20:24,080 --> 00:20:27,800 This fix now checks that the org key in the URL matches the one in the JWT. 204 00:20:28,100 --> 00: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. 205 00:20:37,600 --> 00:20:41,700 So we're going to show a demo of the cross-tenant exploit now. 206 00:20:43,500 --> 00: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. 207 00:20:53,660 --> 00: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. 208 00:21:02,100 --> 00:21:08,180 Then on the attacker's VM, they can then just import this, the branding file and the cert. 209 00:21:17,510 --> 00:21:19,690 So now we just restart Netscape. 210 00:21:34,080 --> 00:21:36,020 And now we have MPA access. 211 00:21:43,610 --> 00:21:46,150 So that's Netscape auth bypass completed. 212 00:21:51,300 --> 00:21:55,380 So we've seen how secure enrollment can be bypassed, but how should it work? 213 00:21:55,380 --> 00: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. 214 00:22:04,300 --> 00:22:11,420 The token's then stored in the registry in this location, and it's encrypted using DPAPI. 215 00:22:11,800 --> 00: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. 216 00:22:21,960 --> 00: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. 217 00:22:33,880 --> 00: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. 218 00:22:51,580 --> 00:22:53,560 That's what an enrollment key looks like. 219 00:23:00,030 --> 00:23:01,750 So what does all this mean? 220 00:23:02,750 --> 00: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. 221 00:23:10,510 --> 00: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, 222 00:23:28,730 --> 00: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. 223 00:23:37,920 --> 00:23:40,080 So we covered, covered the auth bypasses. 224 00:23:40,080 --> 00:23:41,340 What if you've already got a shell? 225 00:23:41,820 --> 00: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. 226 00:23:56,520 --> 00:24:01,640 So both Zscaler and Netscape can store their configs as DPAPI encrypted blobs. 227 00:24:01,660 --> 00:24:04,060 Only Zscaler actually does this by default. 228 00:24:04,680 --> 00:24:08,640 But in theory, zero trust should stop you from stealing the config. 229 00:24:08,640 --> 00:24:10,460 The posture check should fail. 230 00:24:10,840 --> 00:24:13,580 The hardware ID should mismatch. 231 00:24:13,580 --> 00:24:17,260 But as we'll show, all these checks can be spoofed. 232 00:24:20,250 --> 00:24:23,130 So we'll have a quick primer on the Zscaler config. 233 00:24:23,490 --> 00: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. 234 00:24:34,990 --> 00: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. 235 00:24:41,370 --> 00: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. 236 00:24:50,410 --> 00: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. 237 00:25:00,410 --> 00: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. 238 00:25:06,930 --> 00:25:11,410 But if we go back to our table here, we can tick off config theft. 239 00:25:14,280 --> 00:25:21,640 So about these privesks, all of the ZTNA products we looked at shared a very similar architecture. 240 00:25:21,640 --> 00:25:26,680 They've got a low-privileged system tray and a high-privileged service or broker. 241 00:25:27,180 --> 00:25:30,460 And those two kind of communicate via IPC. 242 00:25:30,460 --> 00:25:36,540 That might be TCP socket and then pipe, RPC, but they all have one thing in common. 243 00:25:36,540 --> 00:25:41,300 They failed to properly validate the calling process. 244 00:25:41,380 --> 00: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. 245 00:25:49,440 --> 00:25:54,280 And there's also some kind of tamper proof stuff, but we bypass that, too. 246 00:25:54,460 --> 00:25:58,920 But just because you can call IPC methods, that doesn't automatically give you a system shell. 247 00:25:59,140 --> 00: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. 248 00:26:14,350 --> 00:26:16,090 So I'll show a couple of quick demos. 249 00:26:16,090 --> 00:26:17,810 Here's our Netscape LP. 250 00:26:18,370 --> 00:26:21,270 You can see the attack is using a custom IPC client. 251 00:26:21,270 --> 00:26:26,350 Injects a TCP proxy into a legitimate process to bypass the path signature check. 252 00:26:26,830 --> 00: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. 253 00:26:49,320 --> 00:26:52,420 So next up we've got Zscaler. 254 00:26:52,580 --> 00:26:55,860 This is version 4.7, which I think is the latest version. 255 00:26:55,880 --> 00:27:03,280 Again, using process injection to bypass the signer check and then trigger a vulnerable IPC method to load some malicious code. 256 00:27:03,760 --> 00:27:08,560 And then once we've got our system shell, we can dump the user's config, as we previously discussed. 257 00:27:11,480 --> 00: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. 258 00:27:25,060 --> 00:27:26,780 So back to the wish list. 259 00:27:26,920 --> 00:27:31,640 We can tick off, and this is starting to look quite scary now, but let's carry on. 260 00:27:34,710 --> 00:27:35,510 Cool. 261 00:27:35,550 --> 00:27:38,350 So you've stolen the config and even rolled, now what? 262 00:27:38,510 --> 00: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. 263 00:27:44,170 --> 00:27:47,250 Uh, and one of the ways that this is achieved is through processor checks. 264 00:27:47,350 --> 00: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. 265 00:27:53,650 --> 00: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. 266 00:28:02,010 --> 00: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. 267 00:28:15,170 --> 00: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. 268 00:28:29,090 --> 00: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. 269 00:28:37,710 --> 00: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. 270 00:28:47,710 --> 00:28:51,430 So another piece of information that we had to fake was the hardware ID. 271 00:28:51,590 --> 00: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. 272 00:29:03,010 --> 00: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. 273 00:29:13,910 --> 00: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. 274 00:29:21,470 --> 00:29:26,010 Uh, in the game cheat world, this would be called a spoofer and it's really no different for ZTNA. 275 00:29:26,990 --> 00: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. 276 00:29:36,770 --> 00: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. 277 00:29:43,710 --> 00: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. 278 00:29:50,130 --> 00: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. 279 00:30:01,230 --> 00:30:05,570 So for most checks, a simple Windows API hook was all that was needed. 280 00:30:05,590 --> 00:30:08,710 Uh, however, to spoof some other checks, things that are slightly harder. 281 00:30:09,110 --> 00:30:14,290 Um, so one of the things that normally makes up the, the, uh, hardware ID check is CPU ID. 282 00:30:14,290 --> 00:30:17,730 So they use this as a way to get a unique fingerprint of the hardware. 283 00:30:17,930 --> 00: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. 284 00:30:28,310 --> 00:30:30,730 Uh, so we can't hook this because it's an instruction. 285 00:30:30,730 --> 00:30:32,910 It's not a, um, a method. 286 00:30:32,910 --> 00:30:35,710 Uh, so instead what we do is we use a page guard hook. 287 00:30:35,850 --> 00:30:41,370 So the way this works is we search through the, the, the memory and looking for the CPU ID instructions. 288 00:30:41,550 --> 00:30:44,090 And then we find the, the page that they're in. 289 00:30:44,090 --> 00:30:45,550 We set the page as page guard. 290 00:30:45,570 --> 00:30:51,890 And then when that instruction gets executed, it triggers an exception, which we can catch with a custom exception handler. 291 00:30:51,890 --> 00:30:58,150 And then we can swap the, the register values out just after the CPU ID instruction gets executed. 292 00:30:58,990 --> 00:31:02,610 The downside to this is it's slightly slower than an inline hook. 293 00:31:02,930 --> 00: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. 294 00:31:10,290 --> 00: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. 295 00:31:17,370 --> 00: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. 296 00:31:24,170 --> 00: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. 297 00:31:32,550 --> 00: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. 298 00:31:38,570 --> 00:31:41,150 Um, yep. 299 00:31:41,150 --> 00: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. 300 00:31:47,830 --> 00:31:49,770 Otherwise, I guess we would have called it rescaler. 301 00:31:51,390 --> 00:31:53,410 Uh, we're going to do a demo of this now. 302 00:31:56,440 --> 00:31:58,360 So this picks up where we left off. 303 00:31:58,360 --> 00:32:03,720 So we, we privest, we stole the config and this is what the config looks like in plain text. 304 00:32:03,780 --> 00:32:06,420 So you can see it contains all the posture checks. 305 00:32:10,780 --> 00:32:13,900 So now we're going to import that config into our red scaler GUI. 306 00:32:20,550 --> 00:32:23,850 This is going to re-encrypt the config and put it in the right place. 307 00:32:23,950 --> 00: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. 308 00:32:30,350 --> 00:32:33,870 Then it restarts red scaler and 309 00:32:46,180 --> 00:32:47,080 we're logged in. 310 00:32:53,790 --> 00:32:55,170 But we can't get to the internet. 311 00:32:56,250 --> 00:32:56,710 Oh, it's okay. 312 00:32:56,710 --> 00:32:58,490 We forgot to spoof BitLocker. 313 00:32:58,930 --> 00:33:00,030 So we'll just spoof that. 314 00:33:01,130 --> 00:33:03,210 Just to show you the posture checks are working. 315 00:33:10,720 --> 00:33:12,160 You sunk my battleship. 316 00:33:13,800 --> 00:33:15,940 That's a full house for all the products we looked at. 317 00:33:15,940 --> 00:33:18,400 Bar the, uh, checkpoint side quest. 318 00:33:21,750 --> 00:33:24,870 So let's have a couple of minutes on this privacy thing. 319 00:33:24,890 --> 00: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. 320 00:33:34,670 --> 00:33:40,110 Um, I quite long lived here, like 2065, it's quite a long time for a set. 321 00:33:40,130 --> 00:33:47,270 Um, the way these are pushed down typically either with the policies or they're installed with the client. 322 00:33:47,890 --> 00:33:53,590 It's not really particularly difficult, uh, different to a traditional VPN appliance or, or a web proxy. 323 00:33:53,790 --> 00:33:58,150 Um, but the difference here is that the zero trust engine is, is very much an unknown. 324 00:33:58,150 --> 00:34:01,970 Your traffic enters there, it's decrypted and processed , that leaves again. 325 00:34:01,970 --> 00:34:06,310 You're trusting that it's routed correctly, um, that nothing else happens. 326 00:34:06,310 --> 00: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. 327 00:34:15,070 --> 00:34:16,950 Um, and you would never know. 328 00:34:21,190 --> 00:34:24,310 So we'll talk through a couple of, uh, defense and mitigations here. 329 00:34:24,310 --> 00: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. 330 00:34:31,910 --> 00:34:37,530 Um, also ensure that clients are always updated, even if there's no CV published. 331 00:34:37,530 --> 00: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. 332 00:34:41,650 --> 00:34:46,990 Enable cryptographically secure checks or server side validated checks where they're supported. 333 00:34:47,430 --> 00:34:52,450 Um, as far as we know, there's nothing for Netscape, but, um, ZTN do support this since version 4.4. 334 00:34:52,490 --> 00: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. 335 00:35:02,470 --> 00:35:10,110 And to minimize the attack surface for privilege escalation, disable client side access to features such as debugging and verbose logging. 336 00:35:10,290 --> 00: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. 337 00:35:20,450 --> 00: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. 338 00:35:36,190 --> 00: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, 339 00:35:49,710 --> 00: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. 340 00:35:58,070 --> 00: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. 341 00:36:11,590 --> 00:36:16,070 So, there's a couple of techniques that are good for detecting token and config theft. 342 00:36:16,070 --> 00:36:21,650 Uh, Google have this brilliant blog that, uh, explains how to configure auditing from deep, for deep happy events. 343 00:36:21,750 --> 00:36:25,430 Uh, this is actually aimed at detecting browser cookie theft, but also applies here. 344 00:36:25,490 --> 00: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. 345 00:36:38,330 --> 00: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. 346 00:36:45,470 --> 00:36:52,950 However, we can use the very, very memorably named Microsoft Windows Crypto Deep Happy Log if we turn on debug locking. 347 00:36:53,030 --> 00:36:55,330 And this is also detailed in the, in the Google blog. 348 00:36:55,330 --> 00: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. 349 00:37:04,310 --> 00: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. 350 00:37:16,250 --> 00: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. 351 00:37:29,010 --> 00: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. 352 00:37:38,600 --> 00:37:43,680 So in conclusion, well it turns out there are no magic said TNA beans. 353 00:37:44,100 --> 00:37:48,000 We've got the same old bug classes reimagined for a new technology stack. 354 00:37:48,000 --> 00:37:53,600 Rather than zero trust, we're actually putting a lot of trust into these vendors and to process our data securely. 355 00:37:53,620 --> 00:37:57,860 And we expect them to clearly and effectively communicate when they do fix vulnerabilities. 356 00:37:58,060 --> 00:38:03,580 Even if those bugs are server side, so clients can make informed decisions regarding risk profile. 357 00:38:04,020 --> 00:38:07,460 When the bugs exist only in one place though, at least patching them is efficient. 358 00:38:07,660 --> 00: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. 359 00:38:14,040 --> 00: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. 360 00:38:24,360 --> 00: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. 361 00:38:33,700 --> 00:38:35,060 So thanks for watching our talk. 362 00:38:35,060 --> 00:38:35,880 We hope you enjoyed it. 363 00:38:35,880 --> 00:38:37,200 We've got a link here to our blog. 364 00:38:37,200 --> 00:38:39,860 We'll be publishing write ups over the next few weeks and days. 365 00:38:40,060 --> 00:38:43,060 And you can come up and speak to us and we'll take some questions.