BTC
ETH
HTX
SOL
BNB
View Market
简中
繁中
English
日本語
한국어
ภาษาไทย
Tiếng Việt

Review the case of stolen wallets, and discuss how to achieve asset security in Web3.0?

链捕手
特邀专栏作者
2022-01-21 03:35
This article is about 3230 words, reading the full article takes about 5 minutes
From the case of a stolen wallet, discuss the security guidelines of Web3.
AI Summary
Expand
From the case of a stolen wallet, discuss the security guidelines of Web3.

Original Source: Alpha Rabbit Research Notes

Original Source: Alpha Rabbit Research Notes

event

event

One morning during the New Year's Day holiday in 2022, Little C was preparing to write code and continue to test Web3js' on-chain contract transactions. Suddenly found that my test account (Bsc chain) was reset to zero in MetaMask, and there was still 100 usd in the account the night before, and after checking the transfer, I found:

background

background

secondary title

How was the loss caused?

On the last day of 2021, Little C happened to see an interesting account (this account has many active transactions), tracked some of his on-chain transactions, and saw a very interesting project (with a high annualized rate of return), then accidentally connected to his own MetaMask, and then approved by accident, because the general Web3 project is this process, approve and then the transfer is over.

But a shocking scene appeared: after clicking, the entire website suddenly froze (in fact, during the froze period, the thief transferred the money away), there was no response, and Xiao C didn't take it back at that time. I closed the site and went to do other things.

first level title

secondary title

How did the thief transfer all the money in Little C's account?

Phenomenon: As long as you approve, you can theoretically transfer all the corresponding money without the private key.

Little C traced the source, probably because there was a problem with the approval of a phishing website, so he traced the transfer record.

As shown in the picture, it can be seen that first a contract is approved (authorized), and the phishing contract is authorized to operate on the BUSD in the account, and there is no limit on the number.

Why is it BUSD? Little C recalled that when he entered this phishing site, he chose BUSD by default. It is estimated that after browsing the site link wallet, the thief had already screened out the token with the most money in the account.

Then when Little C thought it was a new swap contract with a high annualized return and was going to try it out first, he proceeded to approve according to the conventional process. After the approve is over, the website is directly stuck.

Later, after tracing back, about tens of seconds after the authorization, the contract directly triggered a transfer operation, and directly transferred the BUSD token away.

Later, I checked the authorization information.

Basically, the default authorization of MetaMask is:

Converted into numbers, what we know is 1.157920892373162 multiplied by 10 to the 59th power. Basically, it can be understood as an unlimited transfer, that is, this authorized operation allows the contract to manipulate the token of my account indefinitely. When I saw this, I felt a chill behind my back, because I clicked approve many times before, but I would not go to see it.

Then the hacker manipulates a wallet address that can control the contract method, initiates the contract transfer method, and transfers the money away. So guys afterBe careful when you click metamask authorization

first level title

secondary title

Where is the problem?

Because I am learning blockchain recently. Little C roughly sorted out the logic of this fishing method. It is necessary to have the heart of harming others and the heart of preventing others. If you are interested, you can find out:

normal transfer

Case 1: Direct transfer between users A user transfers BUSD to B user

The contract normally checks the following logic

1) Determine whether there is enough money in the account balance of user A; 2) Whether it is a transfer initiated by user A

The process is as shown in the figure below

Normal contract exchange

It is the process when we usually use pancakeswap, uniswap, etc. to exchange

Case 2: Token exchange through swap A user performs token exchange (BUSD to WBNB) process contract to judge:

1) Whether there is enough BUSD in the account balance of user A (assuming that the swap contract has been authorized to operate the BUSD token of account A)

2) The swap contract takes 500BUSD from account A and puts it into the swap contract pool (assuming the exchange rate is 1:500)

3) After the contract is successful, transfer 1BNB to account A

Note that points 2 and 3 are operated by the contract control token. In other words, the contract can bypass us and directly initiate operations on the tokens under our account.

fishing contract

First look at this traceability diagram

For normal transfers, the transfer party and the contract execution party should be the same person, that is, (1) and (2) in the above figure should be initiated by the same person. As for the transaction I was transferred to, these two addresses are not the same. It is speculated that a wallet address that can execute the phishing contract should control the execution of the contract, and then transfer the BUSD that I authorized to the phishing contract.

To check the phishing contract, it is not surprising that the phishing contract is an encrypted contract. But it's not difficult to think about it. Anyone who has studied Solidity a little knows that when defining a contract, it is enough to set a few more Admins or Owners.

safety advice

safety advice

Because of this incident, Xiao C searched for some useful suggestions and methods, and also saw a lot of bloody lessons.

Here are some methods that you can choose according to your needs.

1) Do not share keys

I saw a post before saying that a mnemonic phrase generates multiple accounts. I don’t recommend this kind of account, because it is likely to be used in one pot.

2) The key is saved offline

Because there are many clipboard tool input methods that will upload your clipboard records to the cloud, if you copy directly, if the cloud leaks, your key will be lost directly.

My suggestion is to copy it to the notebook as soon as possible after it is generated. Of course, you can copy it to the notebook, and you can also refer to my own dictionary encryption of the key. For example, a is replaced by 1, b is replaced by 2, and 1 is replaced by a. This ensures that even if someone sees your paper key, Nor can you move your digital assets.

3) Separate development and testing (airdrop and main account isolation)

Install 2 browsers, one can be chrome and the other is brave. One to manage your main wallet. The other one can participate in receiving airdrops, various on-chain operations, etc.

4) Do not download software from unknown sources

Don't use baidu to download software from unknown sources. I have seen cases of downloading pirated metamask, which directly went bankrupt. Be sure to go to the official address to download, and you can refer to Google Play if you have the conditions. chrome web store etc.

5) Check your authorization now

The URLs to check are as follows. Debank is not open source, but the UI interaction is better. There are open source ones in the future. You can choose by yourself.

https://debank.com/

https://approved.zone/

https://tac.dappstar.io/

https://ethallowance.com/

As shown in the picture, it is basically infinite.

Every time you wake up MetaMask, you must look at the authorization more, don't be as brainless as I am now to authorize the next step.

6) Before authorization, confirm the security of the contract

https://www.slowmist.com/service-smart-contract-security-audit.html

You can use the contract audit function of SlowMist.

You can also check whether the contract is open source. If it is open source, you need to confirm whether the contract is an upgradeable contract, etc.

7) Pay attention to safety when using airdrops and benefits

Use a small account to collect, don't use a large account, you can set the amount when authorizing! ! !

8) Be wary of the intrusion of social workers, and be careful of strangers who privately chat with you on Discord

For example, Discord or Telegram, someone has known you for a few days, and said that he will bring you money to get airdrops, let you install the software he sent you and log in. 99.99% of this kind of money will lose your money. Account stolen.

In particular, in Discord, enter the official Discord of NFT, and someone will chat with you privately, telling you that you have obtained the whitelist, with a mint link attached. The liar will change the profile picture and name to the official one, which is actually achieved by pulling him into a group with you.

In fact, as long as you are not greedy, this kind of scam is quite easy to see through. Generally, you will be told to mint within a few hours, and the number is 1-10. Many popular projects have a whitelist of mints and one or two mints, but this one has a time limit of 10.

Also, there will be scammers imitating the official website of the project to make a fake website, private message to the people in the project server, and ask them to come to mint.

There are also friends who bought a fake NFT on opensea and found out that it was not official. After a few days, the NFT disappeared from the account but has been deducted... (how did you find it? Look at the chain and the official discord posted the official Opensea URL )

There is also a fake collab.land that cheats the wallet password, airdrops to the big v and then claims that the big v bought the NFT/token.

The new year is coming, everyone must pay attention to safety, I hope that friends who read this article will be safe and sound!

This article thanks to the author Chris

Web3.0
Safety
wallet
Welcome to Join Odaily Official Community