#blockchain

I hacked Parity MultiSig Wallet in Ropsten Testnet

Parity MultiSig Wallet was hacked in 7 November 2017 (see the details here https://paritytech.io/blog/security-alert.html). The hack destroyed 1% of Ethereum’s valuation.

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

Now, I show you the steps to deploy the contracts.

Step 1: Installation

Open Metamask, select Ropsten Network, create two account (User Accout and Hacker Account) and get free ETH.

Open Remix IDE, select Solidity compiler version soljson-v0.4.10+commit.f0d539ae.js. Create file Wallet.sol and copy/paste the source code to the file.

Step 2: User deploys WalletLibrary Contract

On Metamask, select User Account. In Remix IDE, select WalletLibrary Contract and click create button to deploy. Waiting for the deployment finished.

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:

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.

That is a bad day with Ethereum Community and hacker as well.

References

Parity Multisig Hacked. Again

Parity Multi-sig wallets funds frozen (explained)

 

How to get started building an ICO Smart Contract

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).

For the document, you can take a look to link: https://erc20token.sonnguyen.ws

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.

Beside the law, you should concern to the security issue for your smart contract. Try to make your contract as simple as possible (Security loves simple). And reading the smart contract best practice document, learn from the fails (as DAO, Parity MutliSig Wallet) before start coding.