Submitted by jayjonah8
In TimeswapPair.sol, the lend() 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 totalClaims bonds,  insurance and reserves assets) also violates the Checks Effects Interactions best practices further widening the attack surface.
The callback Callback.lend(asset, xIncrease, data); should be placed at the end of the lend() function after all state updates have taken place.
Mathepreneur (Timeswap) confirmed and resolved:
