WEBVTT

00:03.250 --> 00:04.210
Hello.

00:05.390 --> 00:07.610
Hi everyone, uh, I'm Colby Morgan.

00:07.610 --> 00:09.130
I'm here with Jeffrey Hoffman.

00:09.130 --> 00:11.910
We're both offensive security engineers at Robinhood.

00:11.950 --> 00:19.910
And earlier this year we did some research into 1Password for Mac, uh, with the goal of identifying local attacks to dump vaults.

00:20.050 --> 00:25.410
And today we're gonna be sharing with you the outcome of our research and some of the, uh, vulnerabilities we discovered.

00:26.870 --> 00:29.450
So, why look at 1Password for Mac?

00:29.450 --> 00:34.690
Um, well if you use 1 Password, it's probably a place where you have some of your most sensitive credentials.

00:34.910 --> 00:41.290
And we know that APTs, red teamers, one of the first things they're gonna do when they land on an endpoint is look for credentials.

00:41.650 --> 00:53.190
Things like, uh, cloud credentials, browser cookies, um, passwords, API keys, things they might be able to use even if they were evicted from the laptop, uh, to retain, um, some sort of access or even more access.

00:53.670 --> 01:03.170
Um, if they were to be grepping around, uh, looking for files that have the word password in the file name, one thing they would find is this 1Password.SQLite file.

01:03.350 --> 01:09.450
And this is a SQLite database, uh, it's encrypted but it contains your, uh, 1Password vault contents.

01:09.450 --> 01:11.830
So that file itself wouldn't get you much.

01:11.890 --> 01:16.750
Um, so we're gonna talk about some attacks later that might be able to get you some of that content.

01:18.230 --> 01:27.530
Um, so to talk a little bit about the local security model of 1Password on Mac, um, when you log in with your password to 1Password, uh, it doesn't actually store your password.

01:27.530 --> 01:30.150
It's not even sending your password to the server.

01:30.230 --> 01:41.790
Instead what's going on is, um, your password along with a locally stored secret key are combined cryptographically to generate a master unlock key, uh, which is now referred to as an account unlock key.

01:41.790 --> 01:47.050
You'll hear us throughout this talk refer to it as a muck because that's how we saw it referenced in the code.

01:47.550 --> 01:52.810
Um, so we use SSO, meaning, uh, we don't have a password for 1Password.

01:52.810 --> 02:09.830
And how it works in this case is, uh, you authenticate and then you get a device key, um, and you receive a credential bundle from 1Password's API and the device key is stored in your Mac keychain and that is used to decrypt the credential bundle that contains that muck that I referenced.

02:09.910 --> 02:13.290
So the muck is basically the keys to the kingdom.

02:13.290 --> 02:17.750
It allows you to decrypt that SQLite database where your vault content is stored.

02:18.430 --> 02:33.630
Malware on your machine, uh, without a SIP bypass on Mac or a way to inject into processes arbitrarily, shouldn't be able to get your vault contents, uh, decrypted, um, without, in the SSO case, unrestricted keychain access and in the non-SSO case, um,

02:33.630 --> 02:39.390
access to your 1Password password, meaning something you know, um, and your locally stored secret key.

02:39.650 --> 02:52.890
Once you have the muck, uh, the full decryption process, um, isn't super straightforward, but it's fully explained in this blog post from David Shutes, aka DarthNull, uh, where he also had some code that we referenced for the, the decryption.

02:52.890 --> 02:54.870
And so this was really helpful in our research.

02:56.570 --> 03:04.450
Yeah, so it's generally understood that if somebody has full control over your machine, they're going to be able to access whatever data it protects in some way, shape or form.

03:04.510 --> 03:09.510
That being said, 1Password still cares about creating meaningful security boundaries wherever possible.

03:09.990 --> 03:17.190
And on Mac OS specifically, with things like SIP and code signing, uh, there is a possibility to create these significant boundaries.

03:17.430 --> 03:26.950
Uh, these are just some CVEs that are Mac specific, uh, we took a look at these CVEs when we first started our work and they indicated to us that we were thinking about the right things and looking in the right places.

03:27.850 --> 03:33.710
So when we started out looking at 1Password, we didn't really look at the app, we looked at the framework that it was built on.

03:35.170 --> 03:38.790
Uh, we looked at the framework that it was built on, uh, which is Electron.

03:38.790 --> 03:41.910
And so Electron is a Chromium and node based framework.

03:41.930 --> 03:44.150
It has a pretty well defined attack surface.

03:44.150 --> 03:55.130
The standard attack you'll see is somebody trying to get XSS and convert that into RCE or, or something else, but 1Password is an app, doesn't have a whole lot of opportunities to inject user controlled content.

03:55.230 --> 04:04.790
Uh, the XSS to RCE route is usually considered a, a remote attack, but because we're local attackers, we have the ability to consider local things.

04:04.850 --> 04:08.670
And one of the local security controls in Electron is something called fuses.

04:09.030 --> 04:12.890
Uh, these fuses control the behavior of 1Password in certain situations.

04:12.890 --> 04:17.870
I'm not going to read all of these off to you, but I'll tell you that 1Password correctly set all of these.

04:18.030 --> 04:23.470
Uh, but some of the interesting ones that, that you might take a look at are things like only load app from ASAR.

04:23.470 --> 04:30.330
Uh, if this had been enabled or rather disabled , uh, you might be able to proxy the app and inject JavaScript that way.

04:30.450 --> 04:35.490
And the enable node CLI inspect arguments fuse is also pretty interesting.

04:35.490 --> 04:39.910
It controls whether or not this Chromium flag called the remote debugging port works.

04:40.210 --> 04:50.330
If that had been enabled in 1Password, we would have, uh, started it with this flag, uh, connected a Chromium debugger to it, and from there you can see all the pages that the app has.

04:50.350 --> 04:56.270
You would have been able to inject, uh, JavaScript or change the currently running JavaScript in any of those pages.

04:57.750 --> 05:05.570
So once we saw that all the Electron, uh, attack surface was, was considered and wasn't going to be viable, we started looking at how the app functioned.

05:05.610 --> 05:16.050
And there were three main ways that we saw to get passwords out of the desktop app, and those were the SSH agent, the CLI, and the browser extension.

05:16.270 --> 05:21.870
Now the SSH agent and the CLI were disabled by default, but the browser extension is enabled by default.

05:21.930 --> 05:33.670
And so once we saw this, we installed the browser extension, and as long as the app is unlocked, if you click the browser extension, it's going to seamlessly sync all of your passwords and they're going to show up without any kind of re-authentication.

05:33.750 --> 05:37.710
And so as soon as we saw that behavior, we started trying to figure out how we could abuse that.

05:38.570 --> 05:46.510
And so we briefly considered the idea of maybe if we had some cool RCE and sandbox escape, we could control Chrome and try to do that remotely.

05:46.510 --> 05:52.770
Those are prohibitively expensive, and again, because we're local attackers, we have much less expensive options.

05:52.770 --> 05:58.130
And uh, that fuse that I mentioned before that controlled the remote debugging port, that's a Chromium flag.

05:58.130 --> 06:02.950
And so while Electron can turn that off, Chrome and other Chromium based browsers can't.

06:02.950 --> 06:04.550
It's just how they work.

06:05.110 --> 06:09.910
Uh, so as soon as we realized that, we found the JavaScript responsible for doing the syncing.

06:09.910 --> 06:12.510
It's that green URL that's on screen now.

06:12.550 --> 06:18.110
And we opened it up, looked at the console and we saw some log messages related to native core.

06:18.230 --> 06:22.070
This is a native messaging host and we're, we'll revisit that in a little bit.

06:22.490 --> 06:31.410
Uh, but essentially what we did is we read the JavaScript from that page, uh, beautified it, modified it to do that syncing behavior immediately.

06:31.490 --> 06:41.850
And with the remote debugging port, we just injected our new extension into that page and uh, everything was synced and we were able to extract passwords and decrypt them.

06:42.790 --> 06:45.590
And so this is our mental model of 1Password.

06:45.590 --> 06:48.450
We'll revisit this image a couple of times during the presentation.

06:48.470 --> 06:53.810
Uh, but what's important to note here is that we didn't really have a vulnerability in 1Password exactly.

06:53.810 --> 06:56.990
We were kind of just abusing how Chrome and extensions function.

07:00.580 --> 07:14.340
Yeah, so sticking along the path of attacking the browser extension, um, one question we were asking ourselves is would we be able to spoof the legitimate 1Password extension with our own extension or make changes to the 1Password extension and still,

07:14.340 --> 07:19.280
uh, still have it do that automatic syncing process Jeff uh, referred to before.

07:19.600 --> 07:30.860
Um, so if you're not familiar, uh, you can start Chrome from the command line, uh, along with this dash dash load extension flag to load extensions from disk, um, which are referred to as unpacked extensions.

07:31.080 --> 07:37.820
So what we were wondering is if we could load a modified version of 1Password from disk, uh, and have it do that syncing process.

07:37.820 --> 07:45.580
Obviously the modified code we would add would be JavaScript that makes it do what we want such as like taking those passwords after they sync and sending them to a remote server.

07:46.060 --> 07:50.160
Um, there were a couple of kind of challenges that, uh, made this not straightforward.

07:50.160 --> 08:01.480
So first, uh, the, when the extension talks to the Mac OS 1Password app, uh, the 1Password app is gonna verify that the connection is coming from the legitimate extensions extension identifier.

08:01.660 --> 08:11.100
Um, and then further, we have a managed Chrome policy that prevents, uh, loading unpacked extensions altogether, meaning we couldn't launch Chrome with that CLI flag.

08:11.100 --> 08:16.640
Um, and also all extensions are disallowed by default with only some being allow listed.

08:16.940 --> 08:19.820
So we started trying to tackle these challenges one by one.

08:20.020 --> 08:23.960
Uh, first, uh, spoofing the extension identifier.

08:24.000 --> 08:35.180
Thankfully this was extremely straightforward because Google tells us exactly how to do it on their browser extension, uh, security FAQ page where they basically explain that they don't consider this a bug.

08:35.620 --> 08:42.140
And, um, basically, um, every browser extension has a manifest.json file with a bunch of key entries.

08:42.160 --> 08:44.560
Um, one of those is called key.

08:44.560 --> 08:56.220
And, um, basically, if you take that key entry and put it in your own extensions manifest.json file, the extension IDs will be the same because the extension identifier is derived from that key entry.

08:56.220 --> 09:02.140
So we can just grab the legitimate extensions, um, key identifier, put that on our own extension, and then it'll match.

09:02.900 --> 09:06.200
So now we're left with the challenges from the managed Chrome policy.

09:06.320 --> 09:11.400
Uh, we basically started just trying to figure out how it worked and how it is enforced.

09:11.400 --> 09:16.740
And we came across this policy directory in Google Chrome's, um, application support directory.

09:16.760 --> 09:20.420
And we decided to just remove it and see what happens.

09:20.420 --> 09:30.720
Um, so if you delete that policy directory and you start Chrome, Chrome is actually smart enough to realize it should be there and it'll recreate it and it'll start reinforcing itself.

09:30.960 --> 09:36.760
However, um, as I mentioned before, we were prevented from starting Chrome with the dash dash load extension flag.

09:36.780 --> 09:42.880
But what you can do is delete the policy directory, start Chrome with the dash dash load extension flag, which will load your extension.

09:43.360 --> 09:47.860
Um, and it, that works because the policy directory doesn't exist at the time Chrome starts.

09:47.860 --> 09:51.740
But then Chrome will recreate that directory and start reinforcing itself.

09:51.740 --> 09:53.580
Um, but your extension is already loaded.

09:53.820 --> 09:57.420
Um, but Chrome will start going through and saying which extension should be allowed.

09:57.420 --> 09:59.140
If it's not allowed, remove it.

09:59.160 --> 10:05.700
Um, but thankfully it's only doing a shallow check of comparing the extension identifier to the allow list.

10:05.700 --> 10:11.420
And we're spoofing the legitimate extension's extension identifier so it doesn't remove our modified one password.

10:11.620 --> 10:14.300
Um, so that overcomes all of the challenges we had.

10:14.760 --> 10:20.380
And here is us just, uh, adding a POC.html file to the extension.

10:20.380 --> 10:25.780
We have the legitimate extension identifier, so our passwords do sync when one password is unlocked.

10:25.780 --> 10:28.000
Um, and it pulls in all our passwords as expected.

10:28.000 --> 10:35.320
And obviously we could have also added, um, edited the JavaScript or added JavaScript to, uh, make it grab those credentials and send them elsewhere.

10:38.050 --> 10:41.150
So earlier I brought up the term native messaging host.

10:41.150 --> 10:48.510
And what that is, is a binary that acts as a middleman between, uh, Chrome or other browsers that support this protocol and the desktop app.

10:48.710 --> 10:52.050
And, uh, how it normally works is Chrome will launch it.

10:52.050 --> 10:59.010
It will, uh, hold pipes to the standard in and standard out of that process and then send JSON messages back and forth.

10:59.090 --> 11:05.210
And if you're familiar with IPC on macOS specifically, that's a big deviation from the norm.

11:05.210 --> 11:12.530
Normally things use XPC and part of the reason they do that is because when you use XPC you have something called an audit token available to you.

11:12.670 --> 11:18.470
And you can use that audit token to securely look up the code signing information of the process sending the message.

11:18.610 --> 11:31.070
Because there's no audit token and there's no way to attach it to this method of IPC, uh, there's not really a great way for 1Password to go and verify the code signing information of whatever is sending that JSON.

11:31.130 --> 11:46.650
And they seem to know about this and, and still try to implement, uh, a parent PID check and essentially what they did was they would call get PPID, go look up the code signing information of the parent and check it a bunch of, uh, check it across the list of accepted and trusted browsers.

11:46.650 --> 11:52.150
But, that's a generally understood, you know, anti-pattern on XPC.

11:52.270 --> 11:56.610
The reason they tried it here is again, there's no audit token so they can't really do much better.

11:58.050 --> 12:05.030
Um, so going forward we're gonna talk about dumping and instrumenting and hooking and our tool of choice for that was Frida.

12:05.030 --> 12:09.610
We're gonna release some Frida scripts for people to look at other native messaging hosts.

12:09.770 --> 12:21.350
Um, what you can see on screen here is me hooking the read and write methods for the native messaging host and this is how we figured out what JSON to send when we actually wrote our exploit.

12:22.230 --> 12:47.670
And so like I said, it's a well understood problem that if you're doing XPC you should be using the audit token because if you try to look up the code signing information by PID what can happen is someone will send a message exec into the actual process that was supposed to send that message and by the time the PID is used the co-signing information will be that of the trusted process and not the malicious one that sent that initial message.

12:47.670 --> 12:52.630
And so we considered doing that but we actually don't have to there's a bunch better way.

12:52.630 --> 13:10.810
What you can do is create this process tree of 3 processes where the parent holds the standard in and standard out write pipes, the child execs into a trusted browser and the grandchild is actually the browser support process and when it goes to do that uh get PPID check we've satisfied that condition.

13:11.430 --> 13:24.710
So this is what the exploit looks like in process and once you've set up these pipes you can just send the JSON that we showed uh in the Frida slide and the browser support process will happily return back to you the muck.

13:26.250 --> 13:28.510
And so here's our mental model again.

13:28.670 --> 13:32.370
We've totally cut Chrome and the need for the actual extension out of the equation.

13:32.370 --> 13:34.690
This time we're attacking browser support.

13:34.850 --> 13:36.610
And we were satisfied with this.

13:36.610 --> 13:40.570
This is definitely a valid way to uh get the muck and and dump all your vaults.

13:40.570 --> 13:43.630
But we thought well what if we could also cut out browser support.

13:43.630 --> 13:46.470
So we started looking at the browser helper XPC server.

13:48.090 --> 13:54.370
And I've talked a lot about XPC already I'll spare you but they do everything correctly here that you would expect.

13:54.370 --> 14:01.430
They take the audit token, they get the code signing information in a secure way and they check the team identifier and bundle ID.

14:01.570 --> 14:08.430
Unfortunately, what they forgot to do was consider uh the hardened run time or the code signing flags of the client.

14:08.430 --> 14:22.710
And so if you're not familiar with hardened run time, essentially what it is, is a code signing flag that says to Mac OS to uh block all different manners of injecting uh code dynamically and that makes sense, right?

14:22.710 --> 14:32.570
If your security model is going to be built around code signing, you don't want ways to have untrusted code running in a process without invalidating that signature.

14:32.570 --> 14:41.410
And so that was introduced in September of 2018 and it would have been literally impossible for them to include that control and they were a company before 2018.

14:41.410 --> 14:47.690
And so we thought maybe if we could find some old clients, we could do this injection and satisfy their checks.

14:51.490 --> 15:00.930
Um, yeah, so like Jeff mentioned, what they were doing is checking the code signature information of the XPC client to see if it had a matching team identifier.

15:00.930 --> 15:04.530
They weren't checking for the hardened run time, so we knew what we needed to find.

15:04.530 --> 15:07.670
An old version of 1Password that matched these conditions.

15:07.830 --> 15:22.210
Uh, we couldn't find any official source from 1Password that was offering old versions of clients, so we tried to get a little bit creative and what we did is tried to enumerate subdomains of 1Password dot com by looking at certificate transparency logs.

15:22.450 --> 15:26.090
And one of the subdomains we found was C dot 1Password dot com.

15:26.090 --> 15:30.190
And it appeared to be some sort of web cache, we didn't really know what it was used for.

15:30.270 --> 15:36.070
Um, so we used Google dorks to see what files Google had indexed, um, on the URL.

15:36.070 --> 15:40.150
And we found a bunch of old versions of 1Password for all different operating systems.

15:40.150 --> 15:44.310
Um, one of the oldest ones we could find for Mac was version 6.5.2.

15:44.310 --> 15:50.530
So we pulled that down and it looked like a perfect candidate because it had the correct team identifier even though it was very old.

15:50.650 --> 15:52.510
Um, and it didn't have the hardened run time.

15:52.710 --> 15:55.190
So we figured we likely could inject into it.

15:55.510 --> 16:08.130
If you have a binary that is not signed with the hardened run time, um, the easiest way to inject into it is to write your own dynamic library, uh, that runs whatever code you want in its constructor.

16:08.130 --> 16:15.130
And then you load that dynamic library, uh, as you launch the program using the dial D insert libraries environment variable.

16:15.310 --> 16:19.850
This is very similar to LD preload on Linux, uh, for loading shared objects.

16:20.030 --> 16:25.330
Um, basically you can, it'll be the first dynamic library that the program loads and it'll run your code pretty much immediately.

16:25.790 --> 16:31.570
So we knew that the XPC server exposed one method called echo, which just echoed a string back to you.

16:31.570 --> 16:36.310
So as a proof of concept, we just wrote our dynamic library to send the string hello world to the server.

16:36.450 --> 16:41.890
Um, as you can see here, uh, once our code runs, it does send that string, we get a successful response.

16:42.190 --> 16:47.310
And this is great because it proves that, um, the XPC server validation was passed by our client.

16:48.830 --> 16:52.390
So obviously we didn't want to just echo strings back to ourselves.

16:52.450 --> 17:06.330
Um, so we looked at what other methods were available and the one that performed actually interesting functionality was called send to main, uh, where basically a message gets sent through browser helper and then to the main application, um, and gives you a response.

17:06.410 --> 17:12.150
Um, so what we tried doing was just sending the same messages that the browser extension was triggering.

17:12.690 --> 17:16.790
Um, but unfortunately we were just getting no responses whatsoever when we would do that.

17:16.790 --> 17:18.150
It was just totally hang.

17:18.610 --> 17:27.290
Um, so through some debugging, we found that when our connection was created, there was a connection object and it was a Boolean flag on it of is browser equals false.

17:27.290 --> 17:29.590
And we figured this might be problematic.

17:29.950 --> 17:39.210
Um, and it seemed to be getting set to false because our client's package ID, one password six in this case, uh, didn't match what was expected being the browser support process.

17:39.570 --> 17:49.830
Um, so we didn't give up there because we knew that the one password CLI tool, um, called OP, uh, we knew that that also communicated with the same XPC server using XPC messages.

17:49.830 --> 17:51.950
So we wanted to understand how that worked.

17:52.210 --> 17:59.730
To do so, we pulled down this XPC spy, uh, open source program for inspecting XPC traffic that a process is sending.

17:59.730 --> 18:03.930
And we started using, uh, the OP tool, uh, while looking at the XPC traffic.

18:03.930 --> 18:10.230
And we saw that it was sending, uh, similar XPC traffic, but, um, it was including this client info JSON blob.

18:10.370 --> 18:16.150
Um, and I'll explain kind of the significance of some of the values you see, uh, highlighted in red here in the coming slides.

18:16.230 --> 18:24.570
But, um, the point is we were able to send messages in the same way the one password CLI was and mimic the functionality of the one password CLI.

18:24.850 --> 18:29.470
And this was nice, um, but there's quite a few limitations that we weren't satisfied with.

18:29.490 --> 18:33.330
First, CLI integration is disabled by default.

18:33.470 --> 18:38.250
So, uh, if you're sending these messages and the CLI integration is disabled, nothing's gonna happen.

18:38.490 --> 18:42.190
Um, and, you know, most people probably haven't turned it on.

18:42.430 --> 18:47.070
So we were wondering, could we just find where the settings are stored and enable it ourselves?

18:47.770 --> 18:50.510
And we found the settings.json file.

18:50.530 --> 18:55.770
Um, we opened it, we saw a bunch of boolean flags for various settings, one of them being CLI integration.

18:55.950 --> 19:06.910
Um, but we also saw that every setting had a corresponding auth tag, which looked like a big random string that we assumed was protecting the integrity of the settings through some authenticated hash or something like that.

19:06.910 --> 19:09.750
So we assumed this wasn't gonna work, but we tried it anyway.

19:09.850 --> 19:13.850
Swi- switched CLI integration from false to true and it just worked.

19:13.870 --> 19:18.930
So it seemed like these auth tags were here, probably secure, but they just weren't being enforced yet.

19:19.210 --> 19:21.770
So we can enable CLI integration, great.

19:21.970 --> 19:25.530
Uh, but there's still, some serious limitations here.

19:25.670 --> 19:30.390
Um, the first being that when you use the 1Password CLI, you have to approve the session.

19:30.390 --> 19:37.970
So if you've used it before, you're probably familiar with this image on the left, where it's gonna say your terminal is requesting access to 1Password, do you want to authorize it or not?

19:38.570 --> 19:48.850
Um, and so what we saw was that your session basically gets created based on the XPC messages that get sent when you run the, uh, OP tool.

19:49.050 --> 19:58.310
And the session identifier is basically based on the PID of your shell, being the parent process that calls the tool, and the start time of that parent process.

19:58.470 --> 20:12.410
And so, it'd be pretty easy for malware on the machine to basically look for any shell that spawns the OPCLI, figure out the PID of that shell, and then grab the start time of the process, and then you'd know a valid session identifier and you could ride along with it,

20:12.410 --> 20:15.410
sending whatever messages you want with an approved session.

20:15.710 --> 20:26.430
However, um, this, you know, obviously isn't optimal either because it requires that there's a legitimate user sitting there really using the 1Password CLI having an active session that you could spoof alongside.

20:27.330 --> 20:41.570
So we kept digging here, um, we, uh, saw that in the client info JSON blob, there was a session type of CLI being sent when the CLI was being used, and, uh, we were wondering if any other session types might be supported.

20:41.630 --> 20:50.270
We disassembled the browser helper binary to take a look, and we saw that it seemed like the string of browser could also be a valid session type.

20:50.270 --> 20:55.450
And this was interesting to us because we hadn't seen this string being sent by, uh, the extension.

20:55.690 --> 20:58.930
But, uh, we tried it anyway to see what would happen.

20:58.930 --> 21:04.650
We removed all of those other session identifiers that I was mentioning before, and it just totally worked.

21:04.650 --> 21:10.410
If 1Password was unlocked, we were able to send a session type browser, request the muck, and we were able to grab it.

21:10.710 --> 21:17.770
So that kind of completed the chain of, um, injecting into an old client, sending XPC messages, and grabbing the muck.

21:18.630 --> 21:25.490
Um, so you may have noticed that every issue we've discussed so far requires that 1Password is unlocked.

21:25.570 --> 21:30.590
Um, this next and final issue we're gonna discuss does not require that 1Password is unlocked.

21:30.610 --> 21:34.290
And it focuses on how biometric authentication is implemented.

21:34.310 --> 21:38.210
If you, uh, use 1Password on a MacBook, you're probably familiar with this.

21:38.210 --> 21:41.210
You launch 1Password, you provide your fingerprint, it unlocks.

21:42.030 --> 21:48.890
Um, so a very common way that macOS apps are gonna implement fingerprint checks is by using this evaluate policy method.

21:49.310 --> 21:50.890
And it's pretty simple.

21:50.930 --> 21:56.750
You call it, prompts the user for their fingerprint, if they provide it and it's valid, it returns true, otherwise it returns false.

21:56.990 --> 22:06.910
So what we did to make sure this method was in use, we hooked it with Frida, uh, used the code on the right, uh, screenshot here, and just basically made it always return true no matter what.

22:07.250 --> 22:15.570
And so after doing that, we launched 1Password, prompted for our fingerprint, we could either hit cancel or provide someone else's fingerprint, and the vault unlocks.

22:16.290 --> 22:25.090
So, um, you might be thinking, well, you know, if you're a red teamer, you'll end up on someone's laptop, you can't just disable SIP and hook methods with Frida.

22:25.170 --> 22:26.130
And that's true.

22:26.130 --> 22:35.090
But this taught us something really interesting, which is that even with an invalid fingerprint, somehow, 1Password is grabbing the muck and it is decrypting the vaults and displaying your passwords.

22:35.090 --> 22:37.030
So we wanted to understand how that worked.

22:37.550 --> 22:48.990
Um, and also it's not obvious that this was gonna work just hooking, um, methods with Frida, cause it is possible to protect items at the keychain level with flags that indicate a fingerprint is required.

22:48.990 --> 22:54.450
And you wouldn't be able to just hook something with Frida and make that work because the keychain would protect you with your fingerprint.

22:54.610 --> 22:56.630
So that was not what was going on here.

22:57.150 --> 22:58.450
So how does it work?

22:58.530 --> 23:04.350
We figured the keychain was involved in some way, so we opened the keychain access application and started looking around.

23:04.470 --> 23:14.990
And we saw that when using biometric authentication, there were, uh, these items, or there was a item in the keychain called biometric unlock, and it would be named differently depending on if you were using SSO or not.

23:14.990 --> 23:22.670
And we saw that it could only be accessed by 1Password, so if it wasn't obvious from the name, we knew it was, uh, being used by 1Password for biometric unlock.

23:23.070 --> 23:32.490
Now, along with, um, the item in the keychain, there were these comments that were added, which tell us that it's, the item here is encrypted by the secure enclave.

23:32.790 --> 23:39.070
And this tracked because when we looked at what was stored in the item, it was just a bunch of random cipher text that we couldn't do anything with.

23:39.570 --> 23:51.990
So, we were wondering where the secure enclave key entry is because we couldn't see it in the keychain access application, we couldn't query it with the security CLI tool, which is the built-in, uh, Mac OS CLI tool for interacting with the keychain.

23:52.050 --> 23:55.770
Uh, so we wanted to understand where it was, what was going on and how it was being used.

23:56.310 --> 24:05.310
What we did for this was hooked the sec item copy matching, uh, method with Frida and logged the parameters passed to it and the return values from it.

24:05.310 --> 24:15.010
This method is used to query the keychain and so we wanted to trigger the fingerprint unlock and see what was, uh, being accessed from the keychain by 1Password when going through that flow.

24:15.230 --> 24:32.730
And amongst other things, one of the things we saw accessed was a sec key ref or a secret key reference and, um, that's what was returned and in the query was an A tag or an application tag, uh, with those hex bytes you see in the top red box and if you decode those,

24:32.730 --> 24:36.850
you get the string of com agile bits 1Password memory enclave key.

24:36.910 --> 24:41.790
So this seemed likely what we were, uh, looking for based on the name, but we wanted to be sure.

24:42.310 --> 24:48.290
So, uh, we wanted to see if it was being used to decrypt anything or decrypt that biometric unlock entry.

24:48.550 --> 24:54.250
Um, now secure enclave keys, it's not the case that you just access them and then do what you wish with the bytes.

24:54.270 --> 24:58.850
Instead, you ask the secure enclave to encrypt something, decrypt something, or sign something.

24:58.850 --> 25:08.010
In this case, it, we thought it would be decrypting something, so we did the same thing with hooking sec key create decrypted data, which is how you would ask the secure enclave to decrypt something.

25:08.530 --> 25:21.890
And we logged the parameters and the return value and we do see that that's, during the biometric unlock, that sec key ref is being used, it's decrypting the cipher text that was stored in the biometric unlock entry, and in return we get 32 bytes.

25:21.990 --> 25:26.470
Uh, so we thought, 32 bytes, that's great, that sounds like an AES key, maybe that's the muck.

25:26.650 --> 25:35.270
But it turned out it was not the muck, and we didn't really know what to do, so we just took these 32 bytes and started trial and error trying to decrypt things.

25:35.670 --> 25:49.210
And, um, finally, we found an item in the encrypted SQLite database called enc unlock key, and we were able to successfully decrypt it with AES, and, uh, in return we got the muck.

25:49.210 --> 26:03.790
So, now we fully understood the chain here of the memory enclave key and the secure enclave being used to decrypt the biometric unlock entry in the keychain, from there you have a key that can be used to decrypt this entry in the SQLite database, then you have the muck,

26:03.790 --> 26:05.810
which can decrypt the rest.

26:06.470 --> 26:20.950
Um, so, now we fully understand this process, but obviously we can't just access the keychain, um, on behalf of 1Password, unless we have a way to inject our own code into 1Password and query the keychain, because those items can only be queried by 1Password.

26:20.950 --> 26:24.210
So, now we're gonna talk about how we accomplished getting that code injection.

26:26.900 --> 26:34.700
Yeah, so, we needed to, uh, have the 1Password bundle ID, and we needed to not invalidate the code signature.

26:34.700 --> 26:46.140
And, uh, there's a relatively old technique on Electron where you can inject, uh, essentially the main.js file isn't included in the signature check, and so you can just overwrite it.

26:46.140 --> 26:54.920
And to protect against that, they added this enable embedded ASAR integrity validation fuse, and this was enabled in the modern version of 1Password.

26:54.920 --> 27:06.460
Uh, but we implied the same thinking that we did to the hardened runtime and went through all of our scraped old versions, and we found one that was created either before or around the time when this flag was introduced, and it had it disabled.

27:06.600 --> 27:18.180
Even if we couldn't find that though, there was this additional GitHub security advisory that was a bypass to this fuse, and, uh, you know, if we couldn't find either of those, we probably would have gone and hunted for some similar bug ourselves.

27:20.120 --> 27:25.740
So, we can overwrite the main.js file, but that isn't good enough to do what we need to do.

27:25.760 --> 27:34.960
Uh, essentially, there are no functions in Node.js that we can call directly that will let us read the keychain and use the secure enclave, and so we need to call these native functions from native code.

27:35.240 --> 27:44.860
And because of the hardened runtime, which is applied to this version of 1Password, we can't actually do the typical thing where you'd write your own library and have the Node.js code hand off to it.

27:45.020 --> 27:58.560
And so, we took a step back and saw that in the entitlements, uh, there was this Apple security allow JIT entitlement, which essentially means that somewhere in the process it would be okay to have a read write execute page of memory.

27:59.680 --> 28:06.220
Once we saw that, we realized a browser exploit would probably work, and so we found an applicable CVE that was exploited in the wild.

28:06.220 --> 28:14.840
We did the standard browser exploit things and got our JavaScript heap and read write primitives and used that to run shellcode by corrupting a WASM object.

28:14.840 --> 28:30.100
I'll show you a video of that in a second, but I also wanted to call out that because we're not in a renderer process, we can kind of cheat a little bit with ASLR by just running VM map outside of the process and then directly writing all the addresses we need to a file and then reading that file into our exploit.

28:41.680 --> 28:44.700
Alright, so hopefully you see that, it's on the monitor.

28:46.160 --> 28:50.300
Yeah, so in this video we're just adding a demo password that we're going to extract.

28:50.620 --> 28:56.620
Uh, we're adding it right now, then we'll show you that SIP is enabled, and then what we're going to do is run a make file.

28:56.620 --> 29:02.640
And that make file is going to compile a C program that prints out some function addresses in the core foundation library.

29:02.880 --> 29:14.820
The reason this is important is because we need those functions, uh, but we didn't want to do the work of adjusting the ASLR ourselves, and these functions are in the shared cache, so we can just print them out and the addresses are the same between processes.

29:15.060 --> 29:24.560
That print is going to be used to generate our final ASLR adjusted, uh, shell code in JavaScript, and we're going to start the old version of 1Password.

29:24.560 --> 29:39.060
The reason we do that is because on the first run, a deep signature check is going to be performed, uh, but we can just start it, kill it, and then run it again with our modified main.js, and because this fuse is disabled, and only a shallow check runs,

29:39.060 --> 29:40.560
we can run our browser exploit.

29:43.720 --> 29:45.480
Yeah, and so there it is.

29:45.480 --> 29:47.060
We'll show you that the password matches.

30:17.440 --> 30:18.720
I think it's up.

30:21.900 --> 30:23.080
No, I'm not good.

30:23.080 --> 30:24.980
Oh man, this is the hardest part of the talk.

30:31.460 --> 30:32.300
There we are.

30:32.300 --> 30:34.900
Okay, so this is the di- oh man.

30:36.520 --> 30:48.780
So this is the diagram of what we essentially did, and I think it's important to call out here that although, obviously 1Password could have used that enforcement flag, uh, but for everything else in order to get that native code execution and actually exploit it,

30:48.780 --> 30:50.820
we essentially just waited.

30:50.820 --> 30:59.540
And you know, we scraped the old versions, but the vulnerabilities were in Electron and- and Chromium, and it can be really hard to secure that when you're releasing new versions, uh, every day.

31:01.240 --> 31:04.020
And so here's a vulnerability summary of what we reported.

31:04.060 --> 31:10.320
Uh, this is a little bit, uh, there are a few more vulnerabilities here than what's going to be on the next slide.

31:10.320 --> 31:18.680
The reason that is, is because the initial XPC entry vulnerability is really what needed to be fixed, not the other stuff that we talked about with the session writing.

31:18.880 --> 31:24.640
And we also reported the, uh, Chrome managed policy bypasses to them, or to Google rather.

31:26.060 --> 31:28.200
And so here's an exploitability summary.

31:28.200 --> 31:32.820
Uh, I think it's important to call out that SIP doesn't prevent this and root is not required.

31:32.820 --> 31:35.420
Low privilege malware can perform these attacks.

31:35.820 --> 31:42.380
Uh, but, uh, the main issues that 1Password was able to fix are- are highlighted in green.

31:42.380 --> 31:51.480
And so the XPC bypass was fixed, the biometric enforcement flag was fixed, and most importantly, the settings modification is now being enforced.

31:51.480 --> 31:53.740
And you might say, well why is that important?

31:53.860 --> 32:00.200
It's important because the first two currently exploitable issues are not exploitable if you just disable that setting.

32:00.200 --> 32:08.820
And so while it might degrade the user experience a little bit, you are fully protected with the newest version of 8.10.38 which was released in August.

32:08.960 --> 32:17.080
Now the- the browser extension injection and impersonation, like I mentioned earlier, that's not really a- a bug per se, it's kind of just how browsers work.

32:17.200 --> 32:25.120
And the browser support get PBID bypass is a little bit interesting because there's not really a clear line of ownership to the issue.

32:25.120 --> 32:29.880
Uh, so 1Password can't really securely look up the code signing information of their parent process.

32:29.900 --> 32:37.040
It is true that all browsers could maybe switch to XPC to provide that audit token.

32:37.040 --> 32:42.880
Uh, it's one available method to perform inter-process communication with uh, or on Mac OS rather.

32:42.880 --> 32:49.720
But it's also true that Apple might be able to provide some way to look up your parent processes code signing information securely.

32:50.080 --> 32:54.780
It's just not super clear who uh, who needs to go and fix this.

32:56.700 --> 33:00.900
And so, because you can't really fix those things, we're going to talk about how to detect them.

33:00.900 --> 33:04.740
So, I pulled all of these bundle IDs from the browser support process.

33:04.740 --> 33:09.540
These are all the chromium based browsers that it will accept as a parent process.

33:09.800 --> 33:14.020
And these are the non-chromium based browsers that it will accept as a parent process.

33:14.460 --> 33:20.200
And so, for the uh, extension injection and impersonation, those are relatively straightforward to fix.

33:20.200 --> 33:24.740
Essentially, what you have to do is go enumerate the dangerous flags, which I've done for you.

33:24.740 --> 33:26.060
They're highlighted in orange.

33:26.100 --> 33:29.120
And you just need to alert anytime those flags are used.

33:29.240 --> 33:35.680
Uh, we also, out of an abundance of caution, are just blocking the developer builds of certain browsers because they have a slightly different front model.

33:36.700 --> 33:42.660
And for the browser support issue, again, if you just disable that setting, you will be fine.

33:42.660 --> 33:45.420
Uh, I can tell you personally I'm not going to disable the setting.

33:45.420 --> 33:46.960
I like using the browser extension.

33:47.000 --> 33:51.380
And I think having malware on your computer is already a pretty significant bar.

33:51.900 --> 33:56.700
Now, uh, if you don't want to disable the extension like me, here's a, you can alert on it.

33:57.140 --> 34:04.240
Uh, basically during normal use, when you click a browser icon, what's going to happen is LaunchD actually spawns that process.

34:04.240 --> 34:16.300
And so, if you just set an alert for anytime a browser, uh, is spawned and the parent is not LaunchD, it's likely malicious or it's going to be some kind of headless browsing.

34:16.300 --> 34:19.940
And you can usually limit that to the people that need to do that at your company.

34:20.140 --> 34:21.580
Probably QA teams.

34:22.380 --> 34:26.800
And a malicious actor might look at that alert and, and try to get around it, right?

34:26.800 --> 34:32.720
By getting LaunchD to spawn their parent, uh, to spawn their exploit process and then execing indirectly.

34:32.860 --> 34:35.260
And so what you can look for there is the exec.

34:35.260 --> 34:43.100
Uh, the, the point of looking for the exec is that there are a couple different ways to obscure or, or, you know, move around those read write pipes.

34:43.240 --> 34:46.200
You don't have to use the process tree that we showed you here.

34:46.200 --> 34:53.480
But at every, um, for every actual exploit, at some point they're going to have to exec into a trusted browser.

34:53.480 --> 34:59.380
And so, that's what you will, uh, would alert on and it looks like PID reuse in LaunchD child processes.

35:00.740 --> 35:02.780
So here's our full disclosure timeline.

35:02.780 --> 35:06.540
We reported all the stuff that we found initially in January of 2024.

35:06.640 --> 35:12.780
And then we followed up on March 8th and reported, reported that the biometrics flag was missing.

35:12.780 --> 35:17.860
And we actually weren't convinced at the time that it was going to be exploitable in practice.

35:17.860 --> 35:25.200
And so we put together a proof of concept and gave it to them on March 22nd and that confirmed for both us and 1Password that this was going to work.

35:26.220 --> 35:28.220
Here's a remediation timeline.

35:28.220 --> 35:33.080
Again, the, the browser support fix is unclear but you can toggle that setting.

35:33.360 --> 35:36.260
The XPC bypass was fixed in April.

35:36.540 --> 35:40.480
Uh, the settings file modifications, this says it was scheduled to be fixed in August.

35:40.480 --> 35:41.700
That version is out now.

35:41.700 --> 35:43.640
We just submitted the slides before.

35:43.740 --> 35:51.840
And the biometrics flag issue was fixed in 8.10.36 and they followed up in 8.10.38 with just a reliability change.

35:51.840 --> 35:57.940
It was actually fixed in 3.6 but I would just recommend upgrading to the, to the latest version.

36:01.220 --> 36:07.960
So here is where you can find the code we've released at, uh, morganc3 slash 1Password exploits.

36:08.060 --> 36:14.000
Um, as of now, we released, uh, the Frida scripts we used while doing some of this research.

36:14.000 --> 36:16.980
Um, none of it is really specific to 1Password at all.

36:16.980 --> 36:21.000
Um, it could definitely be extended and useful for researching other applications.

36:21.200 --> 36:28.220
In terms of exploits, the only thing we've released is a proof of concept for the XPC validation bypass issue.

36:28.220 --> 36:31.660
It's not going to decrypt your vaults but rather just demonstrate the issue.

36:32.100 --> 36:41.640
Uh, in the future, we, uh, will add more code here once ample time has been given for people to be upgrading their 1Password to safe versions and for the other issues to be fixed.

36:43.920 --> 36:47.900
Um, and yeah, we may have some time for a few questions if people have them.

37:05.710 --> 37:07.050
Sorry, what was that?

37:09.930 --> 37:11.970
Yeah, we, we took a look at them.

37:11.970 --> 37:14.310
Um, I would just say any,

37:18.360 --> 37:20.600
okay, sounds good.

37:20.860 --> 37:21.400
Yeah.

37:22.280 --> 37:23.840
Any other 1Password managers?

37:23.840 --> 37:24.500
Yes.

37:31.800 --> 37:34.280
It was just us over the course of about a month.

37:35.060 --> 37:39.820
And the, the guy to your left helped us a bit with the last coolest vulnerability right there.

37:48.460 --> 37:50.120
I'm, I'm so sorry, can you say that again?

37:51.600 --> 37:54.520
Oh, just we wanted to know how safe our passwords were.

37:54.720 --> 37:58.720
You know, really the detections, I would say are the most important part for us.

37:58.900 --> 38:06.940
And I would say practically we expected this as, we expected this as likely possible with, you know, most major password managers or similar attacks.

38:07.020 --> 38:11.500
We wanted to do it on 1Password because we use 1Password and we wanted to use it on red team operations.

38:11.500 --> 38:14.080
Um, and then of course get the issues fixed as well.

38:25.580 --> 38:31.420
So, uh, we, we took a brief look at other password managers, but this was a significant amount of effort for us.

38:31.420 --> 38:39.860
And so you can imagine that we wouldn't want to do the work, uh, especially on, you know, work time if, uh, if it wasn't going to pay out on a red team.

38:47.110 --> 38:47.610
All right.

38:47.610 --> 38:48.370
Thank you.

