Submitted by Ruhum, also found by oyc109 and smilingheretic
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L198-L200
Some ERC20 tokens dont throw but just return false when a transfer fails. This can be abused to trick the createVault() function to initialize the vault without providing any tokens. A good example of such a token is ZRX: Etherscan code
When such a vault is initialized, another user can both buy and exercise the option without ever receiving any funds. The creator of the vault does receive the buyers Ether tho. So it can cause a loss of funds.
The trick is to create a vault with an ERC20 token but use ERC721 as the vaults type. Then, instead of calling safeTransferFrom() the function calls transferFrom() which wont catch the token returning false.
Heres a test that showcases the issue:
To run it, you need to use forges forking mode: forge test --fork-url <alchemy/infura URL> --match testStealFunds
I think the easiest solution is to use safeTransferFrom() when the token is of type ERC721. Since the transfer is at the end of the function there shouldnt be any risk of reentrancy. If someone passes an ERC20 address with type ERC721, the safeTransferFrom() call would simply fail since that function signature shouldnt exist on ERC20 tokens.
outdoteth (Cally) confirmed and resolved:
HardlyDifficult (judge) commented:
