[00:03.250 --> 00:09.550] Hello. Hi everyone, uh, I'm Colby Morgan. I'm here with Jeffrey Hoffman. We're both [00:09.550 --> 00:14.710] offensive security engineers at Robinhood. And earlier this year we did some research into [00:14.710 --> 00:20.530] 1Password for Mac, uh, with the goal of identifying local attacks to dump vaults. And [00:20.530 --> 00:23.870] today we're gonna be sharing with you the outcome of our research and some of the, uh, [00:23.870 --> 00:31.190] vulnerabilities we discovered. So, why look at 1Password for Mac? Um, well if you use 1 [00:31.190 --> 00:35.310] Password, it's probably a place where you have some of your most sensitive credentials. And [00:35.310 --> 00:38.990] we know that APTs, red teamers, one of the first things they're gonna do when they land on [00:38.990 --> 00:45.010] an endpoint is look for credentials. Things like, uh, cloud credentials, browser cookies, [00:45.010 --> 00:49.070] um, passwords, API keys, things they might be able to use even if they were evicted from the [00:49.070 --> 00:54.950] laptop, uh, to retain, um, some sort of access or even more access. Um, if they were to be [00:54.950 --> 00:59.830] grepping around, uh, looking for files that have the word password in the file name, one [00:59.830 --> 01:06.110] thing they would find is this 1Password.SQLite file. And this is a SQLite database, uh, it's [01:06.110 --> 01:10.990] encrypted but it contains your, uh, 1Password vault contents. So that file itself wouldn't [01:10.990 --> 01:15.610] get you much. Um, so we're gonna talk about some attacks later that might be able to get you [01:15.610 --> 01:21.510] some of that content. Um, so to talk a little bit about the local security model of 1Password [01:21.510 --> 01:26.750] on Mac, um, when you log in with your password to 1Password, uh, it doesn't actually store [01:26.750 --> 01:31.370] your password. It's not even sending your password to the server. Instead what's going on [01:31.370 --> 01:37.270] is, um, your password along with a locally stored secret key are combined cryptographically [01:37.270 --> 01:41.950] to generate a master unlock key, uh, which is now referred to as an account unlock key. You'll [01:41.950 --> 01:46.210] hear us throughout this talk refer to it as a muck because that's how we saw it referenced in [01:46.210 --> 01:53.330] the code. Um, so we use SSO, meaning, uh, we don't have a password for 1Password. And how it [01:53.330 --> 02:00.230] works in this case is, uh, you authenticate and then you get a device key, um, and you receive a [02:00.230 --> 02:05.630] credential bundle from 1Password's API and the device key is stored in your Mac keychain and [02:05.630 --> 02:10.850] that is used to decrypt the credential bundle that contains that muck that I referenced. So [02:10.850 --> 02:16.030] the muck is basically the keys to the kingdom. It allows you to decrypt that SQLite database [02:16.030 --> 02:21.990] where your vault content is stored. Malware on your machine, uh, without a SIP bypass on Mac [02:21.990 --> 02:27.350] or a way to inject into processes arbitrarily, shouldn't be able to get your vault contents, uh, [02:27.350 --> 02:32.510] decrypted, um, without, in the SSO case, unrestricted keychain access and in the non-SSO [02:32.510 --> 02:38.050] case, um, access to your 1Password password, meaning something you know, um, and your locally [02:38.050 --> 02:43.750] stored secret key. Once you have the muck, uh, the full decryption process, um, isn't super [02:43.750 --> 02:48.850] straightforward, but it's fully explained in this blog post from David Shutes, aka DarthNull, [02:48.850 --> 02:53.470] uh, where he also had some code that we referenced for the, the decryption. And so this was [02:53.470 --> 02:59.650] really helpful in our research. Yeah, so it's generally understood that if somebody has full [02:59.650 --> 03:03.210] control over your machine, they're going to be able to access whatever data it protects in [03:03.210 --> 03:07.790] some way, shape or form. That being said, 1Password still cares about creating meaningful [03:07.790 --> 03:12.810] security boundaries wherever possible. And on Mac OS specifically, with things like SIP and [03:12.810 --> 03:17.890] code signing, uh, there is a possibility to create these significant boundaries. Uh, these are [03:17.890 --> 03:22.550] just some CVEs that are Mac specific, uh, we took a look at these CVEs when we first started [03:22.550 --> 03:25.930] our work and they indicated to us that we were thinking about the right things and looking in [03:25.930 --> 03:31.110] the right places. So when we started out looking at 1Password, we didn't really look at the [03:31.110 --> 03:36.690] app, we looked at the framework that it was built on. Uh, we looked at the framework that it [03:36.690 --> 03:41.910] was built on, uh, which is Electron. And so Electron is a Chromium and node based framework. [03:41.930 --> 03:46.490] It has a pretty well defined attack surface. The standard attack you'll see is somebody [03:46.490 --> 03:51.910] trying to get XSS and convert that into RCE or, or something else, but 1Password is an app, [03:51.910 --> 03:56.630] doesn't have a whole lot of opportunities to inject user controlled content. Uh, the XSS to [03:56.630 --> 04:02.510] RCE route is usually considered a, a remote attack, but because we're local attackers, we [04:02.510 --> 04:07.230] have the ability to consider local things. And one of the local security controls in Electron [04:07.230 --> 04:12.130] is something called fuses. Uh, these fuses control the behavior of 1Password in certain [04:12.130 --> 04:16.010] situations. I'm not going to read all of these off to you, but I'll tell you that 1Password [04:16.010 --> 04:20.850] correctly set all of these. Uh, but some of the interesting ones that, that you might take a [04:20.850 --> 04:26.370] look at are things like only load app from ASAR. Uh, if this had been enabled or rather [04:26.370 --> 04:31.390] disabled, uh, you might be able to proxy the app and inject JavaScript that way. And the [04:31.390 --> 04:36.590] enable node CLI inspect arguments fuse is also pretty interesting. It controls whether or [04:36.590 --> 04:41.870] not this Chromium flag called the remote debugging port works. If that had been enabled [04:41.870 --> 04:47.110] in 1Password, we would have, uh, started it with this flag, uh, connected a Chromium debugger [04:47.110 --> 04:51.070] to it, and from there you can see all the pages that the app has. You would have been able to [04:51.070 --> 04:58.150] inject, uh, JavaScript or change the currently running JavaScript in any of those pages. So [04:58.150 --> 05:03.110] once we saw that all the Electron, uh, attack surface was, was considered and wasn't going to [05:03.110 --> 05:07.710] be viable, we started looking at how the app functioned. And there were three main ways that [05:07.710 --> 05:14.990] we saw to get passwords out of the desktop app, and those were the SSH agent, the CLI, and the [05:14.990 --> 05:20.050] browser extension. Now the SSH agent and the CLI were disabled by default, but the browser [05:20.050 --> 05:25.570] extension is enabled by default. And so once we saw this, we installed the browser extension, [05:25.570 --> 05:29.470] and as long as the app is unlocked, if you click the browser extension, it's going to [05:29.470 --> 05:32.550] seamlessly sync all of your passwords and they're going to show up without any kind of [05:32.550 --> 05:36.410] re-authentication. And so as soon as we saw that behavior, we started trying to figure out how [05:36.410 --> 05:43.210] we could abuse that. And so we briefly considered the idea of maybe if we had some cool RCE and [05:43.210 --> 05:47.610] sandbox escape, we could control Chrome and try to do that remotely. Those are prohibitively [05:47.610 --> 05:53.130] expensive, and again, because we're local attackers, we have much less expensive options. And [05:53.130 --> 05:57.510] uh, that fuse that I mentioned before that controlled the remote debugging port, that's a [05:57.510 --> 06:02.030] Chromium flag. And so while Electron can turn that off, Chrome and other Chromium based [06:02.030 --> 06:07.270] browsers can't. It's just how they work. Uh, so as soon as we realized that, we found the [06:07.270 --> 06:12.990] JavaScript responsible for doing the syncing. It's that green URL that's on screen now. And [06:12.990 --> 06:18.110] we opened it up, looked at the console and we saw some log messages related to native core. [06:18.230 --> 06:23.090] This is a native messaging host and we're, we'll revisit that in a little bit. Uh, but [06:23.090 --> 06:28.990] essentially what we did is we read the JavaScript from that page, uh, beautified it, modified [06:28.990 --> 06:33.730] it to do that syncing behavior immediately. And with the remote debugging port, we just [06:33.730 --> 06:39.310] injected our new extension into that page and uh, everything was synced and we were able to [06:39.310 --> 06:45.730] extract passwords and decrypt them. And so this is our mental model of 1Password. We'll [06:45.730 --> 06:49.310] revisit this image a couple of times during the presentation. Uh, but what's important to [06:49.310 --> 06:54.210] note here is that we didn't really have a vulnerability in 1Password exactly. We were kind [06:54.210 --> 07:02.900] of just abusing how Chrome and extensions function. Yeah, so sticking along the path of [07:02.900 --> 07:07.600] attacking the browser extension, um, one question we were asking ourselves is would we be [07:07.600 --> 07:12.100] able to spoof the legitimate 1Password extension with our own extension or make changes to [07:12.100 --> 07:17.740] the 1Password extension and still, uh, still have it do that automatic syncing process Jeff [07:17.740 --> 07:23.420] uh, referred to before. Um, so if you're not familiar, uh, you can start Chrome from the [07:23.420 --> 07:28.780] command line, uh, along with this dash dash load extension flag to load extensions from disk, [07:28.780 --> 07:32.860] um, which are referred to as unpacked extensions. So what we were wondering is if we could [07:32.860 --> 07:37.820] load a modified version of 1Password from disk, uh, and have it do that syncing process. [07:37.820 --> 07:41.680] Obviously the modified code we would add would be JavaScript that makes it do what we want [07:41.680 --> 07:46.780] such as like taking those passwords after they sync and sending them to a remote server. Um, [07:46.780 --> 07:51.680] there were a couple of kind of challenges that, uh, made this not straightforward. So first, [07:51.680 --> 07:57.060] uh, the, when the extension talks to the Mac OS 1Password app, uh, the 1Password app is [07:57.060 --> 08:00.480] gonna verify that the connection is coming from the legitimate extensions extension [08:00.480 --> 08:06.440] identifier. Um, and then further, we have a managed Chrome policy that prevents, uh, [08:06.440 --> 08:10.320] loading unpacked extensions altogether, meaning we couldn't launch Chrome with that CLI [08:10.320 --> 08:15.760] flag. Um, and also all extensions are disallowed by default with only some being allow [08:15.760 --> 08:22.300] listed. So we started trying to tackle these challenges one by one. Uh, first, uh, spoofing [08:22.300 --> 08:26.900] the extension identifier. Thankfully this was extremely straightforward because Google tells [08:26.900 --> 08:32.200] us exactly how to do it on their browser extension, uh, security FAQ page where they [08:32.200 --> 08:38.520] basically explain that they don't consider this a bug. And, um, basically, um, every browser [08:38.520 --> 08:43.800] extension has a manifest.json file with a bunch of key entries. Um, one of those is called [08:43.800 --> 08:49.340] key. And, um, basically, if you take that key entry and put it in your own extensions [08:49.340 --> 08:54.480] manifest.json file, the extension IDs will be the same because the extension identifier is [08:54.480 --> 08:59.240] derived from that key entry. So we can just grab the legitimate extensions, um, key [08:59.240 --> 09:04.140] identifier, put that on our own extension, and then it'll match. So now we're left with the [09:04.140 --> 09:08.740] challenges from the managed Chrome policy. Uh, we basically started just trying to figure [09:08.740 --> 09:14.340] out how it worked and how it is enforced. And we came across this policy directory in Google [09:14.340 --> 09:19.500] Chrome's, um, application support directory. And we decided to just remove it and see what [09:19.500 --> 09:25.780] happens. Um, so if you delete that policy directory and you start Chrome, Chrome is actually [09:25.780 --> 09:29.700] smart enough to realize it should be there and it'll recreate it and it'll start reinforcing [09:29.700 --> 09:35.020] itself. However, um, as I mentioned before, we were prevented from starting Chrome with the [09:35.020 --> 09:39.960] dash dash load extension flag. But what you can do is delete the policy directory, start Chrome [09:39.960 --> 09:44.620] with the dash dash load extension flag, which will load your extension. Um, and it, that works [09:44.620 --> 09:49.040] because the policy directory doesn't exist at the time Chrome starts. But then Chrome will [09:49.040 --> 09:52.780] recreate that directory and start reinforcing itself. Um, but your extension is already [09:52.780 --> 09:57.000] loaded. Um, but Chrome will start going through and saying which extension should be [09:57.000 --> 10:02.140] allowed. If it's not allowed, remove it. Um, but thankfully it's only doing a shallow check [10:02.140 --> 10:06.820] of comparing the extension identifier to the allow list. And we're spoofing the legitimate [10:06.820 --> 10:12.020] extension's extension identifier so it doesn't remove our modified one password. Um, so [10:12.020 --> 10:18.940] that overcomes all of the challenges we had. And here is us just, uh, adding a POC.html [10:18.940 --> 10:23.680] file to the extension. We have the legitimate extension identifier, so our passwords do [10:23.680 --> 10:28.220] sync when one password is unlocked. Um, and it pulls in all our passwords as expected. And [10:28.220 --> 10:33.520] obviously we could have also added, um, edited the JavaScript or added JavaScript to, uh, make [10:33.520 --> 10:40.230] it grab those credentials and send them elsewhere. So earlier I brought up the term native [10:40.230 --> 10:45.290] messaging host. And what that is, is a binary that acts as a middleman between, uh, Chrome [10:45.290 --> 10:50.250] or other browsers that support this protocol and the desktop app. And, uh, how it normally [10:50.250 --> 10:55.430] works is Chrome will launch it. It will, uh, hold pipes to the standard in and standard out [10:55.430 --> 11:01.290] of that process and then send JSON messages back and forth. And if you're familiar with IPC [11:01.290 --> 11:07.390] on macOS specifically, that's a big deviation from the norm. Normally things use XPC and part [11:07.390 --> 11:11.250] of the reason they do that is because when you use XPC you have something called an audit [11:11.250 --> 11:15.930] token available to you. And you can use that audit token to securely look up the code signing [11:15.930 --> 11:20.870] information of the process sending the message. Because there's no audit token and there's no [11:20.870 --> 11:26.610] way to attach it to this method of IPC, uh, there's not really a great way for 1Password to [11:26.610 --> 11:31.850] go and verify the code signing information of whatever is sending that JSON. And they seem [11:31.850 --> 11:37.630] to know about this and, and still try to implement, uh, a parent PID check and essentially [11:37.630 --> 11:41.510] what they did was they would call get PPID, go look up the code signing information of the [11:41.510 --> 11:46.650] parent and check it a bunch of, uh, check it across the list of accepted and trusted browsers. [11:46.650 --> 11:53.430] But, that's a generally understood, you know, anti-pattern on XPC. The reason they tried it [11:53.430 --> 12:00.170] here is again, there's no audit token so they can't really do much better. Um, so going [12:00.170 --> 12:03.750] forward we're gonna talk about dumping and instrumenting and hooking and our tool of [12:03.750 --> 12:07.990] choice for that was Frida. We're gonna release some Frida scripts for people to look at other [12:07.990 --> 12:14.530] native messaging hosts. Um, what you can see on screen here is me hooking the read and [12:14.530 --> 12:19.670] write methods for the native messaging host and this is how we figured out what JSON to send [12:19.670 --> 12:25.450] when we actually wrote our exploit. And so like I said, it's a well understood problem that [12:25.450 --> 12:30.110] if you're doing XPC you should be using the audit token because if you try to look up the [12:30.110 --> 12:35.910] code signing information by PID what can happen is someone will send a message exec into the [12:35.910 --> 12:41.610] actual process that was supposed to send that message and by the time the PID is used the [12:41.610 --> 12:46.170] co-signing information will be that of the trusted process and not the malicious one that [12:46.170 --> 12:50.750] sent that initial message. And so we considered doing that but we actually don't have to [12:50.750 --> 12:56.250] there's a bunch better way. What you can do is create this process tree of 3 processes where [12:56.250 --> 13:02.010] the parent holds the standard in and standard out write pipes, the child execs into a [13:02.010 --> 13:06.750] trusted browser and the grandchild is actually the browser support process and when it goes [13:06.750 --> 13:12.990] to do that uh get PPID check we've satisfied that condition. So this is what the exploit [13:12.990 --> 13:17.590] looks like in process and once you've set up these pipes you can just send the JSON that we [13:17.590 --> 13:23.870] showed uh in the Frida slide and the browser support process will happily return back to you [13:23.870 --> 13:30.590] the muck. And so here's our mental model again. We've totally cut Chrome and the need for the [13:30.590 --> 13:35.590] actual extension out of the equation. This time we're attacking browser support. And we [13:35.590 --> 13:39.750] were satisfied with this. This is definitely a valid way to uh get the muck and and dump all [13:39.750 --> 13:43.910] your vaults. But we thought well what if we could also cut out browser support. So we [13:43.910 --> 13:50.590] started looking at the browser helper XPC server. And I've talked a lot about XPC already [13:50.590 --> 13:54.890] I'll spare you but they do everything correctly here that you would expect. They take the [13:54.890 --> 13:59.730] audit token, they get the code signing information in a secure way and they check the team [13:59.730 --> 14:05.210] identifier and bundle ID. Unfortunately, what they forgot to do was consider uh the [14:05.210 --> 14:09.650] hardened run time or the code signing flags of the client. And so if you're not familiar [14:09.650 --> 14:14.750] with hardened run time, essentially what it is, is a code signing flag that says to Mac OS [14:15.370 --> 14:22.410] to uh block all different manners of injecting uh code dynamically and that makes sense, [14:22.410 --> 14:27.410] right? If your security model is going to be built around code signing, you don't want ways [14:27.410 --> 14:33.070] to have untrusted code running in a process without invalidating that signature. And so [14:33.070 --> 14:37.650] that was introduced in September of 2018 and it would have been literally impossible for [14:37.650 --> 14:43.170] them to include that control and they were a company before 2018. And so we thought maybe [14:43.170 --> 14:47.690] if we could find some old clients, we could do this injection and satisfy their checks. [14:51.490 --> 14:56.830] Um, yeah, so like Jeff mentioned, what they were doing is checking the code signature [14:56.830 --> 15:01.290] information of the XPC client to see if it had a matching team identifier. They weren't [15:01.290 --> 15:05.390] checking for the hardened run time, so we knew what we needed to find. An old version of [15:05.390 --> 15:11.450] 1Password that matched these conditions. Uh, we couldn't find any official source from 1Password [15:11.450 --> 15:15.970] that was offering old versions of clients, so we tried to get a little bit creative and what [15:15.970 --> 15:20.710] we did is tried to enumerate subdomains of 1Password dot com by looking at certificate [15:20.710 --> 15:26.610] transparency logs. And one of the subdomains we found was C dot 1Password dot com. And it [15:26.610 --> 15:31.290] appeared to be some sort of web cache, we didn't really know what it was used for. Um, so we [15:31.290 --> 15:36.950] used Google dorks to see what files Google had indexed, um, on the URL. And we found a bunch [15:36.950 --> 15:41.390] of old versions of 1Password for all different operating systems. Um, one of the oldest ones [15:41.390 --> 15:46.830] we could find for Mac was version 6.5.2. So we pulled that down and it looked like a perfect [15:46.830 --> 15:50.830] candidate because it had the correct team identifier even though it was very old. Um, and [15:50.830 --> 15:56.110] it didn't have the hardened run time. So we figured we likely could inject into it. If you [15:56.110 --> 16:01.930] have a binary that is not signed with the hardened run time, um, the easiest way to inject [16:01.930 --> 16:07.350] into it is to write your own dynamic library, uh, that runs whatever code you want in its [16:07.350 --> 16:12.450] constructor. And then you load that dynamic library, uh, as you launch the program using the [16:12.450 --> 16:18.450] dial D insert libraries environment variable. This is very similar to LD preload on Linux, uh, [16:18.450 --> 16:22.750] for loading shared objects. Um, basically you can, it'll be the first dynamic library that the [16:22.750 --> 16:28.070] program loads and it'll run your code pretty much immediately. So we knew that the XPC server [16:28.070 --> 16:32.490] exposed one method called echo, which just echoed a string back to you. So as a proof of [16:32.490 --> 16:36.850] concept, we just wrote our dynamic library to send the string hello world to the server. Um, [16:36.850 --> 16:41.130] as you can see here, uh, once our code runs, it does send that string, we get a successful [16:41.130 --> 16:46.210] response. And this is great because it proves that, um, the XPC server validation was passed [16:46.210 --> 16:53.330] by our client. So obviously we didn't want to just echo strings back to ourselves. Um, so we [16:53.330 --> 16:57.010] looked at what other methods were available and the one that performed actually interesting [16:57.010 --> 17:01.690] functionality was called send to main, uh, where basically a message gets sent through browser [17:01.690 --> 17:08.170] helper and then to the main application, um, and gives you a response. Um, so what we tried [17:08.170 --> 17:13.190] doing was just sending the same messages that the browser extension was triggering. Um, but [17:13.190 --> 17:17.090] unfortunately we were just getting no responses whatsoever when we would do that. It was just [17:17.090 --> 17:22.630] totally hang. Um, so through some debugging, we found that when our connection was created, [17:22.630 --> 17:27.710] there was a connection object and it was a Boolean flag on it of is browser equals false. And [17:27.710 --> 17:32.770] we figured this might be problematic. Um, and it seemed to be getting set to false because our [17:32.770 --> 17:37.390] client's package ID, one password six in this case, uh, didn't match what was expected being [17:37.390 --> 17:42.210] the browser support process. Um, so we didn't give up there because we knew that the one [17:42.210 --> 17:47.710] password CLI tool, um, called OP, uh, we knew that that also communicated with the same XPC [17:47.710 --> 17:53.810] server using XPC messages. So we wanted to understand how that worked. To do so, we pulled [17:53.810 --> 17:59.210] down this XPC spy, uh, open source program for inspecting XPC traffic that a process is [17:59.210 --> 18:04.450] sending. And we started using, uh, the OP tool, uh, while looking at the XPC traffic. And we [18:04.450 --> 18:09.110] saw that it was sending, uh, similar XPC traffic, but, um, it was including this client info [18:09.110 --> 18:14.030] JSON blob. Um, and I'll explain kind of the significance of some of the values you see, uh, [18:14.030 --> 18:19.330] highlighted in red here in the coming slides. But, um, the point is we were able to send [18:19.330 --> 18:23.310] messages in the same way the one password CLI was and mimic the functionality of the one [18:23.310 --> 18:28.290] password CLI. And this was nice, um, but there's quite a few limitations that we weren't [18:28.290 --> 18:34.690] satisfied with. First, CLI integration is disabled by default. So, uh, if you're sending [18:34.690 --> 18:39.810] these messages and the CLI integration is disabled, nothing's gonna happen. Um, and, you [18:39.810 --> 18:44.710] know, most people probably haven't turned it on. So we were wondering, could we just find [18:44.710 --> 18:49.730] where the settings are stored and enable it ourselves? And we found the settings.json [18:49.730 --> 18:54.310] file. Um, we opened it, we saw a bunch of boolean flags for various settings, one of them [18:54.310 --> 18:59.830] being CLI integration. Um, but we also saw that every setting had a corresponding auth tag, [18:59.830 --> 19:03.830] which looked like a big random string that we assumed was protecting the integrity of the [19:03.830 --> 19:07.850] settings through some authenticated hash or something like that. So we assumed this wasn't [19:07.850 --> 19:12.890] gonna work, but we tried it anyway. Swi- switched CLI integration from false to true and it [19:12.890 --> 19:17.510] just worked. So it seemed like these auth tags were here, probably secure, but they just [19:17.510 --> 19:23.210] weren't being enforced yet. So we can enable CLI integration, great. Uh, but there's still, [19:23.210 --> 19:28.950] some serious limitations here. Um, the first being that when you use the 1Password CLI, you [19:28.950 --> 19:32.470] have to approve the session. So if you've used it before, you're probably familiar with this [19:32.470 --> 19:36.430] image on the left, where it's gonna say your terminal is requesting access to 1Password, do [19:36.430 --> 19:44.570] you want to authorize it or not? Um, and so what we saw was that your session basically gets [19:44.570 --> 19:49.790] created based on the XPC messages that get sent when you run the, uh, OP tool. And the [19:49.790 --> 19:54.650] session identifier is basically based on the PID of your shell, being the parent process that [19:54.650 --> 20:00.230] calls the tool, and the start time of that parent process. And so, it'd be pretty easy for [20:00.230 --> 20:05.790] malware on the machine to basically look for any shell that spawns the OPCLI, figure out the [20:05.790 --> 20:10.070] PID of that shell, and then grab the start time of the process, and then you'd know a valid [20:10.070 --> 20:14.190] session identifier and you could ride along with it, sending whatever messages you want with [20:14.190 --> 20:19.550] an approved session. However, um, this, you know, obviously isn't optimal either because it [20:19.550 --> 20:24.050] requires that there's a legitimate user sitting there really using the 1Password CLI having an [20:24.050 --> 20:32.030] active session that you could spoof alongside. So we kept digging here, um, we, uh, saw that [20:32.030 --> 20:36.610] in the client info JSON blob, there was a session type of CLI being sent when the CLI was [20:36.610 --> 20:42.150] being used, and, uh, we were wondering if any other session types might be supported. We [20:42.150 --> 20:47.210] disassembled the browser helper binary to take a look, and we saw that it seemed like the [20:47.210 --> 20:52.070] string of browser could also be a valid session type. And this was interesting to us because we [20:52.070 --> 20:58.130] hadn't seen this string being sent by, uh, the extension. But, uh, we tried it anyway to see [20:58.130 --> 21:01.870] what would happen. We removed all of those other session identifiers that I was mentioning [21:01.870 --> 21:07.250] before, and it just totally worked. If 1Password was unlocked, we were able to send a session [21:07.250 --> 21:12.570] type browser, request the muck, and we were able to grab it. So that kind of completed the [21:12.570 --> 21:19.150] chain of, um, injecting into an old client, sending XPC messages, and grabbing the muck. Um, [21:19.150 --> 21:24.750] so you may have noticed that every issue we've discussed so far requires that 1Password is [21:24.750 --> 21:29.730] unlocked. Um, this next and final issue we're gonna discuss does not require that 1Password [21:29.730 --> 21:35.710] is unlocked. And it focuses on how biometric authentication is implemented. If you, uh, use [21:35.710 --> 21:39.610] 1Password on a MacBook, you're probably familiar with this. You launch 1Password, you provide [21:39.610 --> 21:45.370] your fingerprint, it unlocks. Um, so a very common way that macOS apps are gonna implement [21:45.370 --> 21:51.330] fingerprint checks is by using this evaluate policy method. And it's pretty simple. You call [21:51.330 --> 21:55.270] it, prompts the user for their fingerprint, if they provide it and it's valid, it returns true, [21:55.270 --> 21:59.870] otherwise it returns false. So what we did to make sure this method was in use, we hooked it [21:59.870 --> 22:05.030] with Frida, uh, used the code on the right, uh, screenshot here, and just basically made it [22:05.030 --> 22:10.130] always return true no matter what. And so after doing that, we launched 1Password, prompted for [22:10.130 --> 22:14.550] our fingerprint, we could either hit cancel or provide someone else's fingerprint, and the [22:14.550 --> 22:21.570] vault unlocks. So, um, you might be thinking, well, you know, if you're a red teamer, you'll [22:21.570 --> 22:25.370] end up on someone's laptop, you can't just disable SIP and hook methods with Frida. And [22:25.370 --> 22:29.230] that's true. But this taught us something really interesting, which is that even with an [22:29.230 --> 22:33.470] invalid fingerprint, somehow, 1Password is grabbing the muck and it is decrypting the [22:33.470 --> 22:38.450] vaults and displaying your passwords. So we wanted to understand how that worked. Um, and [22:38.450 --> 22:43.610] also it's not obvious that this was gonna work just hooking, um, methods with Frida, cause it [22:43.610 --> 22:48.290] is possible to protect items at the keychain level with flags that indicate a fingerprint is [22:48.290 --> 22:51.650] required. And you wouldn't be able to just hook something with Frida and make that work [22:51.650 --> 22:55.790] because the keychain would protect you with your fingerprint. So that was not what was going [22:55.790 --> 23:01.330] on here. So how does it work? We figured the keychain was involved in some way, so we [23:01.330 --> 23:05.170] opened the keychain access application and started looking around. And we saw that when [23:05.170 --> 23:09.710] using biometric authentication, there were, uh, these items, or there was a item in the [23:09.710 --> 23:13.710] keychain called biometric unlock, and it would be named differently depending on if you were [23:13.710 --> 23:18.390] using SSO or not. And we saw that it could only be accessed by 1Password, so if it wasn't [23:18.390 --> 23:24.070] obvious from the name, we knew it was, uh, being used by 1Password for biometric unlock. Now, [23:24.070 --> 23:28.850] along with, um, the item in the keychain, there were these comments that were added, which [23:28.850 --> 23:34.090] tell us that it's, the item here is encrypted by the secure enclave. And this tracked because [23:34.090 --> 23:37.750] when we looked at what was stored in the item, it was just a bunch of random cipher text that [23:37.750 --> 23:42.870] we couldn't do anything with. So, we were wondering where the secure enclave key entry is [23:42.870 --> 23:46.950] because we couldn't see it in the keychain access application, we couldn't query it with the [23:46.950 --> 23:51.410] security CLI tool, which is the built-in, uh, Mac OS CLI tool for interacting with the [23:51.410 --> 23:54.710] keychain. Uh, so we wanted to understand where it was, what was going on and how it was [23:54.710 --> 24:01.710] being used. What we did for this was hooked the sec item copy matching, uh, method with [24:01.710 --> 24:06.050] Frida and logged the parameters passed to it and the return values from it. This method is [24:06.050 --> 24:11.130] used to query the keychain and so we wanted to trigger the fingerprint unlock and see what [24:11.130 --> 24:15.650] was, uh, being accessed from the keychain by 1Password when going through that flow. And [24:15.650 --> 24:21.670] amongst other things, one of the things we saw accessed was a sec key ref or a secret key [24:21.670 --> 24:27.470] reference and, um, that's what was returned and in the query was an A tag or an application [24:27.470 --> 24:33.170] tag, uh, with those hex bytes you see in the top red box and if you decode those, you get the [24:33.170 --> 24:38.530] string of com agile bits 1Password memory enclave key. So this seemed likely what we were, [24:38.530 --> 24:44.790] uh, looking for based on the name, but we wanted to be sure. So, uh, we wanted to see if it [24:44.790 --> 24:49.690] was being used to decrypt anything or decrypt that biometric unlock entry. Um, now secure [24:49.690 --> 24:53.710] enclave keys, it's not the case that you just access them and then do what you wish with the [24:53.710 --> 24:58.210] bytes. Instead, you ask the secure enclave to encrypt something, decrypt something, or sign [24:58.210 --> 25:02.690] something. In this case, it, we thought it would be decrypting something, so we did the same [25:02.690 --> 25:06.630] thing with hooking sec key create decrypted data, which is how you would ask the secure [25:06.630 --> 25:12.070] enclave to decrypt something. And we logged the parameters and the return value and we do [25:12.070 --> 25:16.850] see that that's, during the biometric unlock, that sec key ref is being used, it's decrypting [25:16.850 --> 25:21.090] the cipher text that was stored in the biometric unlock entry, and in return we get 32 [25:21.090 --> 25:25.690] bytes. Uh, so we thought, 32 bytes, that's great, that sounds like an AES key, maybe that's [25:25.690 --> 25:31.410] the muck. But it turned out it was not the muck, and we didn't really know what to do, so we [25:31.410 --> 25:37.630] just took these 32 bytes and started trial and error trying to decrypt things. And, um, [25:37.630 --> 25:43.810] finally, we found an item in the encrypted SQLite database called enc unlock key, and we [25:43.810 --> 25:50.470] were able to successfully decrypt it with AES, and, uh, in return we got the muck. So, now we [25:50.470 --> 25:56.010] fully understood the chain here of the memory enclave key and the secure enclave being used to [25:56.010 --> 26:00.010] decrypt the biometric unlock entry in the keychain, from there you have a key that can be [26:00.010 --> 26:04.590] used to decrypt this entry in the SQLite database, then you have the muck, which can decrypt [26:04.590 --> 26:11.690] the rest. Um, so, now we fully understand this process, but obviously we can't just access the [26:11.690 --> 26:17.250] keychain, um, on behalf of 1Password, unless we have a way to inject our own code into 1Password [26:17.250 --> 26:21.510] and query the keychain, because those items can only be queried by 1Password. So, now we're [26:21.510 --> 26:29.580] gonna talk about how we accomplished getting that code injection. Yeah, so, we needed to, uh, [26:29.580 --> 26:35.340] have the 1Password bundle ID, and we needed to not invalidate the code signature. And, uh, [26:35.340 --> 26:42.060] there's a relatively old technique on Electron where you can inject, uh, essentially the main.js [26:42.060 --> 26:47.040] file isn't included in the signature check, and so you can just overwrite it. And to protect [26:47.040 --> 26:52.360] against that, they added this enable embedded ASAR integrity validation fuse, and this was [26:52.360 --> 26:57.280] enabled in the modern version of 1Password. Uh, but we implied the same thinking that we did [26:57.280 --> 27:01.040] to the hardened runtime and went through all of our scraped old versions, and we found one [27:01.040 --> 27:05.500] that was created either before or around the time when this flag was introduced, and it had [27:05.500 --> 27:10.240] it disabled. Even if we couldn't find that though, there was this additional GitHub security [27:10.240 --> 27:14.680] advisory that was a bypass to this fuse, and, uh, you know, if we couldn't find either of [27:14.680 --> 27:20.760] those, we probably would have gone and hunted for some similar bug ourselves. So, we can [27:20.760 --> 27:25.980] overwrite the main.js file, but that isn't good enough to do what we need to do. Uh, [27:25.980 --> 27:29.500] essentially, there are no functions in Node.js that we can call directly that will let us [27:29.500 --> 27:33.780] read the keychain and use the secure enclave, and so we need to call these native functions [27:33.780 --> 27:38.580] from native code. And because of the hardened runtime, which is applied to this version of [27:38.580 --> 27:43.000] 1Password, we can't actually do the typical thing where you'd write your own library and have [27:43.000 --> 27:49.360] the Node.js code hand off to it. And so, we took a step back and saw that in the entitlements, [27:49.360 --> 27:54.380] uh, there was this Apple security allow JIT entitlement, which essentially means that [27:54.380 --> 28:00.100] somewhere in the process it would be okay to have a read write execute page of memory. Once [28:00.100 --> 28:03.960] we saw that, we realized a browser exploit would probably work, and so we found an [28:03.960 --> 28:08.900] applicable CVE that was exploited in the wild. We did the standard browser exploit things and [28:08.900 --> 28:13.380] got our JavaScript heap and read write primitives and used that to run shellcode by [28:13.380 --> 28:17.900] corrupting a WASM object. I'll show you a video of that in a second, but I also wanted to [28:17.900 --> 28:21.700] call out that because we're not in a renderer process, we can kind of cheat a little bit with [28:21.700 --> 28:26.300] ASLR by just running VM map outside of the process and then directly writing all the [28:26.300 --> 28:42.440] addresses we need to a file and then reading that file into our exploit. Alright, so [28:42.440 --> 28:48.400] hopefully you see that, it's on the monitor. Yeah, so in this video we're just adding a [28:48.400 --> 28:52.940] demo password that we're going to extract. Uh, we're adding it right now, then we'll show [28:52.940 --> 28:57.460] you that SIP is enabled, and then what we're going to do is run a make file. And that make [28:57.460 --> 29:01.740] file is going to compile a C program that prints out some function addresses in the core [29:01.740 --> 29:06.140] foundation library. The reason this is important is because we need those functions, uh, but [29:06.140 --> 29:10.220] we didn't want to do the work of adjusting the ASLR ourselves, and these functions are in [29:10.220 --> 29:13.860] the shared cache, so we can just print them out and the addresses are the same between [29:13.860 --> 29:19.820] processes. That print is going to be used to generate our final ASLR adjusted, uh, shell [29:19.820 --> 29:25.300] code in JavaScript, and we're going to start the old version of 1Password. The reason we do [29:25.300 --> 29:30.760] that is because on the first run, a deep signature check is going to be performed, uh, but we [29:30.760 --> 29:36.480] can just start it, kill it, and then run it again with our modified main.js, and because this [29:36.480 --> 29:44.480] fuse is disabled, and only a shallow check runs, we can run our browser exploit. Yeah, and [29:44.480 --> 30:23.240] so there it is. We'll show you that the password matches. I think it's up. No, I'm not good. Oh [30:23.240 --> 30:34.900] man, this is the hardest part of the talk. There we are. Okay, so this is the di- oh man. [30:36.520 --> 30:40.520] So this is the diagram of what we essentially did, and I think it's important to call out here [30:40.520 --> 30:45.260] that although, obviously 1Password could have used that enforcement flag, uh, but for [30:45.260 --> 30:48.860] everything else in order to get that native code execution and actually exploit it, we [30:49.400 --> 30:52.940] essentially just waited. And you know, we scraped the old versions, but the [30:52.940 --> 30:56.980] vulnerabilities were in Electron and- and Chromium, and it can be really hard to secure that [30:56.980 --> 31:03.040] when you're releasing new versions, uh, every day. And so here's a vulnerability summary of [31:03.040 --> 31:08.240] what we reported. Uh, this is a little bit, uh, there are a few more vulnerabilities here [31:08.240 --> 31:12.440] than what's going to be on the next slide. The reason that is, is because the initial [31:12.440 --> 31:17.000] XPC entry vulnerability is really what needed to be fixed, not the other stuff that we [31:17.000 --> 31:22.180] talked about with the session writing. And we also reported the, uh, Chrome managed policy [31:22.180 --> 31:28.640] bypasses to them, or to Google rather. And so here's an exploitability summary. Uh, I think [31:28.640 --> 31:32.940] it's important to call out that SIP doesn't prevent this and root is not required. Low [31:32.940 --> 31:40.340] privilege malware can perform these attacks. Uh, but, uh, the main issues that 1Password was [31:40.340 --> 31:45.400] able to fix are- are highlighted in green. And so the XPC bypass was fixed, the biometric [31:45.400 --> 31:50.600] enforcement flag was fixed, and most importantly, the settings modification is now being [31:50.600 --> 31:55.520] enforced. And you might say, well why is that important? It's important because the first [31:55.520 --> 32:00.320] two currently exploitable issues are not exploitable if you just disable that setting. And [32:00.320 --> 32:05.040] so while it might degrade the user experience a little bit, you are fully protected with the [32:05.040 --> 32:10.480] newest version of 8.10.38 which was released in August. Now the- the browser extension [32:10.480 --> 32:15.280] injection and impersonation, like I mentioned earlier, that's not really a- a bug per se, [32:15.280 --> 32:20.600] it's kind of just how browsers work. And the browser support get PBID bypass is a little bit [32:20.600 --> 32:26.120] interesting because there's not really a clear line of ownership to the issue. Uh, so 1Password [32:26.120 --> 32:30.640] can't really securely look up the code signing information of their parent process. It is [32:30.640 --> 32:37.520] true that all browsers could maybe switch to XPC to provide that audit token. Uh, it's one [32:37.520 --> 32:43.140] available method to perform inter-process communication with uh, or on Mac OS rather. But [32:43.140 --> 32:47.140] it's also true that Apple might be able to provide some way to look up your parent [32:47.140 --> 32:53.700] processes code signing information securely. It's just not super clear who uh, who needs to [32:53.700 --> 32:59.540] go and fix this. And so, because you can't really fix those things, we're going to talk [32:59.540 --> 33:04.000] about how to detect them. So, I pulled all of these bundle IDs from the browser support [33:04.000 --> 33:08.580] process. These are all the chromium based browsers that it will accept as a parent [33:08.580 --> 33:13.200] process. And these are the non-chromium based browsers that it will accept as a parent [33:13.200 --> 33:18.840] process. And so, for the uh, extension injection and impersonation, those are relatively [33:18.840 --> 33:22.980] straightforward to fix. Essentially, what you have to do is go enumerate the dangerous [33:22.980 --> 33:27.380] flags, which I've done for you. They're highlighted in orange. And you just need to alert [33:27.380 --> 33:31.520] anytime those flags are used. Uh, we also, out of an abundance of caution, are just [33:31.520 --> 33:34.780] blocking the developer builds of certain browsers because they have a slightly different [33:34.780 --> 33:40.980] front model. And for the browser support issue, again, if you just disable that setting, [33:41.580 --> 33:45.640] you will be fine. Uh, I can tell you personally I'm not going to disable the setting. I like [33:45.640 --> 33:49.820] using the browser extension. And I think having malware on your computer is already a [33:49.820 --> 33:55.300] pretty significant bar. Now, uh, if you don't want to disable the extension like me, here's [33:55.380 --> 34:01.000] a, you can alert on it. Uh, basically during normal use, when you click a browser icon, [34:01.000 --> 34:05.760] what's going to happen is LaunchD actually spawns that process. And so, if you just set an [34:05.760 --> 34:12.720] alert for anytime a browser, uh, is spawned and the parent is not LaunchD, it's likely [34:12.720 --> 34:17.520] malicious or it's going to be some kind of headless browsing. And you can usually limit [34:17.520 --> 34:23.800] that to the people that need to do that at your company. Probably QA teams. And a malicious [34:23.800 --> 34:28.700] actor might look at that alert and, and try to get around it, right? By getting LaunchD to [34:28.700 --> 34:33.440] spawn their parent, uh, to spawn their exploit process and then execing indirectly. And so [34:33.440 --> 34:37.880] what you can look for there is the exec. Uh, the, the point of looking for the exec is that [34:37.880 --> 34:42.220] there are a couple different ways to obscure or, or, you know, move around those read write [34:42.220 --> 34:48.340] pipes. You don't have to use the process tree that we showed you here. But at every, um, for [34:48.340 --> 34:53.540] every actual exploit, at some point they're going to have to exec into a trusted browser. And [34:53.540 --> 34:58.420] so, that's what you will, uh, would alert on and it looks like PID reuse in LaunchD child [34:58.420 --> 35:04.200] processes. So here's our full disclosure timeline. We reported all the stuff that we found [35:04.200 --> 35:10.000] initially in January of 2024. And then we followed up on March 8th and reported, reported [35:10.000 --> 35:16.120] that the biometrics flag was missing. And we actually weren't convinced at the time that it [35:16.120 --> 35:20.340] was going to be exploitable in practice. And so we put together a proof of concept and gave [35:20.340 --> 35:24.480] it to them on March 22nd and that confirmed for both us and 1Password that this was going to [35:24.480 --> 35:31.660] work. Here's a remediation timeline. Again, the, the browser support fix is unclear but you [35:31.660 --> 35:37.660] can toggle that setting. The XPC bypass was fixed in April. Uh, the settings file [35:37.660 --> 35:41.780] modifications, this says it was scheduled to be fixed in August. That version is out now. We [35:41.780 --> 35:48.140] just submitted the slides before. And the biometrics flag issue was fixed in 8.10.36 and [35:48.140 --> 35:53.820] they followed up in 8.10.38 with just a reliability change. It was actually fixed in 3.6 [35:53.820 --> 36:02.680] but I would just recommend upgrading to the, to the latest version. So here is where you can [36:02.680 --> 36:09.760] find the code we've released at, uh, morganc3 slash 1Password exploits. Um, as of now, we [36:09.760 --> 36:14.680] released, uh, the Frida scripts we used while doing some of this research. Um, none of it is [36:14.680 --> 36:19.480] really specific to 1Password at all. Um, it could definitely be extended and useful for [36:19.480 --> 36:24.620] researching other applications. In terms of exploits, the only thing we've released is a [36:24.620 --> 36:29.740] proof of concept for the XPC validation bypass issue. It's not going to decrypt your vaults [36:29.740 --> 36:35.240] but rather just demonstrate the issue. Uh, in the future, we, uh, will add more code here [36:35.240 --> 36:39.920] once ample time has been given for people to be upgrading their 1Password to safe versions and [36:39.920 --> 36:46.780] for the other issues to be fixed. Um, and yeah, we may have some time for a few questions if [36:46.780 --> 37:12.830] people have them. Sorry, what was that? Yeah, we, we took a look at them. Um, I would just [37:12.830 --> 37:33.060] say any, okay, sounds good. Yeah. Any other 1Password managers? Yes. It was just us over the [37:33.060 --> 37:37.860] course of about a month. And the, the guy to your left helped us a bit with the last [37:37.860 --> 37:52.580] coolest vulnerability right there. I'm, I'm so sorry, can you say that again? Oh, just we [37:52.580 --> 37:57.100] wanted to know how safe our passwords were. You know, really the detections, I would say are [37:57.100 --> 38:01.900] the most important part for us. And I would say practically we expected this as, we [38:01.900 --> 38:06.120] expected this as likely possible with, you know, most major password managers or similar [38:06.120 --> 38:10.260] attacks. We wanted to do it on 1Password because we use 1Password and we wanted to use it [38:10.260 --> 38:26.640] on red team operations. Um, and then of course get the issues fixed as well. So, uh, we, we [38:26.640 --> 38:31.140] took a brief look at other password managers, but this was a significant amount of effort for [38:31.140 --> 38:36.500] us. And so you can imagine that we wouldn't want to do the work, uh, especially on, you know, [38:36.500 --> 38:48.370] work time if, uh, if it wasn't going to pay out on a red team. All right. Thank you.