It is not "Electrum design's" flaw, it is "SPV design's" flaw.
Is Electrum
SPV? I thought that Electrum used the Electrum protocol; Ive never heard it referred to as SPV. I just double-checked the
Electrum wiki article (
current version permalink), Ctrl-F SPV and simpli; if Electrum is actually SPV, that information should probably be added to the article by an Electrum topical expert.
The logical way, and the secure-by-default way is for a light wallet to store the newly-created transaction and its txid, and then ask the server for its status by txid.
The idea is that the SPV client does not know what transactions belong to it since it neither has the blockchain nor a mempool.
Non sequitur. Doesnt know that
a transaction that it created belongs to it does not follow from has neither the blockchain nor a mempool.
It would follow from completely stateless, but Electrum is not stateless. It has some sort of a tx database. And I dont think a useful wallet ever could be stateless.
You sometimes receive a tx, in which case you do not know the txid beforehand to request based on that.
Thats orthogonal to the case where you
do know the txid.
Lets not forget that we are discussing a SPV client not a full node. By definition a SPV client was never expected to verify signatures of any transaction since it does not have a UTXO set.
In my opinion, a light client should always verify
what it reasonably can. Choosing not to verify the
internal validity of a transaction, within its four corners, means blindly trusting the server not to hand you any garbagewith the results seen here, in this high-severity security bug!
Although a light client by definition cannot validate all blockchain consensus rules, it can easily validate a transaction within its four corners to assure that its not
facially invalid.
(To my understanding, ever since Satoshis whitepaper, SPV clients have always been
expected to validate the transaction from block headers, through a Merkle proof. I think that this level of validation reasonably implies also checking the transactions internal validity, within its four corners. This level of validation is still vulnerable to some potential attacks, but absolutely nothing like what is seen here.)
Every workaround that is added to "force-verify" signatures will first contradict the "Simplified" part and second will come with its own load of issues which would require more workarounds that will contradict the "Simplified" part of SPV even more.
How hard is it to verify a signature? It is an operation that takes milliseconds even on an embedded CPU, and it easily can be done from stack buffers with no dynamic memory allocation.
Simple.I think that to begin with, the code should be designed to validate untrusted data. If properly designed, there is no every workaround; validity checks occur naturally, at every point on the network security boundary where the client says, Okay, an untrusted party on the network just handed me a bag of bits; what is it? If no such boundary is well-defined at the design stage, then that, itself, is a security problem.
Personal note: This is of peculiar interest to me, as Ive been slowly drafting a topic OP about my urgent need for a new light wallet. Electrum wasnt under consideration anyway, as Im hoping for a BIP 157/158 wallet with TUI written in C or Rust. I will add to my list of requirements, The wallet must never in any circumstance accept facially invalid transactions from the network.