When a user borrows crvUSD tokens, he gets minted an equal amount of DebtToken. And at some point if the borrower gets liquidated these DebtTokens are burned from his account. Also it's important to note that this custom token doesn't allow transfers, so borrowers can't transfer them out to some other address and prevent the liquidation. However this is not always the case, more details in the below section.
A malicious user can create a custom smart contract to borrow assets and then selfdestruct it and make profit from the difference of the deposited collateral and the borrowed amount. The behaviour of the selfdestruct opcode was changed with the implementation of EIP-6780 in the Dencun hardfork, which went live on 12th of March, 2024 (here can be seen all changes of the Dencun upgrade - EIP-7569). Quoting the EIP-6780: "SELFDESTRUCT will recover all funds to the target but not delete the account, except when called in the same transaction as creation". More details can be read in the link.
Consider the following scenario, Alice creates a custom smart contract that in it's constructor:
Gets 1000 crvUSD tokens
Mints RAACNFT to itself
Deposits the NFT in the LendingPool (will have 1000 crvUSD as collateral)
Borrows 1250 crvUSD (since liquidationThreshold is set to 80% in the LendingPool, for 1000 crvUSD worth of collateral user can borrow up to 1250 crvUSD), gets minted 1250 DebtTokens
Transfers the borrowed tokens to Alice
Selfdestructs himself
Now when the attacker contract's position is tried to get liquidated the tx will revert, because it will try to burn from this address
Here is a POC:
I'm using Foundry for tests, in order to run the test:
Install Foundry
Run forge init --force in the terminal
Paste the below file in the test folder and run forge test --mt testX -vvv
Impact: High, the report proves that Alice just made profit, the impact can be more severe if the collateral provided is larger amount
Likelihood: High, an incentive for attackers to steal assets
Overall: High
Manual Review
The best solution here is to not allow users to interact with smart contracts. This also means, the nft.safeTransferFrom function to be replaced with transferFrom instead
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.