Today, I try to investigated the vulnerability and re-do exactly what hacker did with Parity Wallet’s smart contract.

There are two main steps I need to do:

Create Parity Multisig Wallet in Ropsten Testnet

Try to hack it

I recorded all steps I did in the video.

At the first step, I red the source code of Multisig Wallet. Parity Multisig Wallet contains two main contracts – Wallet Contract and WalletLibrary Contract. Wallet Contract stores ETH, WalletLibrary contains functions to implement almost features of a multisig wallet.

After understanding a little bit, I tried to deploy the MultiSig Wallet to Ropsten Testnet using Remix IDE and Metamask

Step 2: User deploys WalletLibrary Contract

After that, copy the address of WalletLibrary (with me, it is 0x6bc323538bad65bbde22f908f9a8f180ea4078fe) and paste it into line 448 in Wallet.sol file. This step means we link Wallet Contract to WalletLibrary Contract that we just deployed.

Step 3: User deploys Wallet Contract

Wallet Contract has some constructor parameters, so we need to complete it. In my case, it is ["0xd088d9c6abb936260BF4540026C8F0aDFfD09836"], 1, 1000. 0xd088d9c6abb936260BF4540026C8F0aDFfD09836 is User Account Address.

Now click create button to deploy the Wallet Contract. This contract is multi-signature wallet and store ETH.

Step 4: What hacker did?

This step, I will do things like Hacker did.

I open Metamask, select Hacker Account. I open Remix IDE, copy/paste the source code to Wallet.sol file. I do not need to deploy WalletLibrary contract again (Hacker was same). In Remix IDE, I select WalletLibrary Contract, and copy/paste the address of Wallet Library to address textbox and click address button. Now I have WalletLibrary Contract in my IDE.

Now, I run initWallet function

And run kill function.

So the WalletLibrary was died.

Conclusions

I think that hacker do not want to burn 500.000 ETH. He just want to send 500.000 ETH to his wallet, so he called kill function. Because I checked kill function source code:

1

2

3

functionkill(address _to)onlymanyowners(sha3(msg.data))external{

suicide(_to);

}

It means that if kill function is called, the contract will be died and send all the balance to his wallet. But he had a mistake. 500.000 ETH is not stored in WalletLibrary Contract, It is stored in Wallet Contract. So the result is 500.000 ETH was frozen, and he got nothing.

ICO (Initial Coin Offering) is a new way to raise fund for startups. There are many steps we have to be done before launching an ICO. One of them is writing ICO Smart Contract. Actually, ICO Smart Contract source code is quite simple. I think that, in the near future, there will be ICO Platform to help you create Smart Contract in some of mouse clicks.

However, Blockchain and Smart Contract is still new with developers, and Smart Contract development process is still complicated. So developer will think that there are a lot of things to learn before creating an ICO Smart Contract.

I created a documents to guide developers who have experiences in development but are new in Blockchain and Smart Contract. The document will show you step by step to create an Simple ICO Smart Contract and deploy it to Local Environment or Testnet (Ropsten).

The document is open source under MIT License, now there is only English version. So contributions are always appreciated. The source code of documents and demos are published to Github at link: https://github.com/thanhson1085/DemoCoin.

The smart contract that we used in my tutorial is very simple and only for education purpose. In fact, the scenario for ICO is more complicate and we need to comply the law of country where you want to sell your token.