Submitted by jayjonah8
In TimeswapPair.sol, the pay() function has a callback to the msg.sender in the middle of the function while there are still updates to state that take place after the callback.  The lock modifier guards against reentrancy but not against cross function reentrancy.  Since the protocol implements Uniswap like functionality,  this can be extremely dangerous especially with regard to composability/interacting with other protocols and contracts.  The callback before important state changes (updates to reserves collateral and reserves assets) also violates the Checks Effects Interactions best practices further widening the attack surface.
The callback if (assetIn > 0) Callback.pay(asset, assetIn, data);  should be placed at the end of the pay() function after all state updates have taken place.
Mathepreneur (Timeswap) confirmed and resolved:
