chaduke
medium
deployAndDeposit()
is subject to a DOS attack because the function iterates through each collateral in a for loop. As a result, if a malicious user can increase the list of collateral for a _bidId
, then deployAndDeposit()
will revert due to out of gas, a DOS attack.
We show how a malicious user Bob can launch an attack to deployAndDeposit()
below:
- Bob can call
commitCollateral()
to add a list of new collaterals (ERC20 tokens) to_bidId
. Suppose the borrower of_bidId
is Alice.
- In order to bypass the check at L122 for function
checkBalances()
. For each new collateral_col
, Bob will send 1 wei of_col
token to Alice so that the following check will pass. Here we suppose_collateralInfo._amount = 1
.
if (collateralType == CollateralType.ERC20) {
return
_collateralInfo._amount <=
IERC20Upgradeable(_collateralInfo._collateralAddress).balanceOf(
_borrowerAddress
);
- Because the list of new collaterals for
_bidId
becomes too long, the call ofdeployAndDeposit()
will revert due to out of gas, a DOS attack.
A malicious user can effectively add new collaterals for a _bidId
and cause deployAndDeposit()
to revert due to out of gas.
see above
VSCode
Manual Review
Restrict the length of the list of collaterals for each _bidId
so that out-of-gas can be avoided.