Given enough resources, someone can reorder the transactions in the mempool to arrive at the result they need. This is a big concern in a system with a high volume of public transactions. Protecting against this comes down to the specific contract, and there are multiple ways to do this.
In this recipe, you will learn more about TOD attacks and some common places where you can avoid them.