Submitted by carrotsmuggler
The _processWrapOperation function can be triggered on the Magnetar contract to wrap/unwrap the users tokens into or out of the TOFT contracts. This function allows 2 selectors, wrap and unwrap to be called.
The issue is that unwrap function has 2 issues which prevent it from working properly. Below is the code from the BaseTOFT.sol contract, showing the implementation of the unwrap: function.
As seen here, the token is burnt from the msg.sender address. However, the _processWrapOperation function in the Magnetar contract does not transfer out the token from the users address to itself before calling _unwrap.
So the Magnetar contract isnt in possession of the token that the TOFT contract is trying to burn. The Magnetar contract itself is not designed to hold user tokens, since anyone can claim them. Users should not send their tokens to the Magnetar contract manually and then call this function, since MEV bots can steal tokens from this contract by just calling the unwrap function before them. Due to this, there is no way for Magnetar to actually unwrap the tokens.
Secondly, the _checkSender function is used to check the first passed address against msg.sender. the issue is that the first address passed to the unwrap function is the destination address, not the owners address. The owner is assumed to be msg.sender. So this contract essentially only makes sure that the msg.sender matches the destination of the unwrapped tokens, which is not a useful check.
Since these two issues break the functionality of this function, this is a medium severity issue.
The fact that Magnetar isnt designed to hold tokens is evident from the fact that any user can just call the unwrap function from magnetar and burn up any tokens it is currently holding. So the absence of the transferring of the token to the Magnetar contract itself causes an issue.
The unwrap functionality should transfer the token from the msg.sender to itself first. This will ensure both that the caller owns the token and that the token is in the possession of the Magnetar contract. The _checkSender check for the unwrap case is unnecessary and prevents users from choosing a destination address.
Invalid Validation
cryptotechmaker (Tapioca) confirmed and commented:
