Breaking Digital Asset Custody Solutions

DeFi Security Summit 2023 · 16 Jul 2023 · 19:03

Hossam Mohamed, a senior security architect at Halborn, explains how the custody platforms used by banks and exchanges can be attacked. These systems rely on MPC, threshold signatures and multisig rather than a simple wallet. He identifies four red flags: custom cryptographic implementations that diverge from the published paper, no trusted execution environment, a trusted execution environment without context management, and C or C++ code that exposes memory corruption bugs. He also draws on vulnerabilities Halborn has found and disclosed.

Speakers

Topics

From DeFi Security Summit 2023, hosted by DeFi Security Summit.

Transcript

uh hello everyone so we're going to talk today about uh breaking digital assets costly solution okay so yeah I'm more intro about me I'm senior security actor Holborn uh my backgrounds were in realty research and offensive Security operation over like seven years uh mostly like iOS on Windows in terms of vulnerability research and red team

in terms of events of security right now doing r d Holborn and yeah rounding around and stuff you can follow me on Twitter uh yeah so more about us Holborn we are like specifically as r d we have found like some zero days all of them a lot of vulnerabilities this is one of the most two famous One World since we have disclosed recently uhm is quality and the one I personally found is the Dogecoin variability which is effect also 280 Network uh yeah that's what the brands we are working with yep so today's agenda we're going to talk about what's the digital asset

security cost to these Solutions uh we gotta talk about uh NBC some cartography stuff and we gotta talk about uh real vulnerabilities and this original presentation has been like for one hour long presentation but it have been like squeezed to just for the timeline we have today uh so like was the Axor digitalized sarcastic Solutions like Bank Source centralized exchange they're not holding their assets differently like in minimasualis or their own self-castell wallets they have like a more complicated procedure to execute large transaction let's say to move like from Treasure to another one and they are using technically something called like casting Solutions uh

this is just a market overview I believe that this slice is really out of date because right now the market value is really different than the one we are seeing here uh yeah so what's the difference between your minimize quality or your self-castell wallet versus like a really Enterprise great kind of digital asset capacity so your wallets like small amount when we talk a small amount it could be like some few millions of dollars that's considered small amounts for the amounts operated through costly solution Enterprise great Plastic Solutions for big financial institutions uh simple cryptography initial signatures it could involve like some

multisex some simple multi wallets uh you're using it like normal users are using it like not financial institution that's a crypto exchanges and stuff like that but for digital custom Solutions what banks are using it like this is where banks are storing uh their digital assets like Bitcoin source is or any kind of curved currencies and also like centralized exchange so like when they're holding their liquidities and stuff like that uh the transactions is like more frequent large amounts it could be like a billion of dollars some cases in terms of the cryptography behind that custom Solutions is mostly like MC

protocols uh through your whole signatures keys and other complex cartographic protocols we're going to talk about each one of them so yeah it's simple as that like when you are in shape and transaction from yourself Castle Wallace is just like a few buttons maybe you're entering a password but for a casting solution like I have seen something close to that one like kind of casting Solutions where you have some people like required to enter a specific room use like specific laptop or an iPad to assign a specific transaction and stuff like that there's also procedures like for that mostly for financial institutions so yeah there's stuff like that for this should uh

uh so why we should care about digital casting Securities actually like the digital casting solutions they are designed for Securities like to provide security Force digital assets so that like I would call them like uh a security product or a product have been built with a lot of security consideration would make it like really hard to break uh but let's assume like two following scenarios like on web to space and web series space and web to space uh we are breaking into a financial institution we are getting access we're becoming like domain admin stuff like that we are compromising like the sun guard or this app start to craft like some soft messages yeah that would work like 10 years ago but right now it's like more complicated stuff like

yeah when attackers like games that much access and they start to actually craft uh this kind of messages yeah there's a lot of precisions action responses like it will not work uh that much easy but on web3 like you can just like gain control over the infrastructure and this is definitely optional because you can do like some tags some smart contract attacks if smart contracts are part of system you can compromise like the key materials or the private keys and like just sign your transaction send your transaction and all of your funds come it's much easier in web3 that's why like three actors nowadays are focusing on more attacking like kind of

work through institutions and virtual reality stuff other than regular financial institutions because it's really easy to make profit over some so yeah that's like a kind of uh compromise scenario of a normal let's say a centralized exchange they're not using any kind of gasoline Solutions so the attackers just compromising the operation machines and the operation machines interacting with the backends to handling the private key let's say and sign kind of some kind of transactions and they just send this transaction broadcasting it to bitcoin node but in a secure scenario or like oh where is that exchange using kind of

casted Solutions so we will have something like this one's a function inside is like the cast solution let's say or like the multi secure competition or whatever so when the attacker is trying okay I want to shade to request for transferring 1 million dollar there's like kind of a part of the Constitution it's like kind of a policy manager we'll talk about this a regular policy manager will like give some alerts and shades on NPC and start to like paying people they have been transactions we will just like kind of okay we're just satis action it's not us and yeah it's attack will fail or the attacker will be like not

really will take the money out uh so yeah the core functionality of casting solution is like MBC or TSS or more signatures are not all the same definitely so like the NPCs use like a multiple parses coming together to compute a value based on like uh private inputs a TSS is like a distributed K generation and the mild signatures like just logo mod signatures we are using almost like everyday and our curve to life where we like a group of people trying to authorize a specific transaction so I will talk a lot more about NBC

because NBC is like the core part of a castle solution but definitely there's a lot of other things related to custom Solutions like as communication channels but as a core saying is happening uh inside The cryptographic Primitives offers solution which is uh mostly based on NPC so NPC is not like an actual cryptographic broker but it's more like a hashing like when I say hashing like to resolve functions can come to your mind to make the actual hashing it's the same for embassy you can you can employ like multiple cryptographic parameters to build like an embassy or multiple competition so it's early in 82 like some historical stuff and the NPCs that when

cryptographer actually starts to talk about NBC it wasn't really about cryptocurrencies and digital assets security or digital transactions because that time they didn't have a kind of the stuff so some research yeah definitely they're not like publicly classified informations but most of like the embassy research paper was related to some military activities that time when there are like color launching missiles and stuff like that so nowadays we have like really common papers for the digital assets security like people who's building like custom Solutions this is the most top protocol I have seen when people are implementing their own classes or the classes that

have been auditing so like GG okay or bus General golf header that's the most common one I have seen and DMZ I don't know what's DMZ stand for but there's a lot of open source library is using a DMZ paper implementation so uh not about like when you start to the end like the GG protocol or the G implementation you will see like there's a lot of a research tap down like attacking this protocols actually and there is no one attacks but people like for example when you just like grab this Rebel or you're trying to implement your own protocol uh you're not going to really like

scroll down to all differences I know okay yeah definitely you will check the security because there's something security but you will not read each like kind of research paper that's really time consuming but there is a lot of learning attacks on this YouTube protocol but it's still commonly used is it twine boxes let's say because for example when I'm getting an artist they're using like GG broker I'm not saying GG protocol is not secure but uh yeah it's more common to find implementation or other call uh so ways like to do like the embassies it can be done like through the secret Choice sharing schemes like customers

like sharing social secret sharing and other cultural cryptographic Primitives you can't just pull together and create your own MVC like if you're a cryptographer I I don't recommend you to do that definitely uh so what you need to break a decent uh additional asset security solution so you need to like have a breaker mindset read some codes some masses required I do believe understanding like additional signatures definitely but yeah I mean the actual core of casting solution is more in terms of cryptography stuff but you can still break a custom solution like attacking their like web interface or

the API interface or other stuff yeah this can work but you can also attack the cryptographic bars so uh trust no one every component inside the actual casting solution is let's say is a vulnerable because like this modeling of a customization is like should be kind of completely different other than a normal software because for example you don't even trust your CPU or operating system and we're going to talk about that in a moment uh yeah work however if you want we are hiring if you're interested in as if you can pay me after the talk so yeah we're gonna talk about a red flags when we are starting like kind of

Engagement with auditing digital cassidies so the most common Red Flags uh is and by the way is this what like this flag that has like some real scenarios but I have just squeezed it because of the time so yeah we are coming we are running our own implementation of the cryptographic protocol or we are started our own empty implementation or css implementation that's the right flag and we're going to talk about this in details we don't have securing claim or traffic execution environment or uh okay we have the securing Clays we have HSN uh hsms we have but we don't know like the context management and domain management

CNC plus plus and or remember station oh unsafe memory languages so we have like first scenario we are running on our implementation we are running our own implementation could be like closed Source implementation or could be an open source as actual argue his retina it's not related to whatever it's open source or closed Source implementation uh it's just like their own implementation because most of the people they don't have access to like Rockstar cryptographers will be where they will be able to implement the recall like error free or bugs free so that's definitely kind of a red flag and requires definitely more work from you in terms of all that in terms of securing this product because it's me you're gonna read and inspect a lot of

code so how you break that or how you solve that so you need to understand the actual protocol like you just drop the client code and go understand the actual protocols they are trying to implement towards the actual paper yeah definitely reading research papers is not that much easy like definitely if you're on like a cryptographer but I I do believe like having the basics mass of computer science level math you will be able to understand those uh the paper but yeah if there's some parts of like printer mapping for example like you don't understand that you just go ahead and Google it like your internet age you don't need to go to the librarian look at fat box yeah so review the implementation try to identify like the

core points of the implementation like for example the key generation flows as actual protocol steps verification and signing and once you spot this team entry points you will go and identify the same entry points in another implementation of this protocol or open source implementation of this protocol you might and I find them but right for example if they're using a for example there's other implementation of protocol for instance are using like a different entire different curve so you will start questioning why is these people and their implementation using a specific curve and you might start the client asking click on some questions and you might come up with the finding uh

so the other one is like we don't have securing claim or to asset execution environment and this is like breaks the actual idea of a custom solution because it's mean you're running your your processing your Q materials or your private keys or your cryptographic operations on power machines I would say or uh for example if someone come from my zero machines they can just dump your private keys so like there's kind of no security so you don't need to break it because it's already broken so there's no casting solution or a kind of AMC running outside of trusted execution environment that's completely broken thing uh okay well we have like trust the executor environment we have like

securing claims but we don't know how to manage the contacts or we fail to manage the context uh management between both of them for example we are doing like kind of uh we are extracting the key materials from the secure enclave and we are processing them into like how the web app or the API and we keep them like we are not the residing the values or whatever so the key can be extracted around time in case of the compromise of the untrusted domain and the Andreas domain is say let's say like okay all of your cryptographic stuff are inside the source execution environment or secure Enclave but the attacker gained access to your like uh we went over interface or

is that web app container or does it start like QR already dealing or you're executing some calls to your securing claims and you are keeping your private Keystone like in a variable or whatever so that's where you are failing to manage the context between the securing clay broadcast the execution environment and your untrusted domain which is like the interfaces or your apis oh so you're like CNC plus plus like that's a like CNC plus plus using uh non like a memory safety issues is really common for example at the communication level because it will help you uh exploit the untrusted context let's say uh maybe that will lead to further

attacks but definitely like most of the cryptographic Brokers are usually implemented in two languages that have privacy it's like scenes build Plus or a rust there's like some type of scripts but it's not really common but most of them like our CNC plus plus because people are just getting on shelf cryptographic Primitives from other libraries and they start to use it in their own implementation so also like academic people are more comfortable writing in CNC plus plus code so it's more like you're starting to a kind of as a message processor or the massage Parcels communication person and CNC plus plus as well so I have seen

like some issues related to that one where you don't need to attack the actual cryptographic protocol but you're just attacking the memory safety of CNC is worthless like all the communication broker causing like some hip overflows in the case I have uh so like how to break it just exploit some memory Corruptions because there I I don't think there is any advantage or for the attackers to see inside CC plus inside custody solution other than memory corruption vulnerabilities because yeah it's definitely so like some cryptographic flows that's an entire different thing uh yep so that's all for today any questions so far

complicated topic right okay thank you