Version 0.8 of the Satoshi client uses a different method to handle transactions, so FetchINputs() is not present anymore.
And it's probably protected against this specific attack. I'm going to review the new code.
I have reviewed the current Master branch (which is the base of the 0.8 release) and I found that
the vulnerability is still present.
- tx.HaveInputs(view) in CTxMemPool::accept() retrieves the compressed format of all transactions referred by prevouts.
The main difference is that referred prevouts must not have been spent.
None of the 4 possible attacks listed requires prevouts to be spent. Since the attacke is prepared by sending big transactions, and these transactions contain many outputs to make them big, they are almost incompressible with the CTxOutCompressor class.
The only drawback is that in 0.8, if the attacker wants to redo the attack, a new attack could required a new preparation stage (since the attacking transaction could have spent the prepared prevouts).
Pieter's 0.8 code is based on the assumption that transactions get shorter as outputs gets consumed in time.
The TFMEA attack uses a transaction that refer to parent transactions that have none of their outputs spent, so basically no compression can be applied.
Even if a transaction is dissected into independent cached prevouts (instead of a single CCoins for the whole transaction), then the attacker could create a non-standard transaction with a single prevout with a huge output script. This reduces the 4 TFMEA attacks to an attacker capable of issuing non-standard transactions in blocks (which is possible today using direct connections to miners).
My conclusion: a completely proactive and formally provable protection measure against memory exhaustion attacks in transaction processing would be to
reduce the maximum transaction size to 100 Kbytes or so. That would reduce both the RAM required to load each prevout and the number of prevouts a transaction may request, totaling to 200 Mbytes.
We are still capable of doing it now, using the delayed hard fork feature Gavin has added.
EDIT: Apparently reducing the max Tx size
is NOT a hardfork but a softfork ("changes which strictly reduce the set of acceptable things" (gmaxwell, 2013))
Keep in mind that there will be many people who will implement the Bitcoin protocol in a variety of languages, and most of them will not pay attention to memory consumption.
I urge people to
vote for reduction of the maximum transaction size from 1 Mb to 100 Kbytes.
"That's one small step for Bitcoin now, one giant leap for its future"