diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-02-01 11:00:39 -0400 |
---|---|---|
committer | bitcoindev <bitcoindev@gnusha.org> | 2015-02-01 15:00:46 +0000 |
commit | e1428044884b9f0d1ea9a3008e4e6b77e428d20c (patch) | |
tree | 71bf2eeba22a4dcae77ec0801c7b8c87105975b0 | |
parent | e3cc662f0211248ed91e162dcd5999df773c5c33 (diff) | |
download | pi-bitcoindev-e1428044884b9f0d1ea9a3008e4e6b77e428d20c.tar.gz pi-bitcoindev-e1428044884b9f0d1ea9a3008e4e6b77e428d20c.zip |
Re: [Bitcoin-development] var_int ambiguous serialization consequences
-rw-r--r-- | 48/ab81ff1fe395a23909204e930e9e8494733c32 | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/48/ab81ff1fe395a23909204e930e9e8494733c32 b/48/ab81ff1fe395a23909204e930e9e8494733c32 new file mode 100644 index 000000000..268123fa7 --- /dev/null +++ b/48/ab81ff1fe395a23909204e930e9e8494733c32 @@ -0,0 +1,179 @@ +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 <pieter.wuille@gmail.com>) 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 <bitcoin-development@lists.sourceforge.net>; + 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: <D89EBAA3-ED78-4D9C-B693-FBBF27501938@bitsofproof.com> +References: <D89EBAA3-ED78-4D9C-B693-FBBF27501938@bitsofproof.com> +Date: Sun, 1 Feb 2015 11:00:39 -0400 +Message-ID: <CAPg+sBhmB9tZkOVdUstRYd4DAhNpFoirK-p7-yxVarbQzTqCkQ@mail.gmail.com> +From: Pieter Wuille <pieter.wuille@gmail.com> +To: Tamas Blummer <tamas@bitsofproof.com> +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 <bitcoin-development@lists.sourceforge.net> +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: <bitcoin-development.lists.sourceforge.net> +List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>, + <mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe> +List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development> +List-Post: <mailto:bitcoin-development@lists.sourceforge.net> +List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help> +List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>, + <mailto:bitcoin-development-request@lists.sourceforge.net?subject=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" <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 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 + +<p dir=3D"ltr">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.</p> +<p dir=3D"ltr">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.</p> +<p dir=3D"ltr">As Wladimir says, more recently we switched to just failing = +to deserialize (by throwing an exception) whenever a non-shortest form is u= +sed.</p> +<div class=3D"gmail_quote">On Feb 1, 2015 1:34 AM, "Tamas Blummer"= +; <<a href=3D"mailto:tamas@bitsofproof.com">tamas@bitsofproof.com</a>>= +; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D= +"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style= +=3D"word-wrap:break-word"><div>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)</div><div><br></div><div>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.</div><div><br></div><div>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.</div><br><div> +<div style=3D"color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-st= +yle:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;lin= +e-height:normal;text-align:start;text-indent:0px;text-transform:none;white-= +space:normal;word-spacing:0px">Tamas Blummer</div><div style=3D"color:rgb(0= +,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:n= +ormal;font-weight:normal;letter-spacing:normal;line-height:normal;text-alig= +n:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing= +:0px">Bits of Proof</div><div style=3D"color:rgb(0,0,0);font-family:Helveti= +ca;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;= +letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;t= +ext-transform:none;white-space:normal;word-spacing:0px"><br></div></div></d= +iv><br>--------------------------------------------------------------------= +----------<br> +Dive into the World of Parallel Programming. The Go Parallel Website,<br> +sponsored by Intel and developed in partnership with Slashdot Media, is you= +r<br> +hub for all things parallel software development, from weekly thought<br> +leadership blogs to news, videos, case studies, tutorials and more. Take a<= +br> +look and join the conversation now. <a href=3D"http://goparallel.sourceforg= +e.net/" target=3D"_blank">http://goparallel.sourceforge.net/</a><br>_______= +________________________________________<br> +Bitcoin-development mailing list<br> +<a href=3D"mailto:Bitcoin-development@lists.sourceforge.net">Bitcoin-develo= +pment@lists.sourceforge.net</a><br> +<a href=3D"https://lists.sourceforge.net/lists/listinfo/bitcoin-development= +" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/bitcoin-de= +velopment</a><br> +<br></blockquote></div> + +--001a1141f186d60419050e08197e-- + + |