Bitcoin Forum
May 02, 2024, 04:05:57 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: protocol vulnerability?  (Read 1166 times)
kzv (OP)
Legendary
*
Offline Offline

Activity: 1722
Merit: 1285

OpenTrade - Open Source Cryptocurrency Exchange


View Profile WWW
April 08, 2016, 08:44:41 AM
 #1

Hi,
I'm learning the basics of Bitcoin protocol and have a question.

When i push raw transaction to the network, all nodes may read it for checking...

If some "bad-hacker" node will save my "scriptSig" for transaction inputs, but will change my "scriptPubKey" for outputs. Then the scammer may send a fake transaction to other nodes and there's a possibility to lose my money?


OpenTrade - Open Source Cryptocurrency Exchange
1714622757
Hero Member
*
Offline Offline

Posts: 1714622757

View Profile Personal Message (Offline)

Ignore
1714622757
Reply with quote  #2

1714622757
Report to moderator
1714622757
Hero Member
*
Offline Offline

Posts: 1714622757

View Profile Personal Message (Offline)

Ignore
1714622757
Reply with quote  #2

1714622757
Report to moderator
1714622757
Hero Member
*
Offline Offline

Posts: 1714622757

View Profile Personal Message (Offline)

Ignore
1714622757
Reply with quote  #2

1714622757
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, but full nodes are more resource-heavy, and they must do a lengthy initial syncing process. As a result, lightweight clients with somewhat less security are commonly used.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714622757
Hero Member
*
Offline Offline

Posts: 1714622757

View Profile Personal Message (Offline)

Ignore
1714622757
Reply with quote  #2

1714622757
Report to moderator
1714622757
Hero Member
*
Offline Offline

Posts: 1714622757

View Profile Personal Message (Offline)

Ignore
1714622757
Reply with quote  #2

1714622757
Report to moderator
1714622757
Hero Member
*
Offline Offline

Posts: 1714622757

View Profile Personal Message (Offline)

Ignore
1714622757
Reply with quote  #2

1714622757
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6571


Just writing some code


View Profile WWW
April 08, 2016, 11:41:05 AM
 #2

Hi,
I'm learning the basics of Bitcoin protocol and have a question.

When i push raw transaction to the network, all nodes may read it for checking...

If some "bad-hacker" node will save my "scriptSig" for transaction inputs, but will change my "scriptPubKey" for outputs. Then the scammer may send a fake transaction to other nodes and there's a possibility to lose my money?


Nope, not possible. The scriptsig, if using sighash all (the default), is a signature of the hash of the transaction. If part of the transaction is changed, the hash will no longer match and thus the signature will no longer be valid and thus the transaction ID invalid.

kzv (OP)
Legendary
*
Offline Offline

Activity: 1722
Merit: 1285

OpenTrade - Open Source Cryptocurrency Exchange


View Profile WWW
April 08, 2016, 12:04:16 PM
 #3

Hi,
I'm learning the basics of Bitcoin protocol and have a question.

When i push raw transaction to the network, all nodes may read it for checking...

If some "bad-hacker" node will save my "scriptSig" for transaction inputs, but will change my "scriptPubKey" for outputs. Then the scammer may send a fake transaction to other nodes and there's a possibility to lose my money?


Nope, not possible. The scriptsig, if using sighash all (the default), is a signature of the hash of the transaction. If part of the transaction is changed, the hash will no longer match and thus the signature will no longer be valid and thus the transaction ID invalid.

Thank you for responce.
Is there any documentation how "scriptSig" is constructing for given transaction?

OpenTrade - Open Source Cryptocurrency Exchange
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6571


Just writing some code


View Profile WWW
April 08, 2016, 12:44:41 PM
 #4

Nope, not possible. The scriptsig, if using sighash all (the default), is a signature of the hash of the transaction. If part of the transaction is changed, the hash will no longer match and thus the signature will no longer be valid and thus the transaction ID invalid.

Thank you for responce.
Is there any documentation how "scriptSig" is constructing for given transaction?
[/quote]
There is probably something about it on https://bitcoin.org/en/developer-documentation. Otherwise you can look in the code.

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4613



View Profile
April 08, 2016, 01:05:46 PM
Merited by ABCbits (2)
 #5

Is there any documentation how "scriptSig" is constructing for given transaction?

http://bitcoin.stackexchange.com/a/5241

https://en.bitcoin.it/w/images/en/7/70/Bitcoin_OpCheckSig_InDetail.png
kzv (OP)
Legendary
*
Offline Offline

Activity: 1722
Merit: 1285

OpenTrade - Open Source Cryptocurrency Exchange


View Profile WWW
April 08, 2016, 01:24:47 PM
 #6

Nope, not possible. The scriptsig, if using sighash all (the default), is a signature of the hash of the transaction. If part of the transaction is changed, the hash will no longer match and thus the signature will no longer be valid and thus the transaction ID invalid.

Thank you for responce.
Is there any documentation how "scriptSig" is constructing for given transaction?
There is probably something about it on https://bitcoin.org/en/developer-documentation. Otherwise you can look in the code.
[/quote]

Picture from https://bitcoin.org/en/developer-examples#offline-signing



It seems that signed only scriptPubKey for the previous transaction.
"PubKey Script" for the new transaction is not signed and new transaction is not signed too! So anyone may change scriptPubKey for unconfirmed transaction.  Sad

OpenTrade - Open Source Cryptocurrency Exchange
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6571


Just writing some code


View Profile WWW
April 08, 2016, 01:39:19 PM
 #7


Picture from https://bitcoin.org/en/developer-examples#offline-signing

-snip img-

It seems that signed only scriptPubKey for the previous transaction.
"PubKey Script" for the new transaction is not signed and new transaction is not signed too! So anyone may change scriptPubKey for unconfirmed transaction.  Sad
Nope. Read all of https://bitcoin.org/en/developer-guide#transactions

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4613



View Profile
April 08, 2016, 02:09:08 PM
 #8

Picture from https://bitcoin.org/en/developer-examples#offline-signing

- snip -

It seems that signed only scriptPubKey for the previous transaction.
"PubKey Script" for the new transaction is not signed and new transaction is not signed too! So anyone may change scriptPubKey for unconfirmed transaction.  Sad

Nope.

See all those arrows passing through the "Signed Data" box?  That means all those fields are included in what gets signed.

If you had read the paragraph after the picture, you would have known that there is more signed than just the scriptPubKey...

Quote
As illustrated above, the data that gets signed includes the txid and vout from the previous transaction. That information is included in the createrawtransaction raw transaction. But the data that gets signed also includes the pubkey script from the previous transaction, even though it doesn’t appear in either the unsigned or signed transaction.
hhanh00
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
April 08, 2016, 02:16:55 PM
 #9

If you had read the paragraph after the picture, you would have known that there is more signed than just the scriptPubKey...

Quote
As illustrated above, the data that gets signed includes the txid and vout from the previous transaction. That information is included in the createrawtransaction raw transaction. But the data that gets signed also includes the pubkey script from the previous transaction, even though it doesn’t appear in either the unsigned or signed transaction.


He's concerned that the signature doesn't cover the output of the current transaction - which it does for all signature types besides SIGHASH_NONE.

To be honest, I don't understand this drawing either. This explanation works better for me.

https://en.bitcoin.it/wiki/OP_CHECKSIG



kzv (OP)
Legendary
*
Offline Offline

Activity: 1722
Merit: 1285

OpenTrade - Open Source Cryptocurrency Exchange


View Profile WWW
April 08, 2016, 02:18:16 PM
 #10

Picture from https://bitcoin.org/en/developer-examples#offline-signing

- snip -

It seems that signed only scriptPubKey for the previous transaction.
"PubKey Script" for the new transaction is not signed and new transaction is not signed too! So anyone may change scriptPubKey for unconfirmed transaction.  Sad

Nope.

See all those arrows passing through the "Signed Data" box?  That means all those fields are included in what gets signed.

If you had read the paragraph after the picture, you would have known that there is more signed than just the scriptPubKey...

Quote
As illustrated above, the data that gets signed includes the txid and vout from the previous transaction. That information is included in the createrawtransaction raw transaction. But the data that gets signed also includes the pubkey script from the previous transaction, even though it doesn’t appear in either the unsigned or signed transaction.


I readed this.
ONLY data from the PREVIOUS transaction is signed!
Data in CURRENT transaction is not signet and not protected from changing.
Right?

OpenTrade - Open Source Cryptocurrency Exchange
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6571


Just writing some code


View Profile WWW
April 08, 2016, 02:23:52 PM
 #11


I readed this.
ONLY data from the PREVIOUS transaction is signed!
Data in CURRENT transaction is not signet and not protected from changing.
Right?

NO! With sighash all, all of the data in the current transaction, except for the signature itself, is signed. This prevents any transaction data from being changed.

kzv (OP)
Legendary
*
Offline Offline

Activity: 1722
Merit: 1285

OpenTrade - Open Source Cryptocurrency Exchange


View Profile WWW
April 08, 2016, 02:31:54 PM
 #12


I readed this.
ONLY data from the PREVIOUS transaction is signed!
Data in CURRENT transaction is not signet and not protected from changing.
Right?

NO! With sighash all, all of the data in the current transaction, except for the signature itself, is signed. This prevents any transaction data from being changed.

Where this wrote? Give me please link to any document or source code?

Now i can see only
Quote
includes the txid and vout from the previous transaction
and
Quote
also includes the pubkey script from the previous transaction

OpenTrade - Open Source Cryptocurrency Exchange
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6571


Just writing some code


View Profile WWW
April 08, 2016, 02:48:08 PM
 #13


I readed this.
ONLY data from the PREVIOUS transaction is signed!
Data in CURRENT transaction is not signet and not protected from changing.
Right?

NO! With sighash all, all of the data in the current transaction, except for the signature itself, is signed. This prevents any transaction data from being changed.

Where this wrote? Give me please link to any document or source code?

Now i can see only
Quote
includes the txid and vout from the previous transaction
and
Quote
also includes the pubkey script from the previous transaction

See https://bitcoin.org/en/developer-guide#signature-hash-types

It's also in the source somewhere.

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4613



View Profile
April 08, 2016, 07:47:15 PM
 #14

If you had read the paragraph after the picture, you would have known that there is more signed than just the scriptPubKey...

Quote
As illustrated above, the data that gets signed includes the txid and vout from the previous transaction. That information is included in the createrawtransaction raw transaction. But the data that gets signed also includes the pubkey script from the previous transaction, even though it doesn’t appear in either the unsigned or signed transaction.

He's concerned that the signature doesn't cover the output of the current transaction

Certainly, but he said it "seems that signed only scriptPubKey", and clearly that isn't true.  Therefore, it should be obvious to him, from reading the paragraph below the drawing, that he misunderstood the drawing.

See all those arrows passing through the "Signed Data" box?  That means all those fields are included in what gets signed.
I readed this.
ONLY data from the PREVIOUS transaction is signed!
Data in CURRENT transaction is not signet and not protected from changing.
Right?

No.  That is not right.

I can't tell if you are failing to pay attention, or if you are just trolling.

With sighash all, all of the data in the current transaction, except for the signature itself, is signed. This prevents any transaction data from being changed.

Which has already been explained 3 times, and several links have been included to provide additional details for better understanding.

I'm beginning to think we are being trolled.

NO! With sighash all, all of the data in the current transaction, except for the signature itself, is signed. This prevents any transaction data from being changed.

Where this wrote? Give me please link to any document or source code?
[/quote]

You have been provided several links.

The source code is in github.  Here:
https://github.com/bitcoin/bitcoin

Now i can see only
Quote
includes the txid and vout from the previous transaction
and
Quote
also includes the pubkey script from the previous transaction

If that's all you can see in this whole thread, then you are only looking for things that you can take out of context to create confusion.  I'm nearly certain you are just trolling now.

He's been told that the entire transaction is signed multiple times.  He's been supplied with links with additional details about what is signed.  And yet, he carefully searches through posts and links looking for small pieces that he can take out of context and then exclaim that only the inputs are signed.  Nonsense.
kzv (OP)
Legendary
*
Offline Offline

Activity: 1722
Merit: 1285

OpenTrade - Open Source Cryptocurrency Exchange


View Profile WWW
April 08, 2016, 09:35:08 PM
 #15

Thank you guys.
I realized my mistake. Your links are very useful for me. Sorry for my English ))

OpenTrade - Open Source Cryptocurrency Exchange
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!