Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YHw10-0006rg-1s for bitcoin-development@lists.sourceforge.net; Sun, 01 Feb 2015 15:00:46 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.213.178 as permitted sender) client-ip=209.85.213.178; envelope-from=pieter.wuille@gmail.com; helo=mail-ig0-f178.google.com; Received: from mail-ig0-f178.google.com ([209.85.213.178]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YHw0y-0008AY-Si for bitcoin-development@lists.sourceforge.net; Sun, 01 Feb 2015 15:00:46 +0000 Received: by mail-ig0-f178.google.com with SMTP id hl2so12063745igb.5 for ; Sun, 01 Feb 2015 07:00:39 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.107.41.212 with SMTP id p203mr17899230iop.54.1422802839534; Sun, 01 Feb 2015 07:00:39 -0800 (PST) Received: by 10.50.20.229 with HTTP; Sun, 1 Feb 2015 07:00:39 -0800 (PST) Received: by 10.50.20.229 with HTTP; Sun, 1 Feb 2015 07:00:39 -0800 (PST) In-Reply-To: References: Date: Sun, 1 Feb 2015 11:00:39 -0400 Message-ID: From: Pieter Wuille To: Tamas Blummer Content-Type: multipart/alternative; boundary=001a1141f186d60419050e08197e X-Spam-Score: -0.6 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (pieter.wuille[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 1.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1YHw0y-0008AY-Si Cc: Bitcoin Dev Subject: Re: [Bitcoin-development] var_int ambiguous serialization consequences X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Feb 2015 15:00:46 -0000 --001a1141f186d60419050e08197e Content-Type: text/plain; charset=ISO-8859-1 Hashes are always computed by reserializing data structures, never by hashing wire data directly. This has been the case in every version of the reference client's code that I know of. This even meant that for example a block of 999999 bytes with non-shortest length for the transaction count could be over the mazimum block size, but still be valid. As Wladimir says, more recently we switched to just failing to deserialize (by throwing an exception) whenever a non-shortest form is used. On Feb 1, 2015 1:34 AM, "Tamas Blummer" wrote: > I wonder of consequences if var_int is used in its longer than necessary > forms (e.g encoding 1 as 0xfd0100 instead of 0x01) > > This is already of interest if applying size limit to a block, since > transaction count is var_int but is not part of the hashed header or the > merkle tree. > > It could also be used to create variants of the same transaction message > by altered representation of txIn and txout counts, that would remain valid > provided signatures validate with the shortest form, as that is created > while re-serializing for signature hashing. An implementation that holds > mempool by raw message hashes could be tricked to believe that a modified > encoded version of the same transaction is a real double spend. One could > also mine a valid block with transactions that have a different hash if > regularly parsed and re-serialized. An SPV client could be confused by such > a transaction as it was present in the merkle tree proof with a different > hash than it gets for the tx with its own serialization or from the raw > message. > > Tamas Blummer > Bits of Proof > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming. The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > --001a1141f186d60419050e08197e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Hashes are always computed by reserializing data structures,= never by hashing wire data directly. This has been the case in every versi= on of the reference client's code that I know of.

This even meant that for example a block of 999999 bytes wit= h non-shortest length for the transaction count could be over the mazimum b= lock size, but still be valid.

As Wladimir says, more recently we switched to just failing = to deserialize (by throwing an exception) whenever a non-shortest form is u= sed.

On Feb 1, 2015 1:34 AM, "Tamas Blummer"= ; <tamas@bitsofproof.com>= ; wrote:
I wonder of consequences if var_int is used = in its longer than necessary forms (e.g encoding 1 as 0xfd0100 instead of 0= x01)

This is already of interest if applying size = limit to a block, since transaction count is var_int but is not part of the= hashed header or the merkle tree.

It could also b= e used to create variants of the same transaction message by altered repres= entation of txIn and txout counts, that would remain valid provided signatu= res validate with the shortest form, as that is created while re-serializin= g for signature hashing. An implementation that holds mempool by raw messag= e hashes could be tricked to believe that a modified encoded version of the= same transaction is a real double spend. One could also mine a valid block= with transactions that have a different hash if regularly parsed and re-se= rialized. An SPV client could be confused by such a transaction as it was p= resent in the merkle tree proof with a different hash than it gets for the = tx with its own serialization or from the raw message.

Tamas Blummer
Bits of Proof


--------------------------------------------------------------------= ----------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is you= r
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a<= br> look and join the conversation now. http://goparallel.sourceforge.net/
_______= ________________________________________
Bitcoin-development mailing list
Bitcoin-develo= pment@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-de= velopment

--001a1141f186d60419050e08197e--