11

From Nathaniel Popper's “Digital Gold : Bitcoin and the Inside Story of the Misfits and Millionaires Trying to Reinvent Money", this heavily edited (by me, for clarity) excerpt:

“In late July Gavin and Satoshi got an e-mail from ...a programmer from Germany going by the screen name ArtForz, ... had found a previously undiscovered weakness in the code that ...made it possible to spend Bitcoins in someone else’s wallet.”

“For now, don’t call it the ‘1 RETURN’ bug to anyone who doesn’t already know about it,” Satoshi wrote to Gavin.”

What is this 1 RETURN bug? It's obviously been patched, but I'm interested because the book doesn't delve into technical details.

(FWIW, I highly recommend buying this book).

1

1 Answer 1

11

Have a look at the early sources here: http://www.bitcointrading.com/forum/bitcoin-clients/original-bitcoin-source-code-archives/

there is a small piece of code in script.cpp:

    case OP_RETURN:
    {
        pc = pend;
    }
    break;

which allows to spend ANY UTXO with just a very simple scriptSig OP_1 OP_RETURN

3
  • Wow, what a monumental oversight. I'm not versed in C++, so can you clarify what's happening? It looks like if it's a 6a (op_return) push code is encountered, the code breaks, leaving op_true on the stack, making the Tx valid? Jun 17, 2015 at 16:49
  • Yes, in the early bitcoin versions OP_RETURN just finished the script evaluation without changing the stack value. So, the stack had 1 on the top. The other flaw in that version was concatenating scriptSig and scriptPubkey to one byte array and executing them as one script, not as two consecutive scripts. return EvalScript(txin.scriptSig + CScript(OP_CODESEPARATOR) + txout.scriptPubKey, txTo, nIn, nHashType); The bug was fixed by changing OP_RETURN opcode: now it finishes script execution as 'failed'
    – amaclin
    Jun 17, 2015 at 17:08
  • Wow, possibly the world's best example of Linus's Law en.wikipedia.org/wiki/Linus%27s_law Nov 3, 2022 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.