-
Notifications
You must be signed in to change notification settings - Fork 6
yixxas - Adversary can prevent withdrawal of assets if token used has multiple addresses #369
Comments
'Some tokens have multiple addresses' I have never heard of a token having multiple assets. This does not make sense. A token is created by the deployment of a smart contract and that smart contract address is the token address. I do not see any issue here. |
Escalate for 10 USDC To respond to the sponsor @ethereumdegen, tokens with multiple addresses do exist though they are rare. A similar issue has been reported and accepted in a previous contest sherlock-audit/2023-03-taurus-judging#31 It is explicitly mentioned by the protocol that it aims to support all ERC20 tokens, hence they should be prepared to handle such tokens. Therefore, this issue should be considered a valid medium. |
You've created a valid escalation for 10 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Disagree with the escalation, I believe this issue is invalid. In the scenario where borrowers commit the same token with two different addresses, they are required to deposit this token twice (refer to |
Escalation rejected Invalid issue |
|
yixxas
high
Adversary can prevent withdrawal of assets if token used has multiple addresses
Summary
Some tokens have multiple addresses. If such tokens are used as collatearl, an adversary can cause unknown users from having their collateral stuck in the contract permanently.
Vulnerability Detail
commitCollateral()
has no access control. It checks the balance of borrower to ensure that they have enough balance. If a check is successful, the address is added to thecollateralAddresses
enumerableSet viacollateral.collateralAddresses.add(_collateralInfo._collateralAddress)
.The issue here is that, for a token with multiple addresses, an adversary can call this function to add the same token of its different addresses to
collateral.collateralAddresses
. This call will succeed ascommitCollateral()
only checks balances of the token, and both addresses will map to the same balances of the token.When withdrawing, it loops through all
collateralAddresses
of thebidId
. It then withdraws the token based oncollateralInfo._amount
.For example, if a user has
balanceOf(tokenId) = 500
, andcollateralInfo._amount = 500
, after the first withdrawal,balanceOf == 0
, but it will attempt to withdraw again on this 0 balance as the 2 different addresses maps to the same token. This will revert hence preventing any withdrawal from happening permanently.Impact
Assets with multiple addresses can be forced trapped in contract permanently.
Code Snippet
https://github.com/sherlock-audit/2023-03-teller/blob/main/teller-protocol-v2/packages/contracts/contracts/CollateralManager.sol#L431
https://github.com/sherlock-audit/2023-03-teller/blob/main/teller-protocol-v2/packages/contracts/contracts/CollateralManager.sol#L393-L419
Tool used
Manual Review
Recommendation
Consider using a whitelist to prevent such tokens from being used.
The text was updated successfully, but these errors were encountered: