I was recently looking at the safest way to set up an online bitcoin service. When looking for security concerns I ran across this post on stackexchange What are the risks of running an online store via a bitcoind connection using less than the minimum of 8 connections? under the main question Stephen Gornick talks about how allowing inbound connections on 0 conf could open you up to huge double spends. I looked all over for the reason for this but was hoping someone could explain this vulnerability to me.
The attack is this simple:
You connect to both the merchant and every major mining pool.
At the same time, you send a transaction paying the merchant to the merchant and a conflicting transaction that pays yourself to every major mining pool.
The merchant sees the transaction paying them, and accepts it with zero confirmations.
The mining pools see the transaction paying yourself first, so they try to work that transaction into blocks. Eventually, one of them succeeds and the merchant will never get paid.
If you accept payments with zero confirmations, you should connect directly to multiple points in the Bitcoin network as close to major mining pools as possible and monitor for any conflicting transactions -- even if seen later. (There are other things you must do too. It's not trivial.)