Submitted by WatchPug, also found by 0xsanson, BondiPestControl, and IllIllI
https://github.com/code-423n4/2022-05-cally/blob/1849f9ee12434038aa80753266ce6a2f2b082c59/contracts/src/Cally.sol#L158-L201
https://github.com/code-423n4/2022-05-cally/blob/1849f9ee12434038aa80753266ce6a2f2b082c59/contracts/src/Cally.sol#L23-L34
When creating a new vault, solmates SafeTransferLib is used for pulling vault.token from the callers account, this issue wont exist if OpenZeppelins SafeERC20 is used instead.
Thats because there is a subtle difference between the implementation of solmates SafeTransferLib and OZs SafeERC20:
OZs SafeERC20 checks if the token is a contract or not, solmates SafeTransferLib does not.
See: https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol#L9
As a result, when the tokens address has no code, the transaction will just succeed with no error.
This attack vector was made well-known by the qBridge hack back in Jan 2022.
For our project, this alone still wont be a problem, a vault created and wrongfully accounted for a certain amount of balance for a non-existing token wont be much of a problem, there will be no fund loss as long as the token stays that way (being non-existing).
However, its becoming popular for protocols to deploy their token across multiple networks and when they do so, a common practice is to deploy the token contract from the same deployer address and with the same nonce so that the token address can be the same for all the networks.
For example: $1INCH is using the same token address for both Ethereum and BSC; Gelato's$GEL token is using the same token address for Ethereum, Fantom and Polygon.
A sophisticated attacker can exploit it by taking advantage of that and setting traps on multiple potential tokens to steal from the future users that deposits with such tokens.
Given:
In summary, one of the traps set by the attacker was activated by the deployment of  TokenB and Alice was the victim. As a result, 10000e18 TokenB was stolen by the attacker.
Consider using OZs SafeERC20 instead.
outdoteth (Cally) confirmed and resolved:
HardlyDifficult (judge) commented:
