When a user wants to borrow some crvUSD token he must have provided enough collateral beforehand, then he must call LendingPool::borrow(), this function will transfer the required amount from the RToken contract to the borrower. However an attacker can directly transfer crvUSD to the RToken contract and DoS the borrows.
Let's look at the borrow function:
We can see that the selected amount is transfered to borrower and then the internal _rebalanceLiquidity() is called:
Here reserve.totalLiquidity will be decreased by the wanted amount, link here, based on this value will depend the desired buffer and the current buffer is the RToken's crvUSD reserves.
Now consider the following scenario:
Lender provides liquidity, deposits 1000e18
reserve.totalLiquidity will increment by 1000e18, link here
Bob deposits collateral worth 2000e18 and borrows 1000e18 tokens
So totalLiquidity will be 0
desiredBuffer = 0 * liquidationThreshol (80% == 8000) = 0
currentBuffer will be 0, because the assets are transfered before _rebalanceLiquidity is called
Until here everything is fine, but if an attacker frontruns the borrow tx and directly deposits 1 wei to the RToken contract
currentBuffer will be 1, that means there will be excess amount of 1 and it will try to deposit it to the curve vault
However the excess amount will be transfered from the LendingPool, but this contract doesn't hold any balances, because when lenders are providing liquidity the crvUSD tokens are directly transfered from lender to RToken contract, the lending pool only acts as an intermediary
Hence the call will revert
Here is a coded PoC in Foundry demonstrating the issue:
Setup:
Install Foundry
Run forge init --force in the terminal
Run forge test --mt testX in the terminal
Medium, an attacker can DoS the borrows
Manual Review
Refactor the logic so that LendingPool also holds some tokens
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.