You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
ctf_sec - More granular control of the pause is needed for each money market because deposit and withdrawal can be guaranteed to revert if the underlying money market is paused or has high utilization rate
#129
Closed
sherlock-admin opened this issue
Nov 4, 2022
· 2 comments
More granular control of the pause is needed for each money market because deposit and withdrawal can be guaranteed to revert if the underlying money market is paused or has high utilization rate
Summary
More granular control of the pause is needed for each money market.
Vulnerability Detail
Currently a single pause control the stake and unstake function in UserManager.sol
function stake(uint96amount) public whenNotPaused nonReentrant {
and
function unstake(uint96amount) external whenNotPaused nonReentrant {
the stake function deposit fund into the AssetManager.sol and then deposit the fund into the money market to generate yield.
More granular control of the pause is needed for each money market. When we know the deposit / withdrawal is guaranteed to revert, we can skip the money market when depositing.
For example, we can add isPaused function in AaveV3Adapter.sol
function isPaused() externalreturns (bool) {
return_poolPaused();
}
for _poolPaused(), we can check if the underlying Aave Pool is paused.
/** * @notice Returns if the pool is paused * @param asset The address of the underlying asset of the reserve * @return isPaused True if the pool is paused, false otherwise **/function getPaused(addressasset) externalviewreturns (boolisPaused) {
(, , , , isPaused) =IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getFlags();
}
For consistency reason, we can add isPaused() in PureTokenAdapter.sol, we never need to pause the PureTokenAdapter.sol
function isPaused() externalreturns (bool) {
returnfalse;
}
then when depositing or withdraw, we can change from
ctf_sec
medium
More granular control of the pause is needed for each money market because deposit and withdrawal can be guaranteed to revert if the underlying money market is paused or has high utilization rate
Summary
More granular control of the pause is needed for each money market.
Vulnerability Detail
Currently a single pause control the stake and unstake function in UserManager.sol
and
the stake function deposit fund into the AssetManager.sol and then deposit the fund into the money market to generate yield.
moneyMarket.deposit(token);
which calls
The unstake withdraw fund from the AssetManager.sol, which withdraw money from the money market to return the user fund.
lendingPool.withdraw(tokenAddress, tokenAmount, recipient);
however, the AaveV3Adapter.sol#deposit and withdraw can revert if the underlying pool is paused or have high utilization rate.
The logic from AAVE did the check when depositing
https://github.com/aave/aave-v3-core/blob/f3e037b3638e3b7c98f0c09c56c5efde54f7c5d2/contracts/protocol/libraries/logic/ValidationLogic.sol#L57
and check before withdraw.
https://github.com/aave/aave-v3-core/blob/f3e037b3638e3b7c98f0c09c56c5efde54f7c5d2/contracts/protocol/libraries/logic/ValidationLogic.sol#L87
as we can see,
Impact
Deposit and withdrawal can be guaranteed to revert if the underlying money market is paused or has high utilization rate
Code Snippet
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/Controller.sol#L147-L151
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/asset/AaveV3Adapter.sol#L199-L204
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/asset/AaveV3Adapter.sol#L212-L219
Tool used
Manual Review
Recommendation
More granular control of the pause is needed for each money market. When we know the deposit / withdrawal is guaranteed to revert, we can skip the money market when depositing.
For example, we can add isPaused function in AaveV3Adapter.sol
for _poolPaused(), we can check if the underlying Aave Pool is paused.
https://github.com/aave/aave-v3-core/blob/f3e037b3638e3b7c98f0c09c56c5efde54f7c5d2/contracts/misc/AaveProtocolDataProvider.sol#L155
For consistency reason, we can add isPaused() in PureTokenAdapter.sol, we never need to pause the PureTokenAdapter.sol
then when depositing or withdraw, we can change from
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/asset/AssetManager.sol#L286-L290
to
and in case of the deposit / withdraw fail because the underlying market has high utilization rate,
we can use try catch to wrap the deposit / withdraw.
Duplicate of #37
The text was updated successfully, but these errors were encountered: