A race attack is a type of double spend attack aimed at anyone who accepts a cryptocurrency payment before it is confirmed in a block. The attacker sends one transaction paying the merchant and, almost at the same moment, a conflicting transaction that spends the same coins back to an address the attacker controls, often with a higher fee. If miners include the second transaction first, the payment to the merchant becomes invalid after the goods have been handed over.
The attack works only against zero-confirmation transactions, since both versions wait in the mempool until one is mined. Features such as Replace-by-Fee (RBF) make it easier. The main defence is to wait for one or more confirmations before releasing goods, especially for larger amounts. A related variant, the Finney attack, relies on a miner holding a pre-mined block.
Ref 1070001261