summaryrefslogtreecommitdiff
path: root/48/ab81ff1fe395a23909204e930e9e8494733c32
blob: 268123fa775664d45a3bc98cd06fa7a9fd99b36b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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&#39;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, &quot;Tamas Blummer&quot=
; &lt;<a href=3D"mailto:tamas@bitsofproof.com">tamas@bitsofproof.com</a>&gt=
; 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--