Submitted by Ack, also found by zzebra83
NOTE: This vulnerability relies on the team implementing an onERC721Received() function in Magnetar. As is currently written, attempts to exit oTAP positions via Magnetar will always revert as Magnetar cannot receive ERC721s, despite this being the clear intention of the function. This code path was not covered in the tests. Once implemented, however, an attack vector to steal twAML-locked oTAP positions opens.
Also, this is a similar but distinct attack vector from #933.
MagnetarMarketModule#_exitPositionAndRemoveCollateral() is a complex function used to perform any combination of: exiting an oTAP position, unlocking a locked tOLP position, removing assets and collateral from Singularity/bigBang, and repaying loans. The function achieves this by employing separate if clauses for each task that the caller would like to perform. These clauses are entered based on flags the caller provides in the argument struct removeAndRepayData.
Along with the set of operations to perform, the caller also provides:
As the caller has full control of all of these parameters, he can execute attacks to steal assets that have been approved to Magnetar.
High - Theft of funds
Unfortunately the Magnetar tests do not cover the case where we wish to exit our oTAP position, and the periphery testing infrastructure does not include helper functions for the oTAP workflows (at least that I was able to find). This makes a coded PoC difficult and time consuming. Please consider the following walkthrough and reach out if a coded example is necessary.
In this case, were going to assume that a victim wants to use this function as-designed to exit his twAML-locked oTAP position. In order to do so he needs to grant approval in  for Magnetar to transfer his position.
Once approved, anyone can call _exitPositionAndRemoveCollateral() with his own set of target addresses (some valid Tapioca addresses, some attacker-owned contracts) and the approver as user.
The attack is as follows:
(The attacker could have alternately used a similar bigBang attacker contract approach for removing the yieldbox shares in step 4 as in #933 )
 > 0xRektora (Tapioca) confirmed
