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.
hansfriese
high
AssetManager.removeAdapter()
doesn't updatewithdrawSeq
after removing an adapter.Summary
AssetManager.removeAdapter()
doesn't updatewithdrawSeq
after removing an adapter.Vulnerability Detail
In the
AssetManager.sol
, it stores all market adapters using moneyMarkets and priority sequence of money market indices using withdrawSeq.As we can see from addAdapter(), it adds the index to
withdrawSeq
.But in the removeAdapter(), it doesn't update
withdrawSeq
properly.So the below scenario would be possible.
moneyMarkets = [adapter1, adapter2], withdrawSeq = [0, 1]
adapter2
usingremoveAdapter()
.moneyMarkets = [adapter1], withdrawSeq = [0, 1]
i == 1
because the length ofmoneyMarkets
is 1 here.withdrawSeq = [0]
using setWithdrawSequence() because the lengths should be same.Impact
AssetManager.withdraw()
will revert after some adapters are removed frommoneyMarkets
.Code Snippet
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/asset/AssetManager.sol#L440-L457
Tool used
Manual Review
Recommendation
We should remove the last index from
withdrawSeq
inremoveAdapter()
like below.The above approach doesn't keep the original order after removing an adapter and we might try another method for that.
Duplicate of #76
The text was updated successfully, but these errors were encountered: