How Does Front-Running Occur in the Context of Smart Contracts?

Front-running in smart contracts occurs when a user, often a miner, observes a pending transaction and submits their own transaction with a higher gas fee to have it processed first. This allows them to profit from the information in the pending transaction.

For example, a front-runner could see a large buy order for a token and buy the token themselves at a lower price, only to sell it to the original buyer at a higher price.

How Does a CEX Distinguish between Legitimate Arbitrage and Malicious Front-Running?
How Does Latency Arbitrage Differ from True Front-Running on a CEX?
How Do Transaction Ordering Mechanisms on Blockchains Enable Front-Running?
Can an HFT Firm Be Accused of Front-Running, and under What Circumstances?
How Do Wash Trading and Spoofing Differ from Front-Running?
How Do Private Transaction Relays Prevent the Visibility Required for Front-Running?
Define ‘Front-Running’ and How It Exploits Low Finality in Trading
What Is the Significance of the Mempool in the Context of DeFi Front-Running?