Original title: "Knowing Chuangyu Blockchain Security Lab|Dangerous Authorized Transfers: Li.Finance Attack Incident"
Original author: Chuangyu Blockchain Lab
On the evening of March 20th, Beijing time, I know the security of Chuangyu blockchain The laboratory monitored the distributed cross-chain protocol on Ethereum. Li.Finance was compromised, and the attackers performed 37 call injections, obtaining approximately $600,000 in assets (204 ETH) in multiple wallets. The asset loss this time is not very large, but the project party is very active in dealing with the attack and is worth learning and affirming (see below). At present, the project party has compensated for the loss of the protocol and redeployed the protocol after repairing it.
Know that Chuangyu Blockchain Security Lab tracked and analyzed this incident as soon as possible.

Attack tx:
0x4b4143cbe7f5475029cf23d6dcbb56856366d91794426f2e33819b9b1aac4e96
Sales contract:
0x5A9FD7C39A6C488E715437B1F3C823D5596ed1-Agent contract
Attack address:
0xC6f2bDE06967E04caAf4bF4E43717c3342680d76 -- deployment address
0x878099F08131a18Fab6bB0b4Cfc6B6DAe54b177E -- Payment Address
p>
Attack call process
The attacker constructs the payload and calls the swapAndStartBridgeTokensViaCBridge function of the attacked contract 0x5a9fd7c3:
< /p>

The specific Payload used is as follows - the selected part in the figure is the payload of the authorized transfer (transferFrom) part:

Call the normal $50 cross-chain bridge function once (in order to be able to Call swapAndStartBridgeTokensViaCBridge function):
Include multiple call methods in the payload (transferFrom is actually used for calling). Let 0x5a9fd7c3 call 37 calls, so as to use the authorization (approve) of multiple wallets for the 0x5a9fd7c3 contract to transfer the wallet assets to the attacker's address:

Follow-up execution of normal cross-chain bridge logic _startBridge(_cBridgeData); This is why the first swap is normal, so that the subsequent logic can be executed normally:

< br>
The root cause of this problem is that the logic contract of the attacked contract 0x5a9fd7c3 has a batch function swapAndStartBridgeTokensViaCBridge:

The contract Multiple _swapData data structures in the payload will be taken out and called, LibSwap.swap(...); is implemented as follows:

In this way, the attacker uses the call of the contract to The code authorization of each wallet to the 0x5a9fd7c3 contract transferred various tokens in multiple wallets.

After the event happened, the project party immediately reviewed the possible methods of the contract and apologized for the audit and security issues:

Then, the project party also contacted the hacker, hoping Can get in touch with it and resolve it peacefully:
At the same time, the vulnerability contract will be repaired and launched in the fastest time:

Add the wallet (with Take Matic as an example) For the authorization cancellation of the previously attacked contract, the new contract is re-authorized:

Finally, the user's assets are replenished:

p>
At the same time, we noticed that its contract on the polygon chain has also achieved a new deployment:

p>
The root cause of this attack is the call injection caused by the project party’s over-liberalization of the swapAndStartBridgeTokensViaCBridge contract. However, the project party’s positive attitude to the problem and the timeliness of follow-up remedies are worth learning and affirming. It is not more expensive than having no mistakes, but more expensive than making mistakes.
But we still want to nip mistakes before they happen, learn from others' mistakes and avoid our own future mistakes, as Li.Finance said : "Our mission is to maximize the user experience, and we have now painfully learned that in order to live in that spirit, our security measures must improve dramatically."
Recently, security incidents of various contract vulnerabilities have occurred frequently, and it is necessary to implement contract audits, risk control measures, and emergency plans.
Original text link
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia