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.
AssetManager.removeAdapter: Adapter not removed from withdrawSeq
Summary
When an adapter is removed, the corresponding entry is not removed form withdrawSeq, causing a revert on withdrawals
Vulnerability Detail
In AssetManager, the indices of the adapters are added to the list withdrawSeq. However, when an adapter is removed using removeAdapter, the indices are not updated. Therefore, moneyMarketsLength - 1 (that now no longer exists) and index (that now refers to another adapter, because positions were swapped) will still be in the list.
Impact
Because withdraw iterates over the whole withdrawSeq list and accesses these indices, this will cause an out-of-bounds access there, meaning that withdrawals revert.
Lambda
medium
AssetManager.removeAdapter: Adapter not removed from withdrawSeq
Summary
When an adapter is removed, the corresponding entry is not removed form
withdrawSeq
, causing a revert on withdrawalsVulnerability Detail
In
AssetManager
, the indices of the adapters are added to the listwithdrawSeq
. However, when an adapter is removed usingremoveAdapter
, the indices are not updated. Therefore,moneyMarketsLength - 1
(that now no longer exists) andindex
(that now refers to another adapter, because positions were swapped) will still be in the list.Impact
Because
withdraw
iterates over the wholewithdrawSeq
list and accesses these indices, this will cause an out-of-bounds access there, meaning that withdrawals revert.Code Snippet
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/asset/AssetManager.sol#L396
Tool used
Manual Review
Recommendation
Change the two indices (removal & update) within
withdrawSeq
when removing an adapter.Duplicate of #76
The text was updated successfully, but these errors were encountered: