This repository has been archived by the owner on Jul 14, 2024. It is now read-only.
0xpiken - User might not able to collect collateral after successful redemption #63
Labels
Non-Reward
This issue will not receive a payout
0xpiken
medium
User might not able to collect collateral after successful redemption
Summary
User might not able to call
collectRedemption()
successfully evenredeemDollar()
is invoked successfully.Vulnerability Detail
A eligible user has right to call
redeemDollar()
to redeem their collateral by burning their uAD tokens.Once the collateral balance in the pool is enough, the amount of redeemed collateral will be locked immediately. user can collect it by calling
collectRedemption()
several blocks later (redemptionDelayBlocks
).Ubiquity allows AMO minters to borrow collateral to make yield in external protocols. The amount of collateral they can borrow is defined in
freeCollateralBalance()
:The implementation of
freeCollateralBalance()
is below:From above codes we can see, any collateral that has been redeemed but not collected by user should not be used for borrowing.
However, it was not accounted when
amoMinterBorrow()
is called:Since
unclaimedPoolCollateral
is not accounted, amo minter can borrow up to the entire collateral balance in the pool.Copy below codes into UbiquityPoolFacetTest.t.sol and run
forge test --match-test testCollectRedemption_CollectRedemptionFail()
:Impact
User might not able to call
collectRedemption()
successfully evenredeemDollar()
is invoked successfully.Code Snippet
https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibUbiquityPool.sol#L574-L598
Tool used
Manual Review
Recommendation
Check if there is enough free balance for borrowing in
collectRedemption()
:function amoMinterBorrow(uint256 collateralAmount) internal onlyAmoMinter { UbiquityPoolStorage storage poolStorage = ubiquityPoolStorage(); // checks the collateral index of the minter as an additional safety check uint256 minterCollateralIndex = IDollarAmoMinter(msg.sender) .collateralIndex(); // checks to see if borrowing is paused require( poolStorage.isBorrowPaused[minterCollateralIndex] == false, "Borrowing is paused" ); // ensure collateral is enabled require( poolStorage.isCollateralEnabled[ poolStorage.collateralAddresses[minterCollateralIndex] ], "Collateral disabled" ); + require(collateralAmount <= freeCollateralBalance(minterCollateralIndex), "No free collateral for borrowing"); // transfer IERC20(poolStorage.collateralAddresses[minterCollateralIndex]) .safeTransfer(msg.sender, collateralAmount); }
Duplicate of #1
The text was updated successfully, but these errors were encountered: