1 00:00:03,250 --> 00:00:04,210 Hello. 2 00:00:05,390 --> 00:00:07,610 Hi everyone, uh, I'm Colby Morgan. 3 00:00:07,610 --> 00:00:09,130 I'm here with Jeffrey Hoffman. 4 00:00:09,130 --> 00:00:11,910 We're both offensive security engineers at Robinhood. 5 00:00:11,950 --> 00: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. 6 00:00:20,050 --> 00: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. 7 00:00:26,870 --> 00:00:29,450 So, why look at 1Password for Mac? 8 00:00:29,450 --> 00:00:34,690 Um, well if you use 1 Password, it's probably a place where you have some of your most sensitive credentials. 9 00:00:34,910 --> 00: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. 10 00:00:41,650 --> 00: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. 11 00:00:53,670 --> 00: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. 12 00:01:03,350 --> 00:01:09,450 And this is a SQLite database, uh, it's encrypted but it contains your, uh, 1Password vault contents. 13 00:01:09,450 --> 00:01:11,830 So that file itself wouldn't get you much. 14 00:01:11,890 --> 00:01:16,750 Um, so we're gonna talk about some attacks later that might be able to get you some of that content. 15 00:01:18,230 --> 00: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. 16 00:01:27,530 --> 00:01:30,150 It's not even sending your password to the server. 17 00:01:30,230 --> 00: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. 18 00:01:41,790 --> 00: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. 19 00:01:47,550 --> 00:01:52,810 Um, so we use SSO, meaning, uh, we don't have a password for 1Password. 20 00:01:52,810 --> 00: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. 21 00:02:09,910 --> 00:02:13,290 So the muck is basically the keys to the kingdom. 22 00:02:13,290 --> 00:02:17,750 It allows you to decrypt that SQLite database where your vault content is stored. 23 00:02:18,430 --> 00: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, 24 00:02:33,630 --> 00:02:39,390 access to your 1Password password, meaning something you know, um, and your locally stored secret key. 25 00:02:39,650 --> 00: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. 26 00:02:52,890 --> 00:02:54,870 And so this was really helpful in our research. 27 00:02:56,570 --> 00: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. 28 00:03:04,510 --> 00:03:09,510 That being said, 1Password still cares about creating meaningful security boundaries wherever possible. 29 00:03:09,990 --> 00: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. 30 00:03:17,430 --> 00: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. 31 00:03:27,850 --> 00: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. 32 00:03:35,170 --> 00:03:38,790 Uh, we looked at the framework that it was built on, uh, which is Electron. 33 00:03:38,790 --> 00:03:41,910 And so Electron is a Chromium and node based framework. 34 00:03:41,930 --> 00:03:44,150 It has a pretty well defined attack surface. 35 00:03:44,150 --> 00: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. 36 00:03:55,230 --> 00: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. 37 00:04:04,850 --> 00:04:08,670 And one of the local security controls in Electron is something called fuses. 38 00:04:09,030 --> 00:04:12,890 Uh, these fuses control the behavior of 1Password in certain situations. 39 00:04:12,890 --> 00: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. 40 00:04:18,030 --> 00: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. 41 00:04:23,470 --> 00: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. 42 00:04:30,450 --> 00:04:35,490 And the enable node CLI inspect arguments fuse is also pretty interesting. 43 00:04:35,490 --> 00:04:39,910 It controls whether or not this Chromium flag called the remote debugging port works. 44 00:04:40,210 --> 00: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. 45 00:04:50,350 --> 00:04:56,270 You would have been able to inject, uh, JavaScript or change the currently running JavaScript in any of those pages. 46 00:04:57,750 --> 00: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. 47 00:05:05,610 --> 00: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. 48 00:05:16,270 --> 00:05:21,870 Now the SSH agent and the CLI were disabled by default, but the browser extension is enabled by default. 49 00:05:21,930 --> 00: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. 50 00:05:33,750 --> 00:05:37,710 And so as soon as we saw that behavior, we started trying to figure out how we could abuse that. 51 00:05:38,570 --> 00: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. 52 00:05:46,510 --> 00:05:52,770 Those are prohibitively expensive, and again, because we're local attackers, we have much less expensive options. 53 00:05:52,770 --> 00:05:58,130 And uh, that fuse that I mentioned before that controlled the remote debugging port, that's a Chromium flag. 54 00:05:58,130 --> 00:06:02,950 And so while Electron can turn that off, Chrome and other Chromium based browsers can't. 55 00:06:02,950 --> 00:06:04,550 It's just how they work. 56 00:06:05,110 --> 00:06:09,910 Uh, so as soon as we realized that, we found the JavaScript responsible for doing the syncing. 57 00:06:09,910 --> 00:06:12,510 It's that green URL that's on screen now. 58 00:06:12,550 --> 00:06:18,110 And we opened it up, looked at the console and we saw some log messages related to native core. 59 00:06:18,230 --> 00:06:22,070 This is a native messaging host and we're, we'll revisit that in a little bit. 60 00:06:22,490 --> 00: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. 61 00:06:31,490 --> 00: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. 62 00:06:42,790 --> 00:06:45,590 And so this is our mental model of 1Password. 63 00:06:45,590 --> 00:06:48,450 We'll revisit this image a couple of times during the presentation. 64 00:06:48,470 --> 00:06:53,810 Uh, but what's important to note here is that we didn't really have a vulnerability in 1Password exactly. 65 00:06:53,810 --> 00:06:56,990 We were kind of just abusing how Chrome and extensions function. 66 00:07:00,580 --> 00: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, 67 00:07:14,340 --> 00:07:19,280 uh, still have it do that automatic syncing process Jeff uh, referred to before. 68 00:07:19,600 --> 00: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. 69 00:07:31,080 --> 00: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. 70 00:07:37,820 --> 00: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. 71 00:07:46,060 --> 00:07:50,160 Um, there were a couple of kind of challenges that, uh, made this not straightforward. 72 00:07:50,160 --> 00: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. 73 00:08:01,660 --> 00: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. 74 00:08:11,100 --> 00:08:16,640 Um, and also all extensions are disallowed by default with only some being allow listed. 75 00:08:16,940 --> 00:08:19,820 So we started trying to tackle these challenges one by one. 76 00:08:20,020 --> 00:08:23,960 Uh, first, uh, spoofing the extension identifier. 77 00:08:24,000 --> 00: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. 78 00:08:35,620 --> 00:08:42,140 And, um, basically, um, every browser extension has a manifest.json file with a bunch of key entries. 79 00:08:42,160 --> 00:08:44,560 Um, one of those is called key. 80 00:08:44,560 --> 00: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. 81 00:08:56,220 --> 00: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. 82 00:09:02,900 --> 00:09:06,200 So now we're left with the challenges from the managed Chrome policy. 83 00:09:06,320 --> 00:09:11,400 Uh, we basically started just trying to figure out how it worked and how it is enforced. 84 00:09:11,400 --> 00:09:16,740 And we came across this policy directory in Google Chrome's, um, application support directory. 85 00:09:16,760 --> 00:09:20,420 And we decided to just remove it and see what happens. 86 00:09:20,420 --> 00: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. 87 00:09:30,960 --> 00:09:36,760 However, um, as I mentioned before, we were prevented from starting Chrome with the dash dash load extension flag. 88 00:09:36,780 --> 00: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. 89 00:09:43,360 --> 00:09:47,860 Um, and it, that works because the policy directory doesn't exist at the time Chrome starts. 90 00:09:47,860 --> 00:09:51,740 But then Chrome will recreate that directory and start reinforcing itself. 91 00:09:51,740 --> 00:09:53,580 Um, but your extension is already loaded. 92 00:09:53,820 --> 00:09:57,420 Um, but Chrome will start going through and saying which extension should be allowed. 93 00:09:57,420 --> 00:09:59,140 If it's not allowed, remove it. 94 00:09:59,160 --> 00:10:05,700 Um, but thankfully it's only doing a shallow check of comparing the extension identifier to the allow list. 95 00:10:05,700 --> 00:10:11,420 And we're spoofing the legitimate extension's extension identifier so it doesn't remove our modified one password. 96 00:10:11,620 --> 00:10:14,300 Um, so that overcomes all of the challenges we had. 97 00:10:14,760 --> 00:10:20,380 And here is us just, uh, adding a POC.html file to the extension. 98 00:10:20,380 --> 00:10:25,780 We have the legitimate extension identifier, so our passwords do sync when one password is unlocked. 99 00:10:25,780 --> 00:10:28,000 Um, and it pulls in all our passwords as expected. 100 00:10:28,000 --> 00: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. 101 00:10:38,050 --> 00:10:41,150 So earlier I brought up the term native messaging host. 102 00:10:41,150 --> 00: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. 103 00:10:48,710 --> 00:10:52,050 And, uh, how it normally works is Chrome will launch it. 104 00:10:52,050 --> 00: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. 105 00:10:59,090 --> 00:11:05,210 And if you're familiar with IPC on macOS specifically, that's a big deviation from the norm. 106 00:11:05,210 --> 00: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. 107 00:11:12,670 --> 00:11:18,470 And you can use that audit token to securely look up the code signing information of the process sending the message. 108 00:11:18,610 --> 00: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. 109 00:11:31,130 --> 00: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. 110 00:11:46,650 --> 00:11:52,150 But, that's a generally understood, you know, anti-pattern on XPC. 111 00:11:52,270 --> 00:11:56,610 The reason they tried it here is again, there's no audit token so they can't really do much better. 112 00:11:58,050 --> 00: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. 113 00:12:05,030 --> 00:12:09,610 We're gonna release some Frida scripts for people to look at other native messaging hosts. 114 00:12:09,770 --> 00: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. 115 00:12:22,230 --> 00: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. 116 00:12:47,670 --> 00:12:52,630 And so we considered doing that but we actually don't have to there's a bunch better way. 117 00:12:52,630 --> 00: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. 118 00:13:11,430 --> 00: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. 119 00:13:26,250 --> 00:13:28,510 And so here's our mental model again. 120 00:13:28,670 --> 00:13:32,370 We've totally cut Chrome and the need for the actual extension out of the equation. 121 00:13:32,370 --> 00:13:34,690 This time we're attacking browser support. 122 00:13:34,850 --> 00:13:36,610 And we were satisfied with this. 123 00:13:36,610 --> 00:13:40,570 This is definitely a valid way to uh get the muck and and dump all your vaults. 124 00:13:40,570 --> 00:13:43,630 But we thought well what if we could also cut out browser support. 125 00:13:43,630 --> 00:13:46,470 So we started looking at the browser helper XPC server. 126 00:13:48,090 --> 00: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. 127 00:13:54,370 --> 00: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. 128 00:14:01,570 --> 00:14:08,430 Unfortunately, what they forgot to do was consider uh the hardened run time or the code signing flags of the client. 129 00:14:08,430 --> 00: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? 130 00:14:22,710 --> 00: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. 131 00:14:32,570 --> 00: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. 132 00:14:41,410 --> 00:14:47,690 And so we thought maybe if we could find some old clients, we could do this injection and satisfy their checks. 133 00:14:51,490 --> 00: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. 134 00:15:00,930 --> 00:15:04,530 They weren't checking for the hardened run time, so we knew what we needed to find. 135 00:15:04,530 --> 00:15:07,670 An old version of 1Password that matched these conditions. 136 00:15:07,830 --> 00: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. 137 00:15:22,450 --> 00:15:26,090 And one of the subdomains we found was C dot 1Password dot com. 138 00:15:26,090 --> 00:15:30,190 And it appeared to be some sort of web cache, we didn't really know what it was used for. 139 00:15:30,270 --> 00:15:36,070 Um, so we used Google dorks to see what files Google had indexed, um, on the URL. 140 00:15:36,070 --> 00:15:40,150 And we found a bunch of old versions of 1Password for all different operating systems. 141 00:15:40,150 --> 00:15:44,310 Um, one of the oldest ones we could find for Mac was version 6.5.2. 142 00:15:44,310 --> 00: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. 143 00:15:50,650 --> 00:15:52,510 Um, and it didn't have the hardened run time. 144 00:15:52,710 --> 00:15:55,190 So we figured we likely could inject into it. 145 00:15:55,510 --> 00: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. 146 00:16:08,130 --> 00:16:15,130 And then you load that dynamic library, uh, as you launch the program using the dial D insert libraries environment variable. 147 00:16:15,310 --> 00:16:19,850 This is very similar to LD preload on Linux, uh, for loading shared objects. 148 00:16:20,030 --> 00: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. 149 00:16:25,790 --> 00:16:31,570 So we knew that the XPC server exposed one method called echo, which just echoed a string back to you. 150 00:16:31,570 --> 00:16:36,310 So as a proof of concept, we just wrote our dynamic library to send the string hello world to the server. 151 00:16:36,450 --> 00:16:41,890 Um, as you can see here, uh, once our code runs, it does send that string, we get a successful response. 152 00:16:42,190 --> 00:16:47,310 And this is great because it proves that, um, the XPC server validation was passed by our client. 153 00:16:48,830 --> 00:16:52,390 So obviously we didn't want to just echo strings back to ourselves. 154 00:16:52,450 --> 00: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. 155 00:17:06,410 --> 00:17:12,150 Um, so what we tried doing was just sending the same messages that the browser extension was triggering. 156 00:17:12,690 --> 00:17:16,790 Um, but unfortunately we were just getting no responses whatsoever when we would do that. 157 00:17:16,790 --> 00:17:18,150 It was just totally hang. 158 00:17:18,610 --> 00: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. 159 00:17:27,290 --> 00:17:29,590 And we figured this might be problematic. 160 00:17:29,950 --> 00: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. 161 00:17:39,570 --> 00: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. 162 00:17:49,830 --> 00:17:51,950 So we wanted to understand how that worked. 163 00:17:52,210 --> 00: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. 164 00:17:59,730 --> 00:18:03,930 And we started using, uh, the OP tool, uh, while looking at the XPC traffic. 165 00:18:03,930 --> 00:18:10,230 And we saw that it was sending, uh, similar XPC traffic, but, um, it was including this client info JSON blob. 166 00:18:10,370 --> 00: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. 167 00:18:16,230 --> 00: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. 168 00:18:24,850 --> 00:18:29,470 And this was nice, um, but there's quite a few limitations that we weren't satisfied with. 169 00:18:29,490 --> 00:18:33,330 First, CLI integration is disabled by default. 170 00:18:33,470 --> 00:18:38,250 So, uh, if you're sending these messages and the CLI integration is disabled, nothing's gonna happen. 171 00:18:38,490 --> 00:18:42,190 Um, and, you know, most people probably haven't turned it on. 172 00:18:42,430 --> 00:18:47,070 So we were wondering, could we just find where the settings are stored and enable it ourselves? 173 00:18:47,770 --> 00:18:50,510 And we found the settings.json file. 174 00:18:50,530 --> 00:18:55,770 Um, we opened it, we saw a bunch of boolean flags for various settings, one of them being CLI integration. 175 00:18:55,950 --> 00: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. 176 00:19:06,910 --> 00:19:09,750 So we assumed this wasn't gonna work, but we tried it anyway. 177 00:19:09,850 --> 00:19:13,850 Swi- switched CLI integration from false to true and it just worked. 178 00:19:13,870 --> 00:19:18,930 So it seemed like these auth tags were here, probably secure, but they just weren't being enforced yet. 179 00:19:19,210 --> 00:19:21,770 So we can enable CLI integration, great. 180 00:19:21,970 --> 00:19:25,530 Uh, but there's still, some serious limitations here. 181 00:19:25,670 --> 00:19:30,390 Um, the first being that when you use the 1Password CLI, you have to approve the session. 182 00:19:30,390 --> 00: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? 183 00:19:38,570 --> 00: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. 184 00:19:49,050 --> 00: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. 185 00:19:58,470 --> 00: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, 186 00:20:12,410 --> 00:20:15,410 sending whatever messages you want with an approved session. 187 00:20:15,710 --> 00: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. 188 00:20:27,330 --> 00: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. 189 00:20:41,630 --> 00: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. 190 00:20:50,270 --> 00:20:55,450 And this was interesting to us because we hadn't seen this string being sent by, uh, the extension. 191 00:20:55,690 --> 00:20:58,930 But, uh, we tried it anyway to see what would happen. 192 00:20:58,930 --> 00:21:04,650 We removed all of those other session identifiers that I was mentioning before, and it just totally worked. 193 00:21:04,650 --> 00: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. 194 00:21:10,710 --> 00:21:17,770 So that kind of completed the chain of, um, injecting into an old client, sending XPC messages, and grabbing the muck. 195 00:21:18,630 --> 00:21:25,490 Um, so you may have noticed that every issue we've discussed so far requires that 1Password is unlocked. 196 00:21:25,570 --> 00:21:30,590 Um, this next and final issue we're gonna discuss does not require that 1Password is unlocked. 197 00:21:30,610 --> 00:21:34,290 And it focuses on how biometric authentication is implemented. 198 00:21:34,310 --> 00:21:38,210 If you, uh, use 1Password on a MacBook, you're probably familiar with this. 199 00:21:38,210 --> 00:21:41,210 You launch 1Password, you provide your fingerprint, it unlocks. 200 00:21:42,030 --> 00:21:48,890 Um, so a very common way that macOS apps are gonna implement fingerprint checks is by using this evaluate policy method. 201 00:21:49,310 --> 00:21:50,890 And it's pretty simple. 202 00:21:50,930 --> 00: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. 203 00:21:56,990 --> 00: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. 204 00:22:07,250 --> 00: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. 205 00:22:16,290 --> 00: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. 206 00:22:25,170 --> 00:22:26,130 And that's true. 207 00:22:26,130 --> 00: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. 208 00:22:35,090 --> 00:22:37,030 So we wanted to understand how that worked. 209 00:22:37,550 --> 00: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. 210 00:22:48,990 --> 00: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. 211 00:22:54,610 --> 00:22:56,630 So that was not what was going on here. 212 00:22:57,150 --> 00:22:58,450 So how does it work? 213 00:22:58,530 --> 00:23:04,350 We figured the keychain was involved in some way, so we opened the keychain access application and started looking around. 214 00:23:04,470 --> 00: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. 215 00:23:14,990 --> 00: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. 216 00:23:23,070 --> 00: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. 217 00:23:32,790 --> 00: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. 218 00:23:39,570 --> 00: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. 219 00:23:52,050 --> 00:23:55,770 Uh, so we wanted to understand where it was, what was going on and how it was being used. 220 00:23:56,310 --> 00: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. 221 00:24:05,310 --> 00: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. 222 00:24:15,230 --> 00: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, 223 00:24:32,730 --> 00:24:36,850 you get the string of com agile bits 1Password memory enclave key. 224 00:24:36,910 --> 00:24:41,790 So this seemed likely what we were, uh, looking for based on the name, but we wanted to be sure. 225 00:24:42,310 --> 00:24:48,290 So, uh, we wanted to see if it was being used to decrypt anything or decrypt that biometric unlock entry. 226 00:24:48,550 --> 00: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. 227 00:24:54,270 --> 00:24:58,850 Instead, you ask the secure enclave to encrypt something, decrypt something, or sign something. 228 00:24:58,850 --> 00: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. 229 00:25:08,530 --> 00: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. 230 00:25:21,990 --> 00:25:26,470 Uh, so we thought, 32 bytes, that's great, that sounds like an AES key, maybe that's the muck. 231 00:25:26,650 --> 00: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. 232 00:25:35,670 --> 00: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. 233 00:25:49,210 --> 00: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, 234 00:26:03,790 --> 00:26:05,810 which can decrypt the rest. 235 00:26:06,470 --> 00: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. 236 00:26:20,950 --> 00:26:24,210 So, now we're gonna talk about how we accomplished getting that code injection. 237 00:26:26,900 --> 00:26:34,700 Yeah, so, we needed to, uh, have the 1Password bundle ID, and we needed to not invalidate the code signature. 238 00:26:34,700 --> 00: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. 239 00:26:46,140 --> 00: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. 240 00:26:54,920 --> 00: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. 241 00:27:06,600 --> 00: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. 242 00:27:20,120 --> 00:27:25,740 So, we can overwrite the main.js file, but that isn't good enough to do what we need to do. 243 00:27:25,760 --> 00: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. 244 00:27:35,240 --> 00: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. 245 00:27:45,020 --> 00: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. 246 00:27:59,680 --> 00: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. 247 00:28:06,220 --> 00: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. 248 00:28:14,840 --> 00: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. 249 00:28:41,680 --> 00:28:44,700 Alright, so hopefully you see that, it's on the monitor. 250 00:28:46,160 --> 00:28:50,300 Yeah, so in this video we're just adding a demo password that we're going to extract. 251 00:28:50,620 --> 00: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. 252 00:28:56,620 --> 00: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. 253 00:29:02,880 --> 00: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. 254 00:29:15,060 --> 00: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. 255 00:29:24,560 --> 00: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, 256 00:29:39,060 --> 00:29:40,560 we can run our browser exploit. 257 00:29:43,720 --> 00:29:45,480 Yeah, and so there it is. 258 00:29:45,480 --> 00:29:47,060 We'll show you that the password matches. 259 00:30:17,440 --> 00:30:18,720 I think it's up. 260 00:30:21,900 --> 00:30:23,080 No, I'm not good. 261 00:30:23,080 --> 00:30:24,980 Oh man, this is the hardest part of the talk. 262 00:30:31,460 --> 00:30:32,300 There we are. 263 00:30:32,300 --> 00:30:34,900 Okay, so this is the di- oh man. 264 00:30:36,520 --> 00: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, 265 00:30:48,780 --> 00:30:50,820 we essentially just waited. 266 00:30:50,820 --> 00: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. 267 00:31:01,240 --> 00:31:04,020 And so here's a vulnerability summary of what we reported. 268 00:31:04,060 --> 00: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. 269 00:31:10,320 --> 00: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. 270 00:31:18,880 --> 00:31:24,640 And we also reported the, uh, Chrome managed policy bypasses to them, or to Google rather. 271 00:31:26,060 --> 00:31:28,200 And so here's an exploitability summary. 272 00:31:28,200 --> 00:31:32,820 Uh, I think it's important to call out that SIP doesn't prevent this and root is not required. 273 00:31:32,820 --> 00:31:35,420 Low privilege malware can perform these attacks. 274 00:31:35,820 --> 00:31:42,380 Uh, but, uh, the main issues that 1Password was able to fix are- are highlighted in green. 275 00:31:42,380 --> 00: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. 276 00:31:51,480 --> 00:31:53,740 And you might say, well why is that important? 277 00:31:53,860 --> 00:32:00,200 It's important because the first two currently exploitable issues are not exploitable if you just disable that setting. 278 00:32:00,200 --> 00: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. 279 00:32:08,960 --> 00: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. 280 00:32:17,200 --> 00: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. 281 00:32:25,120 --> 00:32:29,880 Uh, so 1Password can't really securely look up the code signing information of their parent process. 282 00:32:29,900 --> 00:32:37,040 It is true that all browsers could maybe switch to XPC to provide that audit token. 283 00:32:37,040 --> 00:32:42,880 Uh, it's one available method to perform inter-process communication with uh, or on Mac OS rather. 284 00:32:42,880 --> 00: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. 285 00:32:50,080 --> 00:32:54,780 It's just not super clear who uh, who needs to go and fix this. 286 00:32:56,700 --> 00:33:00,900 And so, because you can't really fix those things, we're going to talk about how to detect them. 287 00:33:00,900 --> 00:33:04,740 So, I pulled all of these bundle IDs from the browser support process. 288 00:33:04,740 --> 00:33:09,540 These are all the chromium based browsers that it will accept as a parent process. 289 00:33:09,800 --> 00:33:14,020 And these are the non-chromium based browsers that it will accept as a parent process. 290 00:33:14,460 --> 00:33:20,200 And so, for the uh, extension injection and impersonation, those are relatively straightforward to fix. 291 00:33:20,200 --> 00:33:24,740 Essentially, what you have to do is go enumerate the dangerous flags, which I've done for you. 292 00:33:24,740 --> 00:33:26,060 They're highlighted in orange. 293 00:33:26,100 --> 00:33:29,120 And you just need to alert anytime those flags are used. 294 00:33:29,240 --> 00: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. 295 00:33:36,700 --> 00:33:42,660 And for the browser support issue, again, if you just disable that setting, you will be fine. 296 00:33:42,660 --> 00:33:45,420 Uh, I can tell you personally I'm not going to disable the setting. 297 00:33:45,420 --> 00:33:46,960 I like using the browser extension. 298 00:33:47,000 --> 00:33:51,380 And I think having malware on your computer is already a pretty significant bar. 299 00:33:51,900 --> 00:33:56,700 Now, uh, if you don't want to disable the extension like me, here's a, you can alert on it. 300 00:33:57,140 --> 00: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. 301 00:34:04,240 --> 00: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. 302 00:34:16,300 --> 00:34:19,940 And you can usually limit that to the people that need to do that at your company. 303 00:34:20,140 --> 00:34:21,580 Probably QA teams. 304 00:34:22,380 --> 00:34:26,800 And a malicious actor might look at that alert and, and try to get around it, right? 305 00:34:26,800 --> 00:34:32,720 By getting LaunchD to spawn their parent, uh, to spawn their exploit process and then execing indirectly. 306 00:34:32,860 --> 00:34:35,260 And so what you can look for there is the exec. 307 00:34:35,260 --> 00: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. 308 00:34:43,240 --> 00:34:46,200 You don't have to use the process tree that we showed you here. 309 00:34:46,200 --> 00: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. 310 00:34:53,480 --> 00:34:59,380 And so, that's what you will, uh, would alert on and it looks like PID reuse in LaunchD child processes. 311 00:35:00,740 --> 00:35:02,780 So here's our full disclosure timeline. 312 00:35:02,780 --> 00:35:06,540 We reported all the stuff that we found initially in January of 2024. 313 00:35:06,640 --> 00:35:12,780 And then we followed up on March 8th and reported, reported that the biometrics flag was missing. 314 00:35:12,780 --> 00:35:17,860 And we actually weren't convinced at the time that it was going to be exploitable in practice. 315 00:35:17,860 --> 00: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. 316 00:35:26,220 --> 00:35:28,220 Here's a remediation timeline. 317 00:35:28,220 --> 00:35:33,080 Again, the, the browser support fix is unclear but you can toggle that setting. 318 00:35:33,360 --> 00:35:36,260 The XPC bypass was fixed in April. 319 00:35:36,540 --> 00:35:40,480 Uh, the settings file modifications, this says it was scheduled to be fixed in August. 320 00:35:40,480 --> 00:35:41,700 That version is out now. 321 00:35:41,700 --> 00:35:43,640 We just submitted the slides before. 322 00:35:43,740 --> 00: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. 323 00:35:51,840 --> 00:35:57,940 It was actually fixed in 3.6 but I would just recommend upgrading to the, to the latest version. 324 00:36:01,220 --> 00:36:07,960 So here is where you can find the code we've released at, uh, morganc3 slash 1Password exploits. 325 00:36:08,060 --> 00:36:14,000 Um, as of now, we released, uh, the Frida scripts we used while doing some of this research. 326 00:36:14,000 --> 00:36:16,980 Um, none of it is really specific to 1Password at all. 327 00:36:16,980 --> 00:36:21,000 Um, it could definitely be extended and useful for researching other applications. 328 00:36:21,200 --> 00:36:28,220 In terms of exploits, the only thing we've released is a proof of concept for the XPC validation bypass issue. 329 00:36:28,220 --> 00:36:31,660 It's not going to decrypt your vaults but rather just demonstrate the issue. 330 00:36:32,100 --> 00: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. 331 00:36:43,920 --> 00:36:47,900 Um, and yeah, we may have some time for a few questions if people have them. 332 00:37:05,710 --> 00:37:07,050 Sorry, what was that? 333 00:37:09,930 --> 00:37:11,970 Yeah, we, we took a look at them. 334 00:37:11,970 --> 00:37:14,310 Um, I would just say any, 335 00:37:18,360 --> 00:37:20,600 okay, sounds good. 336 00:37:20,860 --> 00:37:21,400 Yeah. 337 00:37:22,280 --> 00:37:23,840 Any other 1Password managers? 338 00:37:23,840 --> 00:37:24,500 Yes. 339 00:37:31,800 --> 00:37:34,280 It was just us over the course of about a month. 340 00:37:35,060 --> 00:37:39,820 And the, the guy to your left helped us a bit with the last coolest vulnerability right there. 341 00:37:48,460 --> 00:37:50,120 I'm, I'm so sorry, can you say that again? 342 00:37:51,600 --> 00:37:54,520 Oh, just we wanted to know how safe our passwords were. 343 00:37:54,720 --> 00:37:58,720 You know, really the detections, I would say are the most important part for us. 344 00:37:58,900 --> 00: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. 345 00:38:07,020 --> 00:38:11,500 We wanted to do it on 1Password because we use 1Password and we wanted to use it on red team operations. 346 00:38:11,500 --> 00:38:14,080 Um, and then of course get the issues fixed as well. 347 00:38:25,580 --> 00: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. 348 00:38:31,420 --> 00: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. 349 00:38:47,110 --> 00:38:47,610 All right. 350 00:38:47,610 --> 00:38:48,370 Thank you.