Some ERC20 tokens doesn't revert on failure instead they return false.
A malicious actor can call Lender::borrow
with an amount of collateral greater than his current balance, when the protocol calls the transferFrom
method to move tokens from msg.sender
to the protocol this will fail, but due to the lack of check in the return value Lender::borrow
will not revert and the actor will successfully drain the pool without depositing tokens.
Assume a malicious user has a balance of 2000 collateralToken
, and decides to borrow the whole balance of pool1
by depositing 3000 collateralToken
.
The user calls Lender::borrow
, but due the lack of funds from the user no collateral will be deposited, the debt will be issued and tokens will be transferred to the borrower, and successfully the pool is drained.
At this point nothing can be done by the lender to recover the tokens even if he starts an auction.
The result of this hack is shown below.
Pools can be drained
VS Code and Foundry
Check for return values for ERC20 operations or implement wrappers around ERC20 operation like the SafeERC20 library from OpenZeppelin.
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.