start	end	text
3250	9550	Hello. Hi everyone, uh, I'm Colby Morgan. I'm here with Jeffrey Hoffman. We're both
9550	14710	offensive security engineers at Robinhood. And earlier this year we did some research into
14710	20530	1Password for Mac, uh, with the goal of identifying local attacks to dump vaults. And
20530	23870	today we're gonna be sharing with you the outcome of our research and some of the, uh,
23870	31190	vulnerabilities we discovered. So, why look at 1Password for Mac? Um, well if you use 1
31190	35310	Password, it's probably a place where you have some of your most sensitive credentials. And
35310	38990	we know that APTs, red teamers, one of the first things they're gonna do when they land on
38990	45010	an endpoint is look for credentials. Things like, uh, cloud credentials, browser cookies,
45010	49070	um, passwords, API keys, things they might be able to use even if they were evicted from the
49070	54950	laptop, uh, to retain, um, some sort of access or even more access. Um, if they were to be
54950	59830	grepping around, uh, looking for files that have the word password in the file name, one
59830	66110	thing they would find is this 1Password.SQLite file. And this is a SQLite database, uh, it's
66110	70990	encrypted but it contains your, uh, 1Password vault contents. So that file itself wouldn't
70990	75610	get you much. Um, so we're gonna talk about some attacks later that might be able to get you
75610	81510	some of that content. Um, so to talk a little bit about the local security model of 1Password
81510	86750	on Mac, um, when you log in with your password to 1Password, uh, it doesn't actually store
86750	91370	your password. It's not even sending your password to the server. Instead what's going on
91370	97270	is, um, your password along with a locally stored secret key are combined cryptographically
97270	101950	to generate a master unlock key, uh, which is now referred to as an account unlock key. You'll
101950	106210	hear us throughout this talk refer to it as a muck because that's how we saw it referenced in
106210	113330	the code. Um, so we use SSO, meaning, uh, we don't have a password for 1Password. And how it
113330	120230	works in this case is, uh, you authenticate and then you get a device key, um, and you receive a
120230	125630	credential bundle from 1Password's API and the device key is stored in your Mac keychain and
125630	130850	that is used to decrypt the credential bundle that contains that muck that I referenced. So
130850	136030	the muck is basically the keys to the kingdom. It allows you to decrypt that SQLite database
136030	141990	where your vault content is stored. Malware on your machine, uh, without a SIP bypass on Mac
141990	147350	or a way to inject into processes arbitrarily, shouldn't be able to get your vault contents, uh,
147350	152510	decrypted, um, without, in the SSO case, unrestricted keychain access and in the non-SSO
152510	158050	case, um, access to your 1Password password, meaning something you know, um, and your locally
158050	163750	stored secret key. Once you have the muck, uh, the full decryption process, um, isn't super
163750	168850	straightforward, but it's fully explained in this blog post from David Shutes, aka DarthNull,
168850	173470	uh, where he also had some code that we referenced for the, the decryption. And so this was
173470	179650	really helpful in our research. Yeah, so it's generally understood that if somebody has full
179650	183210	control over your machine, they're going to be able to access whatever data it protects in
183210	187790	some way, shape or form. That being said, 1Password still cares about creating meaningful
187790	192810	security boundaries wherever possible. And on Mac OS specifically, with things like SIP and
192810	197890	code signing, uh, there is a possibility to create these significant boundaries. Uh, these are
197890	202550	just some CVEs that are Mac specific, uh, we took a look at these CVEs when we first started
202550	205930	our work and they indicated to us that we were thinking about the right things and looking in
205930	211110	the right places. So when we started out looking at 1Password, we didn't really look at the
211110	216690	app, we looked at the framework that it was built on. Uh, we looked at the framework that it
216690	221910	was built on, uh, which is Electron. And so Electron is a Chromium and node based framework.
221930	226490	It has a pretty well defined attack surface. The standard attack you'll see is somebody
226490	231910	trying to get XSS and convert that into RCE or, or something else, but 1Password is an app,
231910	236630	doesn't have a whole lot of opportunities to inject user controlled content. Uh, the XSS to
236630	242510	RCE route is usually considered a, a remote attack, but because we're local attackers, we
242510	247230	have the ability to consider local things. And one of the local security controls in Electron
247230	252130	is something called fuses. Uh, these fuses control the behavior of 1Password in certain
252130	256010	situations. I'm not going to read all of these off to you, but I'll tell you that 1Password
256010	260850	correctly set all of these. Uh, but some of the interesting ones that, that you might take a
260850	266370	look at are things like only load app from ASAR. Uh, if this had been enabled or rather
266370	271390	disabled, uh, you might be able to proxy the app and inject JavaScript that way. And the
271390	276590	enable node CLI inspect arguments fuse is also pretty interesting. It controls whether or
276590	281870	not this Chromium flag called the remote debugging port works. If that had been enabled
281870	287110	in 1Password, we would have, uh, started it with this flag, uh, connected a Chromium debugger
287110	291070	to it, and from there you can see all the pages that the app has. You would have been able to
291070	298150	inject, uh, JavaScript or change the currently running JavaScript in any of those pages. So
298150	303110	once we saw that all the Electron, uh, attack surface was, was considered and wasn't going to
303110	307710	be viable, we started looking at how the app functioned. And there were three main ways that
307710	314990	we saw to get passwords out of the desktop app, and those were the SSH agent, the CLI, and the
314990	320050	browser extension. Now the SSH agent and the CLI were disabled by default, but the browser
320050	325570	extension is enabled by default. And so once we saw this, we installed the browser extension,
325570	329470	and as long as the app is unlocked, if you click the browser extension, it's going to
329470	332550	seamlessly sync all of your passwords and they're going to show up without any kind of
332550	336410	re-authentication. And so as soon as we saw that behavior, we started trying to figure out how
336410	343210	we could abuse that. And so we briefly considered the idea of maybe if we had some cool RCE and
343210	347610	sandbox escape, we could control Chrome and try to do that remotely. Those are prohibitively
347610	353130	expensive, and again, because we're local attackers, we have much less expensive options. And
353130	357510	uh, that fuse that I mentioned before that controlled the remote debugging port, that's a
357510	362030	Chromium flag. And so while Electron can turn that off, Chrome and other Chromium based
362030	367270	browsers can't. It's just how they work. Uh, so as soon as we realized that, we found the
367270	372990	JavaScript responsible for doing the syncing. It's that green URL that's on screen now. And
372990	378110	we opened it up, looked at the console and we saw some log messages related to native core.
378230	383090	This is a native messaging host and we're, we'll revisit that in a little bit. Uh, but
383090	388990	essentially what we did is we read the JavaScript from that page, uh, beautified it, modified
388990	393730	it to do that syncing behavior immediately. And with the remote debugging port, we just
393730	399310	injected our new extension into that page and uh, everything was synced and we were able to
399310	405730	extract passwords and decrypt them. And so this is our mental model of 1Password. We'll
405730	409310	revisit this image a couple of times during the presentation. Uh, but what's important to
409310	414210	note here is that we didn't really have a vulnerability in 1Password exactly. We were kind
414210	422900	of just abusing how Chrome and extensions function. Yeah, so sticking along the path of
422900	427600	attacking the browser extension, um, one question we were asking ourselves is would we be
427600	432100	able to spoof the legitimate 1Password extension with our own extension or make changes to
432100	437740	the 1Password extension and still, uh, still have it do that automatic syncing process Jeff
437740	443420	uh, referred to before. Um, so if you're not familiar, uh, you can start Chrome from the
443420	448780	command line, uh, along with this dash dash load extension flag to load extensions from disk,
448780	452860	um, which are referred to as unpacked extensions. So what we were wondering is if we could
452860	457820	load a modified version of 1Password from disk, uh, and have it do that syncing process.
457820	461680	Obviously the modified code we would add would be JavaScript that makes it do what we want
461680	466780	such as like taking those passwords after they sync and sending them to a remote server. Um,
466780	471680	there were a couple of kind of challenges that, uh, made this not straightforward. So first,
471680	477060	uh, the, when the extension talks to the Mac OS 1Password app, uh, the 1Password app is
477060	480480	gonna verify that the connection is coming from the legitimate extensions extension
480480	486440	identifier. Um, and then further, we have a managed Chrome policy that prevents, uh,
486440	490320	loading unpacked extensions altogether, meaning we couldn't launch Chrome with that CLI
490320	495760	flag. Um, and also all extensions are disallowed by default with only some being allow
495760	502300	listed. So we started trying to tackle these challenges one by one. Uh, first, uh, spoofing
502300	506900	the extension identifier. Thankfully this was extremely straightforward because Google tells
506900	512200	us exactly how to do it on their browser extension, uh, security FAQ page where they
512200	518520	basically explain that they don't consider this a bug. And, um, basically, um, every browser
518520	523800	extension has a manifest.json file with a bunch of key entries. Um, one of those is called
523800	529340	key. And, um, basically, if you take that key entry and put it in your own extensions
529340	534480	manifest.json file, the extension IDs will be the same because the extension identifier is
534480	539240	derived from that key entry. So we can just grab the legitimate extensions, um, key
539240	544140	identifier, put that on our own extension, and then it'll match. So now we're left with the
544140	548740	challenges from the managed Chrome policy. Uh, we basically started just trying to figure
548740	554340	out how it worked and how it is enforced. And we came across this policy directory in Google
554340	559500	Chrome's, um, application support directory. And we decided to just remove it and see what
559500	565780	happens. Um, so if you delete that policy directory and you start Chrome, Chrome is actually
565780	569700	smart enough to realize it should be there and it'll recreate it and it'll start reinforcing
569700	575020	itself. However, um, as I mentioned before, we were prevented from starting Chrome with the
575020	579960	dash dash load extension flag. But what you can do is delete the policy directory, start Chrome
579960	584620	with the dash dash load extension flag, which will load your extension. Um, and it, that works
584620	589040	because the policy directory doesn't exist at the time Chrome starts. But then Chrome will
589040	592780	recreate that directory and start reinforcing itself. Um, but your extension is already
592780	597000	loaded. Um, but Chrome will start going through and saying which extension should be
597000	602140	allowed. If it's not allowed, remove it. Um, but thankfully it's only doing a shallow check
602140	606820	of comparing the extension identifier to the allow list. And we're spoofing the legitimate
606820	612020	extension's extension identifier so it doesn't remove our modified one password. Um, so
612020	618940	that overcomes all of the challenges we had. And here is us just, uh, adding a POC.html
618940	623680	file to the extension. We have the legitimate extension identifier, so our passwords do
623680	628220	sync when one password is unlocked. Um, and it pulls in all our passwords as expected. And
628220	633520	obviously we could have also added, um, edited the JavaScript or added JavaScript to, uh, make
633520	640230	it grab those credentials and send them elsewhere. So earlier I brought up the term native
640230	645290	messaging host. And what that is, is a binary that acts as a middleman between, uh, Chrome
645290	650250	or other browsers that support this protocol and the desktop app. And, uh, how it normally
650250	655430	works is Chrome will launch it. It will, uh, hold pipes to the standard in and standard out
655430	661290	of that process and then send JSON messages back and forth. And if you're familiar with IPC
661290	667390	on macOS specifically, that's a big deviation from the norm. Normally things use XPC and part
667390	671250	of the reason they do that is because when you use XPC you have something called an audit
671250	675930	token available to you. And you can use that audit token to securely look up the code signing
675930	680870	information of the process sending the message. Because there's no audit token and there's no
680870	686610	way to attach it to this method of IPC, uh, there's not really a great way for 1Password to
686610	691850	go and verify the code signing information of whatever is sending that JSON. And they seem
691850	697630	to know about this and, and still try to implement, uh, a parent PID check and essentially
697630	701510	what they did was they would call get PPID, go look up the code signing information of the
701510	706650	parent and check it a bunch of, uh, check it across the list of accepted and trusted browsers.
706650	713430	But, that's a generally understood, you know, anti-pattern on XPC. The reason they tried it
713430	720170	here is again, there's no audit token so they can't really do much better. Um, so going
720170	723750	forward we're gonna talk about dumping and instrumenting and hooking and our tool of
723750	727990	choice for that was Frida. We're gonna release some Frida scripts for people to look at other
727990	734530	native messaging hosts. Um, what you can see on screen here is me hooking the read and
734530	739670	write methods for the native messaging host and this is how we figured out what JSON to send
739670	745450	when we actually wrote our exploit. And so like I said, it's a well understood problem that
745450	750110	if you're doing XPC you should be using the audit token because if you try to look up the
750110	755910	code signing information by PID what can happen is someone will send a message exec into the
755910	761610	actual process that was supposed to send that message and by the time the PID is used the
761610	766170	co-signing information will be that of the trusted process and not the malicious one that
766170	770750	sent that initial message. And so we considered doing that but we actually don't have to
770750	776250	there's a bunch better way. What you can do is create this process tree of 3 processes where
776250	782010	the parent holds the standard in and standard out write pipes, the child execs into a
782010	786750	trusted browser and the grandchild is actually the browser support process and when it goes
786750	792990	to do that uh get PPID check we've satisfied that condition. So this is what the exploit
792990	797590	looks like in process and once you've set up these pipes you can just send the JSON that we
797590	803870	showed uh in the Frida slide and the browser support process will happily return back to you
803870	810590	the muck. And so here's our mental model again. We've totally cut Chrome and the need for the
810590	815590	actual extension out of the equation. This time we're attacking browser support. And we
815590	819750	were satisfied with this. This is definitely a valid way to uh get the muck and and dump all
819750	823910	your vaults. But we thought well what if we could also cut out browser support. So we
823910	830590	started looking at the browser helper XPC server. And I've talked a lot about XPC already
830590	834890	I'll spare you but they do everything correctly here that you would expect. They take the
834890	839730	audit token, they get the code signing information in a secure way and they check the team
839730	845210	identifier and bundle ID. Unfortunately, what they forgot to do was consider uh the
845210	849650	hardened run time or the code signing flags of the client. And so if you're not familiar
849650	854750	with hardened run time, essentially what it is, is a code signing flag that says to Mac OS
855370	862410	to uh block all different manners of injecting uh code dynamically and that makes sense,
862410	867410	right? If your security model is going to be built around code signing, you don't want ways
867410	873070	to have untrusted code running in a process without invalidating that signature. And so
873070	877650	that was introduced in September of 2018 and it would have been literally impossible for
877650	883170	them to include that control and they were a company before 2018. And so we thought maybe
883170	887690	if we could find some old clients, we could do this injection and satisfy their checks.
891490	896830	Um, yeah, so like Jeff mentioned, what they were doing is checking the code signature
896830	901290	information of the XPC client to see if it had a matching team identifier. They weren't
901290	905390	checking for the hardened run time, so we knew what we needed to find. An old version of
905390	911450	1Password that matched these conditions. Uh, we couldn't find any official source from 1Password
911450	915970	that was offering old versions of clients, so we tried to get a little bit creative and what
915970	920710	we did is tried to enumerate subdomains of 1Password dot com by looking at certificate
920710	926610	transparency logs. And one of the subdomains we found was C dot 1Password dot com. And it
926610	931290	appeared to be some sort of web cache, we didn't really know what it was used for. Um, so we
931290	936950	used Google dorks to see what files Google had indexed, um, on the URL. And we found a bunch
936950	941390	of old versions of 1Password for all different operating systems. Um, one of the oldest ones
941390	946830	we could find for Mac was version 6.5.2. So we pulled that down and it looked like a perfect
946830	950830	candidate because it had the correct team identifier even though it was very old. Um, and
950830	956110	it didn't have the hardened run time. So we figured we likely could inject into it. If you
956110	961930	have a binary that is not signed with the hardened run time, um, the easiest way to inject
961930	967350	into it is to write your own dynamic library, uh, that runs whatever code you want in its
967350	972450	constructor. And then you load that dynamic library, uh, as you launch the program using the
972450	978450	dial D insert libraries environment variable. This is very similar to LD preload on Linux, uh,
978450	982750	for loading shared objects. Um, basically you can, it'll be the first dynamic library that the
982750	988070	program loads and it'll run your code pretty much immediately. So we knew that the XPC server
988070	992490	exposed one method called echo, which just echoed a string back to you. So as a proof of
992490	996850	concept, we just wrote our dynamic library to send the string hello world to the server. Um,
996850	1001130	as you can see here, uh, once our code runs, it does send that string, we get a successful
1001130	1006210	response. And this is great because it proves that, um, the XPC server validation was passed
1006210	1013330	by our client. So obviously we didn't want to just echo strings back to ourselves. Um, so we
1013330	1017010	looked at what other methods were available and the one that performed actually interesting
1017010	1021690	functionality was called send to main, uh, where basically a message gets sent through browser
1021690	1028170	helper and then to the main application, um, and gives you a response. Um, so what we tried
1028170	1033190	doing was just sending the same messages that the browser extension was triggering. Um, but
1033190	1037090	unfortunately we were just getting no responses whatsoever when we would do that. It was just
1037090	1042630	totally hang. Um, so through some debugging, we found that when our connection was created,
1042630	1047710	there was a connection object and it was a Boolean flag on it of is browser equals false. And
1047710	1052770	we figured this might be problematic. Um, and it seemed to be getting set to false because our
1052770	1057390	client's package ID, one password six in this case, uh, didn't match what was expected being
1057390	1062210	the browser support process. Um, so we didn't give up there because we knew that the one
1062210	1067710	password CLI tool, um, called OP, uh, we knew that that also communicated with the same XPC
1067710	1073810	server using XPC messages. So we wanted to understand how that worked. To do so, we pulled
1073810	1079210	down this XPC spy, uh, open source program for inspecting XPC traffic that a process is
1079210	1084450	sending. And we started using, uh, the OP tool, uh, while looking at the XPC traffic. And we
1084450	1089110	saw that it was sending, uh, similar XPC traffic, but, um, it was including this client info
1089110	1094030	JSON blob. Um, and I'll explain kind of the significance of some of the values you see, uh,
1094030	1099330	highlighted in red here in the coming slides. But, um, the point is we were able to send
1099330	1103310	messages in the same way the one password CLI was and mimic the functionality of the one
1103310	1108290	password CLI. And this was nice, um, but there's quite a few limitations that we weren't
1108290	1114690	satisfied with. First, CLI integration is disabled by default. So, uh, if you're sending
1114690	1119810	these messages and the CLI integration is disabled, nothing's gonna happen. Um, and, you
1119810	1124710	know, most people probably haven't turned it on. So we were wondering, could we just find
1124710	1129730	where the settings are stored and enable it ourselves? And we found the settings.json
1129730	1134310	file. Um, we opened it, we saw a bunch of boolean flags for various settings, one of them
1134310	1139830	being CLI integration. Um, but we also saw that every setting had a corresponding auth tag,
1139830	1143830	which looked like a big random string that we assumed was protecting the integrity of the
1143830	1147850	settings through some authenticated hash or something like that. So we assumed this wasn't
1147850	1152890	gonna work, but we tried it anyway. Swi- switched CLI integration from false to true and it
1152890	1157510	just worked. So it seemed like these auth tags were here, probably secure, but they just
1157510	1163210	weren't being enforced yet. So we can enable CLI integration, great. Uh, but there's still,
1163210	1168950	some serious limitations here. Um, the first being that when you use the 1Password CLI, you
1168950	1172470	have to approve the session. So if you've used it before, you're probably familiar with this
1172470	1176430	image on the left, where it's gonna say your terminal is requesting access to 1Password, do
1176430	1184570	you want to authorize it or not? Um, and so what we saw was that your session basically gets
1184570	1189790	created based on the XPC messages that get sent when you run the, uh, OP tool. And the
1189790	1194650	session identifier is basically based on the PID of your shell, being the parent process that
1194650	1200230	calls the tool, and the start time of that parent process. And so, it'd be pretty easy for
1200230	1205790	malware on the machine to basically look for any shell that spawns the OPCLI, figure out the
1205790	1210070	PID of that shell, and then grab the start time of the process, and then you'd know a valid
1210070	1214190	session identifier and you could ride along with it, sending whatever messages you want with
1214190	1219550	an approved session. However, um, this, you know, obviously isn't optimal either because it
1219550	1224050	requires that there's a legitimate user sitting there really using the 1Password CLI having an
1224050	1232030	active session that you could spoof alongside. So we kept digging here, um, we, uh, saw that
1232030	1236610	in the client info JSON blob, there was a session type of CLI being sent when the CLI was
1236610	1242150	being used, and, uh, we were wondering if any other session types might be supported. We
1242150	1247210	disassembled the browser helper binary to take a look, and we saw that it seemed like the
1247210	1252070	string of browser could also be a valid session type. And this was interesting to us because we
1252070	1258130	hadn't seen this string being sent by, uh, the extension. But, uh, we tried it anyway to see
1258130	1261870	what would happen. We removed all of those other session identifiers that I was mentioning
1261870	1267250	before, and it just totally worked. If 1Password was unlocked, we were able to send a session
1267250	1272570	type browser, request the muck, and we were able to grab it. So that kind of completed the
1272570	1279150	chain of, um, injecting into an old client, sending XPC messages, and grabbing the muck. Um,
1279150	1284750	so you may have noticed that every issue we've discussed so far requires that 1Password is
1284750	1289730	unlocked. Um, this next and final issue we're gonna discuss does not require that 1Password
1289730	1295710	is unlocked. And it focuses on how biometric authentication is implemented. If you, uh, use
1295710	1299610	1Password on a MacBook, you're probably familiar with this. You launch 1Password, you provide
1299610	1305370	your fingerprint, it unlocks. Um, so a very common way that macOS apps are gonna implement
1305370	1311330	fingerprint checks is by using this evaluate policy method. And it's pretty simple. You call
1311330	1315270	it, prompts the user for their fingerprint, if they provide it and it's valid, it returns true,
1315270	1319870	otherwise it returns false. So what we did to make sure this method was in use, we hooked it
1319870	1325030	with Frida, uh, used the code on the right, uh, screenshot here, and just basically made it
1325030	1330130	always return true no matter what. And so after doing that, we launched 1Password, prompted for
1330130	1334550	our fingerprint, we could either hit cancel or provide someone else's fingerprint, and the
1334550	1341570	vault unlocks. So, um, you might be thinking, well, you know, if you're a red teamer, you'll
1341570	1345370	end up on someone's laptop, you can't just disable SIP and hook methods with Frida. And
1345370	1349230	that's true. But this taught us something really interesting, which is that even with an
1349230	1353470	invalid fingerprint, somehow, 1Password is grabbing the muck and it is decrypting the
1353470	1358450	vaults and displaying your passwords. So we wanted to understand how that worked. Um, and
1358450	1363610	also it's not obvious that this was gonna work just hooking, um, methods with Frida, cause it
1363610	1368290	is possible to protect items at the keychain level with flags that indicate a fingerprint is
1368290	1371650	required. And you wouldn't be able to just hook something with Frida and make that work
1371650	1375790	because the keychain would protect you with your fingerprint. So that was not what was going
1375790	1381330	on here. So how does it work? We figured the keychain was involved in some way, so we
1381330	1385170	opened the keychain access application and started looking around. And we saw that when
1385170	1389710	using biometric authentication, there were, uh, these items, or there was a item in the
1389710	1393710	keychain called biometric unlock, and it would be named differently depending on if you were
1393710	1398390	using SSO or not. And we saw that it could only be accessed by 1Password, so if it wasn't
1398390	1404070	obvious from the name, we knew it was, uh, being used by 1Password for biometric unlock. Now,
1404070	1408850	along with, um, the item in the keychain, there were these comments that were added, which
1408850	1414090	tell us that it's, the item here is encrypted by the secure enclave. And this tracked because
1414090	1417750	when we looked at what was stored in the item, it was just a bunch of random cipher text that
1417750	1422870	we couldn't do anything with. So, we were wondering where the secure enclave key entry is
1422870	1426950	because we couldn't see it in the keychain access application, we couldn't query it with the
1426950	1431410	security CLI tool, which is the built-in, uh, Mac OS CLI tool for interacting with the
1431410	1434710	keychain. Uh, so we wanted to understand where it was, what was going on and how it was
1434710	1441710	being used. What we did for this was hooked the sec item copy matching, uh, method with
1441710	1446050	Frida and logged the parameters passed to it and the return values from it. This method is
1446050	1451130	used to query the keychain and so we wanted to trigger the fingerprint unlock and see what
1451130	1455650	was, uh, being accessed from the keychain by 1Password when going through that flow. And
1455650	1461670	amongst other things, one of the things we saw accessed was a sec key ref or a secret key
1461670	1467470	reference and, um, that's what was returned and in the query was an A tag or an application
1467470	1473170	tag, uh, with those hex bytes you see in the top red box and if you decode those, you get the
1473170	1478530	string of com agile bits 1Password memory enclave key. So this seemed likely what we were,
1478530	1484790	uh, looking for based on the name, but we wanted to be sure. So, uh, we wanted to see if it
1484790	1489690	was being used to decrypt anything or decrypt that biometric unlock entry. Um, now secure
1489690	1493710	enclave keys, it's not the case that you just access them and then do what you wish with the
1493710	1498210	bytes. Instead, you ask the secure enclave to encrypt something, decrypt something, or sign
1498210	1502690	something. In this case, it, we thought it would be decrypting something, so we did the same
1502690	1506630	thing with hooking sec key create decrypted data, which is how you would ask the secure
1506630	1512070	enclave to decrypt something. And we logged the parameters and the return value and we do
1512070	1516850	see that that's, during the biometric unlock, that sec key ref is being used, it's decrypting
1516850	1521090	the cipher text that was stored in the biometric unlock entry, and in return we get 32
1521090	1525690	bytes. Uh, so we thought, 32 bytes, that's great, that sounds like an AES key, maybe that's
1525690	1531410	the muck. But it turned out it was not the muck, and we didn't really know what to do, so we
1531410	1537630	just took these 32 bytes and started trial and error trying to decrypt things. And, um,
1537630	1543810	finally, we found an item in the encrypted SQLite database called enc unlock key, and we
1543810	1550470	were able to successfully decrypt it with AES, and, uh, in return we got the muck. So, now we
1550470	1556010	fully understood the chain here of the memory enclave key and the secure enclave being used to
1556010	1560010	decrypt the biometric unlock entry in the keychain, from there you have a key that can be
1560010	1564590	used to decrypt this entry in the SQLite database, then you have the muck, which can decrypt
1564590	1571690	the rest. Um, so, now we fully understand this process, but obviously we can't just access the
1571690	1577250	keychain, um, on behalf of 1Password, unless we have a way to inject our own code into 1Password
1577250	1581510	and query the keychain, because those items can only be queried by 1Password. So, now we're
1581510	1589580	gonna talk about how we accomplished getting that code injection. Yeah, so, we needed to, uh,
1589580	1595340	have the 1Password bundle ID, and we needed to not invalidate the code signature. And, uh,
1595340	1602060	there's a relatively old technique on Electron where you can inject, uh, essentially the main.js
1602060	1607040	file isn't included in the signature check, and so you can just overwrite it. And to protect
1607040	1612360	against that, they added this enable embedded ASAR integrity validation fuse, and this was
1612360	1617280	enabled in the modern version of 1Password. Uh, but we implied the same thinking that we did
1617280	1621040	to the hardened runtime and went through all of our scraped old versions, and we found one
1621040	1625500	that was created either before or around the time when this flag was introduced, and it had
1625500	1630240	it disabled. Even if we couldn't find that though, there was this additional GitHub security
1630240	1634680	advisory that was a bypass to this fuse, and, uh, you know, if we couldn't find either of
1634680	1640760	those, we probably would have gone and hunted for some similar bug ourselves. So, we can
1640760	1645980	overwrite the main.js file, but that isn't good enough to do what we need to do. Uh,
1645980	1649500	essentially, there are no functions in Node.js that we can call directly that will let us
1649500	1653780	read the keychain and use the secure enclave, and so we need to call these native functions
1653780	1658580	from native code. And because of the hardened runtime, which is applied to this version of
1658580	1663000	1Password, we can't actually do the typical thing where you'd write your own library and have
1663000	1669360	the Node.js code hand off to it. And so, we took a step back and saw that in the entitlements,
1669360	1674380	uh, there was this Apple security allow JIT entitlement, which essentially means that
1674380	1680100	somewhere in the process it would be okay to have a read write execute page of memory. Once
1680100	1683960	we saw that, we realized a browser exploit would probably work, and so we found an
1683960	1688900	applicable CVE that was exploited in the wild. We did the standard browser exploit things and
1688900	1693380	got our JavaScript heap and read write primitives and used that to run shellcode by
1693380	1697900	corrupting a WASM object. I'll show you a video of that in a second, but I also wanted to
1697900	1701700	call out that because we're not in a renderer process, we can kind of cheat a little bit with
1701700	1706300	ASLR by just running VM map outside of the process and then directly writing all the
1706300	1722440	addresses we need to a file and then reading that file into our exploit. Alright, so
1722440	1728400	hopefully you see that, it's on the monitor. Yeah, so in this video we're just adding a
1728400	1732940	demo password that we're going to extract. Uh, we're adding it right now, then we'll show
1732940	1737460	you that SIP is enabled, and then what we're going to do is run a make file. And that make
1737460	1741740	file is going to compile a C program that prints out some function addresses in the core
1741740	1746140	foundation library. The reason this is important is because we need those functions, uh, but
1746140	1750220	we didn't want to do the work of adjusting the ASLR ourselves, and these functions are in
1750220	1753860	the shared cache, so we can just print them out and the addresses are the same between
1753860	1759820	processes. That print is going to be used to generate our final ASLR adjusted, uh, shell
1759820	1765300	code in JavaScript, and we're going to start the old version of 1Password. The reason we do
1765300	1770760	that is because on the first run, a deep signature check is going to be performed, uh, but we
1770760	1776480	can just start it, kill it, and then run it again with our modified main.js, and because this
1776480	1784480	fuse is disabled, and only a shallow check runs, we can run our browser exploit. Yeah, and
1784480	1823240	so there it is. We'll show you that the password matches. I think it's up. No, I'm not good. Oh
1823240	1834900	man, this is the hardest part of the talk. There we are. Okay, so this is the di- oh man.
1836520	1840520	So this is the diagram of what we essentially did, and I think it's important to call out here
1840520	1845260	that although, obviously 1Password could have used that enforcement flag, uh, but for
1845260	1848860	everything else in order to get that native code execution and actually exploit it, we
1849400	1852940	essentially just waited. And you know, we scraped the old versions, but the
1852940	1856980	vulnerabilities were in Electron and- and Chromium, and it can be really hard to secure that
1856980	1863040	when you're releasing new versions, uh, every day. And so here's a vulnerability summary of
1863040	1868240	what we reported. Uh, this is a little bit, uh, there are a few more vulnerabilities here
1868240	1872440	than what's going to be on the next slide. The reason that is, is because the initial
1872440	1877000	XPC entry vulnerability is really what needed to be fixed, not the other stuff that we
1877000	1882180	talked about with the session writing. And we also reported the, uh, Chrome managed policy
1882180	1888640	bypasses to them, or to Google rather. And so here's an exploitability summary. Uh, I think
1888640	1892940	it's important to call out that SIP doesn't prevent this and root is not required. Low
1892940	1900340	privilege malware can perform these attacks. Uh, but, uh, the main issues that 1Password was
1900340	1905400	able to fix are- are highlighted in green. And so the XPC bypass was fixed, the biometric
1905400	1910600	enforcement flag was fixed, and most importantly, the settings modification is now being
1910600	1915520	enforced. And you might say, well why is that important? It's important because the first
1915520	1920320	two currently exploitable issues are not exploitable if you just disable that setting. And
1920320	1925040	so while it might degrade the user experience a little bit, you are fully protected with the
1925040	1930480	newest version of 8.10.38 which was released in August. Now the- the browser extension
1930480	1935280	injection and impersonation, like I mentioned earlier, that's not really a- a bug per se,
1935280	1940600	it's kind of just how browsers work. And the browser support get PBID bypass is a little bit
1940600	1946120	interesting because there's not really a clear line of ownership to the issue. Uh, so 1Password
1946120	1950640	can't really securely look up the code signing information of their parent process. It is
1950640	1957520	true that all browsers could maybe switch to XPC to provide that audit token. Uh, it's one
1957520	1963140	available method to perform inter-process communication with uh, or on Mac OS rather. But
1963140	1967140	it's also true that Apple might be able to provide some way to look up your parent
1967140	1973700	processes code signing information securely. It's just not super clear who uh, who needs to
1973700	1979540	go and fix this. And so, because you can't really fix those things, we're going to talk
1979540	1984000	about how to detect them. So, I pulled all of these bundle IDs from the browser support
1984000	1988580	process. These are all the chromium based browsers that it will accept as a parent
1988580	1993200	process. And these are the non-chromium based browsers that it will accept as a parent
1993200	1998840	process. And so, for the uh, extension injection and impersonation, those are relatively
1998840	2002980	straightforward to fix. Essentially, what you have to do is go enumerate the dangerous
2002980	2007380	flags, which I've done for you. They're highlighted in orange. And you just need to alert
2007380	2011520	anytime those flags are used. Uh, we also, out of an abundance of caution, are just
2011520	2014780	blocking the developer builds of certain browsers because they have a slightly different
2014780	2020980	front model. And for the browser support issue, again, if you just disable that setting,
2021580	2025640	you will be fine. Uh, I can tell you personally I'm not going to disable the setting. I like
2025640	2029820	using the browser extension. And I think having malware on your computer is already a
2029820	2035300	pretty significant bar. Now, uh, if you don't want to disable the extension like me, here's
2035380	2041000	a, you can alert on it. Uh, basically during normal use, when you click a browser icon,
2041000	2045760	what's going to happen is LaunchD actually spawns that process. And so, if you just set an
2045760	2052720	alert for anytime a browser, uh, is spawned and the parent is not LaunchD, it's likely
2052720	2057520	malicious or it's going to be some kind of headless browsing. And you can usually limit
2057520	2063800	that to the people that need to do that at your company. Probably QA teams. And a malicious
2063800	2068700	actor might look at that alert and, and try to get around it, right? By getting LaunchD to
2068700	2073440	spawn their parent, uh, to spawn their exploit process and then execing indirectly. And so
2073440	2077880	what you can look for there is the exec. Uh, the, the point of looking for the exec is that
2077880	2082220	there are a couple different ways to obscure or, or, you know, move around those read write
2082220	2088340	pipes. You don't have to use the process tree that we showed you here. But at every, um, for
2088340	2093540	every actual exploit, at some point they're going to have to exec into a trusted browser. And
2093540	2098420	so, that's what you will, uh, would alert on and it looks like PID reuse in LaunchD child
2098420	2104200	processes. So here's our full disclosure timeline. We reported all the stuff that we found
2104200	2110000	initially in January of 2024. And then we followed up on March 8th and reported, reported
2110000	2116120	that the biometrics flag was missing. And we actually weren't convinced at the time that it
2116120	2120340	was going to be exploitable in practice. And so we put together a proof of concept and gave
2120340	2124480	it to them on March 22nd and that confirmed for both us and 1Password that this was going to
2124480	2131660	work. Here's a remediation timeline. Again, the, the browser support fix is unclear but you
2131660	2137660	can toggle that setting. The XPC bypass was fixed in April. Uh, the settings file
2137660	2141780	modifications, this says it was scheduled to be fixed in August. That version is out now. We
2141780	2148140	just submitted the slides before. And the biometrics flag issue was fixed in 8.10.36 and
2148140	2153820	they followed up in 8.10.38 with just a reliability change. It was actually fixed in 3.6
2153820	2162680	but I would just recommend upgrading to the, to the latest version. So here is where you can
2162680	2169760	find the code we've released at, uh, morganc3 slash 1Password exploits. Um, as of now, we
2169760	2174680	released, uh, the Frida scripts we used while doing some of this research. Um, none of it is
2174680	2179480	really specific to 1Password at all. Um, it could definitely be extended and useful for
2179480	2184620	researching other applications. In terms of exploits, the only thing we've released is a
2184620	2189740	proof of concept for the XPC validation bypass issue. It's not going to decrypt your vaults
2189740	2195240	but rather just demonstrate the issue. Uh, in the future, we, uh, will add more code here
2195240	2199920	once ample time has been given for people to be upgrading their 1Password to safe versions and
2199920	2206780	for the other issues to be fixed. Um, and yeah, we may have some time for a few questions if
2206780	2232830	people have them. Sorry, what was that? Yeah, we, we took a look at them. Um, I would just
2232830	2253060	say any, okay, sounds good. Yeah. Any other 1Password managers? Yes. It was just us over the
2253060	2257860	course of about a month. And the, the guy to your left helped us a bit with the last
2257860	2272580	coolest vulnerability right there. I'm, I'm so sorry, can you say that again? Oh, just we
2272580	2277100	wanted to know how safe our passwords were. You know, really the detections, I would say are
2277100	2281900	the most important part for us. And I would say practically we expected this as, we
2281900	2286120	expected this as likely possible with, you know, most major password managers or similar
2286120	2290260	attacks. We wanted to do it on 1Password because we use 1Password and we wanted to use it
2290260	2306640	on red team operations. Um, and then of course get the issues fixed as well. So, uh, we, we
2306640	2311140	took a brief look at other password managers, but this was a significant amount of effort for
2311140	2316500	us. And so you can imagine that we wouldn't want to do the work, uh, especially on, you know,
2316500	2328370	work time if, uh, if it wasn't going to pay out on a red team. All right. Thank you.
