Ethereum Flavored Packages
ETHCC 3 · March 2020 · 32:00
Philipp Langhans discusses Ethereum Flavored Packages.
Speakers
Topics
From ETHCC 3, hosted by Ethereum France.
Transcript
hello everyone my name is Philip Blanc and I work for the Hume foundation on should I use the microphone okay hello everyone my name is Philip Lankans I work for the Hume foundation on the JavaScript team and I'm going to talk about each package if Hume flavored packages today so what are packages packages sometimes also called archive files container fires usually of the extension zipped are they can be gzip ASA jar files apk files android applications all of these are packages and when I did the size I thought okay that that sounds like a really dry topic
and I try to spice it up a little bit and I hope it works so why are packages so cool you can put different things in them so they're very versatile you can put images in them binary files metadata fires source code everything you can think of and that makes them really easy to share and to transport things you end up with one download link you can attach it to an email and it makes everything much easier if it's contained in a package it also becomes easier to do management of these packages because you end up with this kind of snap snap shot and so a certain state or for example your software project can be captured by
one package and then you can do version management and dependency resolution and all of this you can encrypt them if they contain valuable information and they can be signed and this is the the most important part and because they are so cool there's already a bunch of formats for packages so if um flavored packages format 1001 no we only focus on the signing aspect you can take whatever package format you want to use and make it an easy room flavor package so this is only relevant for for sign
packages but before I jump into the solution I want to really stress why it's an important problem to solve and to understand this we should first look at traditional file signing not just not package signing but only like one file and we will use Manero as an example I hope no one from owner OSI or maybe they are okay so you want to avoid this basically you want to sign your stuff because you don't want someone else to replace your binaries and then have the heavier users hecht for example this is what we don't want and this is why we use signed packages for example all signed binaries so how does it work what do we have to do the first step is we
take our binaries and we calculate the hash and then we have binaries and we have hashes and then we can publish our binaries so we upload them to our web server make a nice use interface for everyone to download and then we do the same for our hashes we upload them to our server we have these nice like hashes for all the binaries okay step 2 we create a lot of instructions and warnings so on the left this is actually the screenshot of the instructions what you should do with these binaries after you downloaded them so first you install them more software and then you import signing Keys and verify hashes and you verify binaries and then also warnings are important strongly advise to verify
always verify your downloads so what is the problem with this okay so the first problem problem is you upload the binaries and the ashes probably to the same server and if an attacker gets access to your server they get also access to the hashes so what is keeping them from just computing new hashes and replacing your hashes but the new one of the modified binaries the other problem or they don't do it this is actually why it was discovered so it was sitting there the modified binaries were sitting there for quite some time but the attackers forgot to change the ashes and then add I don't know how many weeks after someone
it actually and he was like this is not what I downloaded and then it got uncovered yeah that's funny okay the second problem is exactly this no one does the checking of the binary is no one is following these instructions this is way too complicated so you end up in this situation where you should do something but most of the time it's meaningless and then suddenly it becomes super important so it's a really bad situation and this makes security really hard for not only for for the users of the software but also for the developers to get it right it's a really hard problem and I don't want to to blame more narrow this is this like many more
more projects teams people that there are doing this okay so that one of the solutions could be we take our binaries and maybe the attacker has access to the to the server but then we upload the hashes to a different server and and the problem solved right but we still have the issue that now the user has to look up hashes so the user has to download hashes for edie binaries from one one address now and then they have to go to a different address and download the hashes and then go through all the steps and of course maybe there's a typo maybe they're not going to hashes calm but hashes dark or whatever and this is attacker controlled server and there's
many more scenarios where this goes wrong so this is not a not a good solution okay so we can sign the hashes this way it doesn't matter where where they are uploaded because in the end we can always just verify the signature of these hashes and then we know okay it was not modified the problem here is in order to verify the signature which is on the bottom here and this is actually what what Minerva is doing no they're signing there it is this is the actual screenshot okay now the steps of like like the following to verify the binaries you go to the github server you don't know the the key and then you verify the key with a fingerprint that
is coming from yet another server and then you get the hash file you verify the hash file you get the Monaro binary you calculate the Monaro binary hash using the same algorithm that they used you compare the hashes with a sign - and then you profit and still not solving the the situation that potentially you know one will do this okay now let's talk about package signing what's different here if we talk about signed packages everything is contained in this archive format so you have all the files that you want to sign inside the package and then you calculate the hashes you sign the hashes and then you place two more entries into the package and you have a signed
package and of course if you calculate the signature and the hashes you cannot do this for your signature and hash and edges that you placed there and this is a problem again because now if someone wants to receive the package which is signed and we have a man in the middle but the person could also have access to the server then they can just take these files and replace for example the signature with their own signature and instead of fluffy Pony is the name from the Monaro team it could be puffy pony and no one would notice and this brings us to certificate authorities so how do
how do we solve the problem of who created the signature and we have a we have a we already have solutions for this and they are based on mostly digital certificates and certificate authority a digital certificate is only it only binds an identity to public key so that we know okay the person who signed this package also has is this this person in real life and the certificate authority is just an instant and an entity that issues these digital certificates so how does it look like at the moment if you want to go through this process okay let's assume i we have ellis ellis has a public and a private
key and she wants to make sure that everyone knows that the public he that is whether the private key that is used for signing can be verified and can be traced back to her identity so she would contact a certificate authority and she would say hey I'm Alice I own this public key and she will probably sign this message with the private key and then the certificate authority says we need your personal information Alice and then Alice gives the certificate authority all her personal information that she wants to bind to the key and then the certificate does some verification and the verification can look like this they will call based on the information that
you provided are you Alice yes okay so we are done here and then the certificate authority will say thanks for using our service this is 1,600 u.s. osp's this is not even this is not even unrealistic by the way and then Alice will give them the money and then they will the certificate authority would say per year so Alice give us some more money and then she has a certificate finally and now she can prove that this key belongs to her and everyone is happy or not so she doesn't actually get the document but you get this little hardware device usually where the certificate is still stored and she will use this device for
signing now okay and this especially from a developer's perspective if you want to guarantee that that your binaries are safe while your users are say if this sounds like a lot of fun right everyone wants to to implement this after they finished I don't know sprint 120 and they finally shipped they want to go through this process okay and this is the problem and Vitaly give gave a really nice speech during DEFCON about crypto economics and the situation is pretty much this all of this all these tools and everything it works right the problem is not that the cryptography and everything does not
work we don't need to reinvent the wheel because this this stuff is not working but it sucks the problem is no one is using it or they and they're not using it correctly okay so how can we use how can we use etherium to change the situation because the current situation is that people are incentivized against a secure system they are incentivized against making easy solutions for people to verify binaries for example it's way too hard learning curve it's way too way too steep they are no they are no tools and developers expose themselves to risks by over sharing personal information why
should everyone know my phone number or address just because I wanted to sign a binary especially in times where developers might get arrested for working on cryptocurrency stuff they have to pay for this additional security and no one no one will say thank you pretty much for this and this means setting up infrastructure to store these hardware hardware devices and setting up roles within the organization and all of this paying consultants and this work is often useless because in the end if no one verifies the binaries then why did why did they do this okay so the idea we use idiom to sign packages let's have a look at how these two things compare
okay traditional signing you buy this little hardware device for signing and in a theorem you already have tools that manage your keys so you might have a ledger you maybe have meta masks and that's already good tools that are widely available for you that you can use that are secure they can store your keys they are easy to use they have a lot of advantages over buying one of these like new things and setting up new software on your computer that you don't understand and the second step for code signing after you sign it you need to verify it and with traditional signatures you get the authentication integrity non-repudiation properties and you get the same so this when you when you use your private key
that you use to sign in Hulme transactions to sign a package it's the exact same thing pretty much on this end for the verification you get exactly the same properties and you get in here using cryptography that is proven because we're using it for a financial system that is pretty good at being unhackable okay and this is interesting now we come to the authentication step where you actually verify okay what is the identity behind this key and in traditional code signing you will receive all the personal information from the developer and for if hyrum some packages you will receive an address and that's pretty cool because now you can
define how much information you are sharing so you can use one of these identity contracts or identity systems and just enter a relevant information like this is my github handler or you can use ENS and then it resolves to such a name and everyone that downloads a package and verifies it we'll see how this package is coming from the person that I expect it to come from and it cannot be modified in transit it cannot be hacked in between it cannot be hacked on the server and that that's a real solution and it gets even better because you can use this to incentivize a secure system so you can completely flip the existing system where people are incentivized to not make it secure
because they're just spending on it and it's useless and now people can actually pay to be paid for it because if you verify it and you see the address that signed it you can send the address money and this is cool because you can for example create rules into your software that says if dependencies are not signed please don't don't execute them and you can incentivize this with a new license model for example we say oh this is Ellis and now she has all the money she saves all the money because she's not spending it on certificates anymore so she spends everything on software now and this means you can have a new license model that says hey contribute
to open source and this can be baked into a package manager that does it automatically for you so if you if your software relies on open source work you can create some rules for splitting or your revenue and directly distributing for every sale to these that you're using and they can of course do the same and this is a fume flavored packages it has it has a specification it has a reference implementation you can use it in the browser you can use it in your no js' application it has CLI tools and you will find every everything relevant to this project on this github page and you can build a lot of cool
stuff with it like decentralized package managers where it doesn't matter if it's on ipfs or asia or AWS you can always verify the origin even if it's something that you don't know USB stick you can still verify this is coming from the author that I expect it to come from and you can build plug-in systems and you can build software like if you're in grid and a lot of other cool things that's it thank you thanks for your attention okay questions we have time for questions can you show the URL again I just wanted to see that but I also
have another question that is like if you if you use something like a github URL or like a name like DNS name as proof yeah then what what prevents like the malicious actor of like entering my github name or using a domain name that looks very very similar to my domain name okay so to get the to get the question right so you're saying my i I say I'm using my get up handle as my like name record for my from a key and yes you can do this but the cool thing is what you can also do is you can have something like continuous certification services that are going so you can for example you can create a self-signed
certificate a file that you sign with your key and then you post it on github and then you care then you can have services that are scanning the github repor for these files and then they could countersign your certificate and then you kind of end up with the same thing that a certificate authority does only with proofs by independent service something like key base for example they could they could see this proof that you did and then countersign it they would say I checked it and the file was there on the github repository this does not prevent of course that someone would heck your your github account and then change the certificate for example but the other thing is it doesn't matter because if they hack your github account
they can also change your code can upload new binary so then it's already like the worst case situation kind of if they have access to your codebase and to your server and everything it doesn't help that your certificate is safe a very very cool project definitely I'm curious to see like the command line and that's I was wondering like what what's like built-in into what you have already like probably you didn't have time for a demo but in terms of doing that I could also imagine like you just want to ensure that the next version of the package is still signed by the same guy something like this right exactly this is this is this is a great thing this is this was actually one of the ideas because we saw the problem in NPM where the maintainer of a project changed and the new maintainer was an attacker and
they uploaded malicious code and then the the original developer said hey I'm maintaining me I'm maintaining this module and I'm not getting anything from it and it's a lot of work and I don't want to do it so I gave this guy ownership pretty much with it which is a crazy situation and affected a lot of project and it was also targeted against crypto wallets and the idea is of course if you have a if you have a key for example that can hold funds you would not transfer your key to the new maintainer and then you can have a package manager that automatically detects a change of ownership and just warn the user or say say something like hey do you want to add this new maintainer to the list of trusted authors and then at least here you have
an alert system that something changed because the current situation is that this completely goes unnoticed and then you get hacked yeah sorry if you get back to the way that signing certificate walk I don't really understand why you oppose those things and you as a result good to the conclusion that I will be able to save some money because I see this as complementary with the class the code signing certificate what they do they actually give a call to that number they make sure this business exists if you've used them yeah you're right so there they are good and bad actors so they are certificate authority that really do their due diligence and they will check ok is it legit organization they will maybe do some background checks but not
then there are also like black sheeps that do just a call or maybe not even a call maybe they prove nothing at all sometimes it's even the situation that these certificate authorities get hacked or that they are keys leak and then you have a really bad certificate authority that can sign every single certificate as like legit this situation can also happen and of course yeah it is a working solution and I'm not I'm not saying it's completely useless but I just think that it makes sense that if we have something like ens which is pretty cool we can see it as an alternative and can see how far we come with it if these kind of things make lives easier for developers and users then I think it's a more viable solution yes another pact is not a wrapper for
existing package managers or no so it's all new repository yes so if package is it started pretty much just with the idea - I have to go back a lot of slides but the idea to just place the the hashes and the signature inside of the package and then it abstracts like you can use a zip file it will place them in a secret directory and then you have the verify and assign function this was like the first draft where it had only these two functionalities so you could extend a package and make it a sign package and then you could very very packaged and and we we realized for our own doing our own work on on grid which is a it's which is a binary manager which is why I put the the last slide here so we were
in this situation so we wanted to offer a simple download for binaries from gas parity pizu and we discover they are all using different hosting solutions so somehow on Asia Simone that AWS bin tray and then we had to implement these backends and we were running in the situation where we were challenged to make sure like if this is coming from like random origins how can we make sure that in the end the package that we're using is still secure and this this brought us to to package signing and we had to implement a lot of functionality for this and because it goes so well together actually that you abstract from the origin with your signatures
now everything got baked into each package and you can use it actually to fetch packages from all these locations you can publish them and in the end it doesn't matter where they are you can mirror them to ipfs you can use a CDN it doesn't doesn't really matter and Google is actually on working on something very similar for for signed requests because they want to use caching and the browser kind of prevents this when when the origin changes because of the the content delivery network so they are also exploring like sign packages for this and it's just a great use case and we put all the functionality into each package now and yeah so it's a package manager kind of it does not do dependency resolution and these kind of things last question thank you for time
[Applause] you