Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: fevirfevir on August 01, 2015, 10:40:15 AM



Title: The Easy Attack - What am I missing?
Post by: fevirfevir on August 01, 2015, 10:40:15 AM
Hi all,

While trying to understand how Bitcoin operates under the hood, I was wondering if it's not dead easy to cheat (in Bitcoin).

Suppose we have Alice and Bob, you may know them, and Alice wants to send 10 BTC to Bob. Suppose both have a Bitcoin client (https://en.bitcoin.it/wiki/Clients) running on their device. From what I understand, a client is build upon Bitcoin core. Bitcoin core contains all protocol rules (https://bitcoin.org/en/developer-guide), such as transaction and block rules (https://en.bitcoin.it/wiki/Protocol_rules).
Now, in short, if Alice wants to send Bob 10 BTC, her client verifies the transaction (tx message: https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages), the client broadcasts the transaction to peers/miners, who add the transaction into their block they're about to mine. The miner itself also performs a check (block message: https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages). If Alice wants to cheat (e.g. tries a double spend), it's either detected by her own client, or by the miner.

Now, suppose the following. Eve wants to get rich. Fast. She decides upon the following. She downloads the source code of Bitcoin Core and makes some adjustments in its protocol, particulalrly, all checks on tx and block messages will pass the check, no matter how the transaction or block looks like. She then compiles the code and has her home-brewn Eve-Bitcoin-client.
Now, Eve creates two addresses (A and B), both contain 0 Bitcoins. Then, she creates a transaction, which sends 1000 BTC from address A to B. She does not broadcast this transaction to the network. Instead, she starts mining a block (based on the latest block in the blockchain) which include her own transaction. Suppose Eve is lucky or very patient and finds the right hash. Her client performs a block checks (which passes all criteria, remember Eve's client) and broadcasts the block to the network. Since the hash is correct, it seems that the network will add Eve's block to the chain. Eve just created 1000 BTC out of thin air.

It sounds too obvious though - what am I missing? Are there additional checks? What are the exact criteria upon which a block is added to the chain, and who decides this?

Fevir.


Title: Re: The Easy Attack - What am I missing?
Post by: -ck on August 01, 2015, 10:47:24 AM
The block would be rejected by every single node it's sent to as every transaction included in the broadcast block is checked by every node it's sent to.


Title: Re: The Easy Attack - What am I missing?
Post by: fevirfevir on August 01, 2015, 11:01:44 AM
Thanks. Wasn't aware that every single node receiving a new block also checks the transactions in the new block. I assume each node also performs a "block message" (https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages) check upon receiving new blocks.

Another thought occured: what if Eve changes her input to 1000 (of account A) and then send that 1000 to B. But this (https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages) reads it becomes an orphan transaction, because there is no corresponding 'out' for Eve's 'input'.


Title: Re: The Easy Attack - What am I missing?
Post by: BurtW on August 01, 2015, 03:02:08 PM
Great first post.  I love your enthusiasm.  Reminds me of me when I first found out about Bitcoin.  You brightened my day.  Thanks.


Title: Re: The Easy Attack - What am I missing?
Post by: jl2012 on August 01, 2015, 06:43:55 PM

Another thought occured: what if Eve changes her input to 1000 (of account A) and then send that 1000 to B. But this (https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages) reads it becomes an orphan transaction, because there is no corresponding 'out' for Eve's 'input'.

This tx is obviously invalid, as the reason you mentioned. Except the 25BTC reward for each block, any attempt to generate bitcoin out of thin air is invalid.

A block containing any invalid tx is simply invalid. Miners mining invalid blocks are just wasting time and energy.


Title: Re: The Easy Attack - What am I missing?
Post by: dreamspark on August 03, 2015, 10:22:54 AM
The fact that every node would reject the attempt to just create bitcoin is what makes our little project so great. Traditional money systems allow slect individuals to do just that. Change the rules abit and create money out of thin air  ;)


Title: Re: The Easy Attack - What am I missing?
Post by: fairglu on August 04, 2015, 09:27:16 AM
Thanks. Wasn't aware that every single node receiving a new block also checks the transactions in the new block.

Bitcoin protocol being trustless means that the bitcoin code trusts no-one, so it checks everything before accepting it.

Most of the bitcoin kernel code is made up of a of checks that protect relatively few additions and subtractions.

This is completely different from centralized apps, where your bank app trusts the bank servers, your store app trusts the store servers, etc. and so perform only very minimal checks (only at the network connection level).