Submitted by GalloDaSballo
Because of an incorrect interpretation of calldata for the execute signature, we are able to bypass the _checkSender and perform arbitrary execute operations as Magnetar.
Market.execute uses the following signature:
For Calldata variables, the size 4:36 is going to be the length of the calldata. We can specify an arbitrary length that matches the value of any address that is whitelisted, or any address that were able to generate. This will allow us to bypass the check and perform arbitrary execution in the market.
After forging our length, we have bypassed the check, allowing us to execute, while having permissions/allowances from other users:
https://github.com/Tapioca-DAO/tapioca-periph/blob/2ddbcb1cde03b548e13421b2dba66435d2ac8eb5/contracts/Magnetar/Magnetar.sol#L256-L281
This will allow us to transfer any token that is approved to us, stealing them. We can proceed to mine an address with low enough zeros, or simply use a suitable system address for any chain, as the requirement for _checkSender(abi.decode(_actionCalldata[4:36], (address))) is simply to match the msg.sender.
An example would be the Optimism Portal on L2 which would have very low address; meaning we would be able to have a sufficient amount of operations there. Once we can bypass the check, we will be able to have Magnetar execute any market operation, such as transfers of other people tokens, allowing us to steal them.
The Coded POC shows how we can forge calldata to bypass the check, as long as we can use an address that matches the abi.decoding of the length:
The cost of the attack is the cost of finding an address that is small enough to steal all funds; As far as I can tell, this would take a few days on specialized hardware.
On certain chains, with system contracts (e.g. Optimism) the cost would be zero as we could act on behalf of the Portal and we would be able to use very small amount of data. 
Its also worth noting that Arbitrum (the base chain of the project), has no gas limit on blocks.
It may be necessary to remove execute from available commands as all commands will be performed by Magnetar.
en/de-code
0xWeiss (Tapioca) confirmed
