Nicolas BACCA - SECURING DECENTRALIZED EXCHANGES WITH HARDWARE WALLETS

ETHCC 1 · 10 Mar 2018 · 18:12

Nicolas Bacca, co-founder and CTO of a hardware wallet company, explains how hardware wallets can secure trading on decentralized exchanges. The talk covers browser integration through U2F, WebUSB and Web Bluetooth, and the attacks that remain: fake websites, wrong contracts, wrong tokens and misleading orders. It also discusses trusted registries, EIP-712 message signing and small contract-specific apps on the device, and invites community input.

Speakers

Topics

From ETHCC 1, hosted by Ethereum France.

Transcript

okay so good afternoon at DHCC I'm Nicola Becker CTO and co-founder of Fletcher and today and surprisingly I will be talking about hardware wallets and most specifically I will be talking about how we can use hardware wallet to have an decentralize exchanges so that will be mostly a list of issues I have run into while trying to do so a few solutions and a lot of open questions for everybody that we can discuss after or later tonight during the nice party that I said will be organizing so first a reminder I mean just in case people here don't have many ads I'm not very familiar with hardware wallets so the goal of hardware what I did to protect

your private keys because if we look at the traditional user computer on the Left it's not very well protected and it's not in a very good state so you want to protect your assets your private key against people that may want to steal them or against people that might want just to corrupt what you are doing for whatever reason for fun hotspot or anything you have plenty of ways to corrupt your actions on a tearoom because you are interacting with smart contracts and basically the goal of the hardware wallet in that case is most not just to protect your keys but the hardware wallet must tell you exactly what you are trying to do and how you are trying to interact with your contract so an atrium the hardware wallet as a specific functionality of letting you know that you are doing the

right thing so for example here if you are playing a dice you want to know that you are willing the dice you don't want to be performing any other action so the hardware wallet should be smart enough to let you do that and that's one of the reason why interacting with decentralized exchanges is interesting so why so first because I think the architecture of the centralized exchange is pretty interesting by itself so it's kind of the ultimate step into the centralization today we have a lot of we have a lot of system so most of the exchange a centralized we have a few eBridge system like at Phoenix for example using the liquidity of centralized exchanges with peer-to-peer aspect of decentralized exchanges we have fully decentralized exchanges like

us who apps your eggs also we've seen that who isn't before so the architecture is interesting and it's a good match for hardware wallets because how do our wallets I mean to own your keys and couple with the centralized exchanges it would be a full way to trade freely you have your keys you have your transaction and you can check both and yes another thing is that it's an interesting problem because it brings a lot of new user BDC problems that can help how do i wallet making be better and it can improve hardware wallets for all kind of contract based applications so first you need to want you need to have your hardware wallet interacting with your decks as easily as possible which means it should be transparent to integrate

your hardware wallet into your browser then you have to provide clear information to the end-user you want ideally to visualize your trade or the action that you are performing in a very clear way and you want to prevent creative scams because decentralized exchanges and smut contracting all can open the door to a lot of very nice scams so today we have only seen I would say very common or boring scams but I will get a bit more into the different security issues that we have and we see that there is still a lot of potential for people who would like to steal money so where are we today so first maybe to start with what we have accomplished so far so mostly thanks to the ATM community because we provided the api's

but everybody has been doing the integration by themselves so thanks to everybody here so we have been integrated into the 0x protocol and relay O's so basically an integration into this your HTS library and then having the Elwha wallet playing fine with all the websites so we are in the into baddha relay products DDX and we have been integrated into other specific exchanges which have their own protocols with a delta Qyburn ID exit so i might forget a few people so sorry about that no people are working on it so why are we here today we are here today because we have a nice JavaScript API that people can look at and that will let you

integrate hardware wallet into your that very easily so the initial integration was done I did it for my ETA wallet about two years ago it has completely changed thanks to guy Tom who has been repackaging our applications into something that looks into a proper JavaScript project so if you looked at it in the past I would suggest giving it another look because now it really looks very nice I mean it's completely different so we have a sub provider if you want to integrate into something like meta mask and copulate with another web 3 provider and we have a starter kit if you want to design your own application and you want just to access the hardware wallet so you have with those two links you should find anything you want then why are we

working so why are we working fine with a browser today so first on we are looking to have a plug-and-play integration into the browser so if we look a bit into the standard we started from something completely different so we started from u2f u2f is supposed to be the model infeasible protocol which is based on a cryptographic challenge between a website and a physical token so it's all things that was developed by Google or in 2012 I think the idea that you have to set of six you have to set of messages a registration where the device is generating a private key and returning the unencrypted private key to a server so which means that you can have an unlimited number of website

handled by a simple token and then an authentication where the token is performing a challenge against what the server would be asking so you will be sending the private key encrypted to the token token will decrypt it sign the challenge return the signature so here from there you might wonder how are we talking to a hardware wallet using that kind of protocol because that an authentication protocol that not something to correspond contract so here is the catch we can use on the key handle here which is just an encrypted blood to pass a comment and instead of facing nature we can send back a response so by doing that we managed to add a simple hack and the u2f protocol

and turning it into a kind of a proxy eternal to be able to talk to any kind of device so there are just two bags so first it's a hack so it might be removed but so far it has been working well for more than two years we have no events when the device is connected or disconnected which is kind of a limitation if you want to perform if you want to have a nice UX but we can still work with it and on the plus side the application ID is a browser guarantee the hash of the web origin you're currently browsing so we see where we can use that but it's very well it's a nice feature to add because you basically the device knows where it is on the web and we can use that to

provide more information to the user so that's what we have today in the future we want to move into standards which will be a bit most on that so Web USB will be a good start so Web USB is not a hack so it's a proper protocol to talk to a USB device on the web it will have mobile support so at least on Android you will get device connected and disconnected events but you lose you lose the web origin and I would say that Web USB had kind of a bumpy start so far so it has been integrated into Chrome it was disabled recently because people realized that it gave a way to access you to have two tokens some kind of u2f

tokens differently so people managed to fish the unfishable protocol using web USB by basically connecting to an interface that was not enumerated and accessing the u2f applied in a way that was not supposed to be done so basically changing the origin and another way to move to a plug-and-play browser integration will be the web Bluetooth protocol so for different kind of hardware wallets that will be able to communicate with mobile devices so when we do that we have basically a protection of private keys when we want to transact but there are lots of other attacks that can be done under the centralized exchange so first we can wonder if we are interacting with the

right website so that the simplest kind of attack then are we interacting with the right smart contract what can be changed on the contract itself and the token will be swapping the website will be swapping tokens but are we interacting with the right token I mean can we be fooled into swapping something that we didn't want to swap initially and then a more specific attack on the protocol itself when we're interacting with the smart contracts are we really passing the right message for example 0x is based as a protocol to define orders what happens is though if those orders are different and how can we display them properly on the hard

wallet so first integration with what with the right website this has been a source of attack in the past so for example with the tail Delta which was the DNS was changed when the website was required and well it was a very simple attack but people managed to collect private keys so u2f here can help if we look at the application ID because it means that we have a way to if we're able to make them that between the hashes and the website see hardware wallet will be able to display the information and we'll be able to verify that we are really interacting with each other for example problem is that if we do that then we realize quickly that we need a trusted store of web origin

hashes and well for people who have been watching that TCR talk yesterday so for them talking curated registries they have seen that it's an open problem and unhide what device it's even harder because we have in a way I mean if we want to have a trusted source something we would basically need an external party to do it to sign it and to pass back the token to the hardware wallet so not very convenient then how do we verify that we're interacting with the right mat contrite so on that ENS can help on the host because we can map names to smart contract addresses but if we want to validate TNS on the device and it's more complicated because of

course the device has no real access to the blockchain and cannot really verify the state of any honest name another problem is that TNS is not going to prevent current attack on website which is post-wedding so if for example you have a delta and somebody's which is virtue stirring at a delta with 2l or 1 e replacing the L it's not going to help a lot so again it looks like we need another two assets or but this time that can run in jihad wallet also and mappings not contracts to their names now interacting with a writer can again it's still a naming problem so token is

represented as an address we need to have a way to map token names to token addresses so I know the trusted store starting to get well a bit boring here now how are we going to verify that we are communicating right with a smart contract so for that we need to validate the EBI but validating the ABI on the device itself will provide a very Pro UX because we don't have a very specific name in the ABI and people don't want to read binary so you don't want to verify when you see a trade you don't want to see the exactly see more data that you are passing and validating what you're doing so here you might also need

another level of abstraction when you interact with a contract for example a blob can be a message a blood can be another or blood can be an address so how are we going to display that and the hardware wallet and what kind of specification can we had for that if we look at the argument of the smart contrite let's say we are going to sign a message so if we sign a message there is an EIP for easier message message signing where you can pass on the argument of the message and verify that you are correctly signing the right argument so you would get an information for example that this field is the string this pill is an integer and displayed that way instead of displaying a binary blood but

here we also have a UX problem it's still too low level typically there is a field in the SEO exporter call probably not very visible here but there is a time at some point the time should be represented in a way that is readable by the user so do we want to present an absolute time do we want to present a time related to transition do we want to do we have a source of time in the wallet itself so you see that in that case trying to make something generic is still very hard so proposal for that reverse AB it's a problem and think that we won't manage to create something that is completely standard to display what the contract is

doing and to sign messages and turn into small applications that we can basically provide along the DAP which will be loaded into the hardware wallet adding so just adding a few additional trusts to the different a woman wallet manufacturers so here I said ok we have to have a wallet manufacturers of course we can have more and they will just provide it or additions so first they will manage a trusted star of token so they can give you an association that will map the token to a name and regarding the code they can give permission to the contract author to write an application that will handle transaction specifically for his contract and that can sign messages that

are matching the EIP seven one two description so that means that here we provide a responsibility from the hardware wallet to the DAP developer to create a small application running and the hardware wallet that will be responsible for signing transaction going to this address messages are mapping the specification but leaving a full UX rights to the developer so that way we can imagine a set of small application that will be loaded along the DAT and on which people will just be able to handle everything regarding the UX while interacting only in the scope of the comte right so this is an

addition this is an additional protection I would say to what exists today because today so add wallets only running application signed by the manufacturer typically here we would sign we would sign we would run delegated rights for application related to specific contract so what would we know what would we need for that dynamic application management and the hardware well at first also that's something that we already have in our infrastructure and that's going to be I think not too hard to make with third-party architectures for example a lot of people are looking into bitin today if you want to make something like this in baton you won't be able to do it directly with the script but we could

think about a long wait running on top of Python which could describe that so the issue is still to map a UI to different devices because other wallets can add very different UI's so some will have a screen some will have a touch screen some will have a cross screen some will only have a few LEDs few buttons so it's better if that part is native and still belonging to the hydro ballot manufacturer but that's open for description if we want so not as API what do we want this application doing so it needs to sign things for sure but does it need to do more to still open for description and what kind of language can we have for that so python

can be something to look at still a bit complex to run for some architectures something else so still open for discussion today with our architecture we can design third-party application in C so that what we have been doing for few decentralizing changes we would have some things to show on that so shortly I would say in the coming months and so we would have those that let running around along the main interim application and able to display specific messages are regarding regarding the spot regarding the decks which is currently running so well in our architecture we just design applications that way that's fully

opened for description for other architectures of course and well we're interested to think about ways to describe how those small application could look like and if people would be interested to run them on other media's so thank you [Applause]

Related talks