createVault()
does not confirm whether tokenType
and token
’s type are the same
#243
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
Lines of code
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L158-L201
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L296
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L345
Vulnerability details
Impact
When calling
createVault()
,tokenType
could be different fromtoken
’s type. If a user accidentally used the wrongtokenType
, it could lead to two different results.If
token
is an ERC20 token and the user usesTokenType.ERC721
astokenType
. It is less harmful, sinceERC721(vault.token).transferFrom(msg.sender, address(this), vault.tokenIdOrAmount)
still works whenvault.token
is actually ERC20 token.However, if
token
is an ERC721 token and the user usesTokenType.ERC20
astokenType
. When doingcreatVault()
,ERC20(vault.token).safeTransferFrom(msg.sender, address(this), vault.tokenIdOrAmount)
works fine. But when doingexercise()
orwithdraw()
,ERC20(vault.token).safeTransfer(msg.sender, vault.tokenIdOrAmount);
doesn’t work since ERC721 doesn’t implementsafeTransfer()
function. In consequence, the ERC721 token is frozen in the vault.Proof of Concept
createVault()
does not confirm whethertokenType
andtoken
’s type are the same.But the token can still be transferred into this contract. Since
transferFrom()
is implemented in ERC20 andsafeTransferFrom()
is implemented in ERC721https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L158-L201
However when doing
exercise()
orwithdraw()
, it always reverts since ERC721 doesn’t implementsafeTransfer()
. The ERC721 token is frozen in the contract.https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L296
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L345
Tools Used
None
Recommended Mitigation Steps
Confirm whether
tokenType
andtoken
’s type are the same increateVault()
.The text was updated successfully, but these errors were encountered: