[Not All Tokens Are Good] The quick analysis of the Paraluni attack

BlockSec
3 min readMar 13, 2022

--

The Paraluni project was attacked on the morning of March 13 (UTC +8 time). The attacker leveraged two vulnerabilities to attack the protocol. The first vulnerability is the lack of the verification of passed tokens, and the second is the traditional reentrancy. The attacker launched a couple of attack transactions. In the following, we will use one of them 0xf2bba649019ce40a67f0fb74e5e800257d359d9094b6ba6faea14ffa4d3446b1 to illustrate the whole attack process.

Step I: add liquidity to paraRouter

The attacker invoked addLiquidity to the BTCB-WBNB pool (index = 9) and the pool will mint the lp token to UBT (a token created by the attacker.) After this operation, the UBT token holds the pool's lp token. Note that, the BTCB and WBNB is borrowed from the flash loan.

Step II: invoke depositByAddLiquidity of MasterChef

The attacker invoked depositByAddLiquidity by providing the _pid as 9 and using the UGT and UBT token as the parameters. However, the function does not check whether the pool’s reserve tokens are equal to the passed tokens (UGT and UBT).

Then the function invokes the depositByAddLiquidityInternal which then invokes addLiquidity of paraRouter. This function will invoke the UGT and UBT token’s transferFrom function. However, these two tokens are controlled by the attacker. In the transferFrom function of UBT, the attacker invoked deposit function of the MasterChef contract to deposit the LP token obtained in the first step into MasterChef contract.

Unfortunately, due to the balance change in the deposit function, the newBalance after addLiquidity is much larger than the oldBalance. In this way, the attacker got double credits in MasterChef contract.

Step III: get profit

The attacker finally invoked UBT.withdrawAsset and MasterChef.withdrawto redeem the lptoken to get BTCB and WBNB. Since the number of liquidity is more than the attacker should have, the attacker will get profits.

Lessons

Besides the reentrancy problem, the passed tokens have not been verified is one of the root causes. We have seen other cases with similar issue, as in the Visor case and the Coin98 case.

About BlockSec

The BlockSec Team focuses on the security of the blockchain ecosystem, and collaborates with leading DeFi projects to secure their products. The team is founded by top-notch security researchers and experienced experts from both academia and industry. The core founder of the team has been recognized as the Most Influential Scholar Award (Rank 4 from 2012–2021), in the field of security and privacy. They have published multiple blockchain security papers in prestigious conferences, reported several zero-day attacks of DeFi applications, and released detailed analysis reports of high impact security incidents.

--

--

BlockSec
BlockSec

Written by BlockSec

The BlockSec focuses on the security of the blockchain ecosystem and the research of DeFi attack monitoring and blocking. https://blocksec.com

No responses yet