summaryrefslogtreecommitdiff
path: root/a5/19a888f31257f97caf0a11cfd8809ffacd7415
blob: f5c6c5382df90326f8269a6200340e8e7cf1a417 (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
Return-Path: <roconnor@blockstream.io>
Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org
	[172.17.192.35])
	by mail.linuxfoundation.org (Postfix) with ESMTPS id E5F6B2C
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Wed,  4 Jan 2017 03:14:16 +0000 (UTC)
X-Greylist: whitelisted by SQLgrey-1.7.6
Received: from mail-qt0-f175.google.com (mail-qt0-f175.google.com
	[209.85.216.175])
	by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7434E110
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Wed,  4 Jan 2017 03:14:15 +0000 (UTC)
Received: by mail-qt0-f175.google.com with SMTP id k15so241475586qtg.3
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Tue, 03 Jan 2017 19:14:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=blockstream-io.20150623.gappssmtp.com; s=20150623;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=i8YLaAdhU3c42VM/sfkBB5MzRaJcjOb5G8fcWD4N/jc=;
	b=Kk3E1jI6BxVU2Ult2MrhdUg5bTJ0Y+efT/zt/CCGQDSHIWPZF1DkR2T1uKd2+x3+68
	Wkb6JjSugfm27w31uK7jVxPCVr5LVWpYhBiYMu43Mv/zAJEfdSI4bErhRHvI5VtGOgnL
	TmgFXhyuWF2XKCAKrEq1u32sI8AAr9EpMeqOEaI58C/8BF+cbMuolPRVVbHGFvqXql3Y
	cERf9FtB0xDhUWBZ+3wh4rtw2BpmKVkhNFJ3LBizAr21JBomcmpK96r4KkE5skdQ3rSa
	rJRJ97qTKl7jJuGJEloCwqe9b/+3MZ76s1dHbPOoSX7ExY1caxhLJwWFN55Lo2I40htx
	uXTg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=i8YLaAdhU3c42VM/sfkBB5MzRaJcjOb5G8fcWD4N/jc=;
	b=DiWpH9l1eX1TiNREalN+vLDGTHtyIasTXDDu2NHaK3dGzzDb3s6sftHiMOsb/s3CF2
	zTCbnRS16RSZCjpJELTcWgasIeC2uyJONs/CXMuJv63QbV70AL70b/nsjikwqrxP15FR
	RusDywf/I27/hh2HyBi+rQMcAem7xRgxOQtJpXJyo58+WLj9YdoftRckEBUeIcxKyE/k
	FnUCgdgMqa15DMXt4edLUW+X/TrbUcadwdAvvr+u7S5zGZQmp9JqQAcGAejOceN6XMpH
	1FscyihMWD9XRhzcbADK+UBsw7LRai1EtroohYJfMfJ7HQivV1/eUcfMjmSVYK3c99D/
	ofcA==
X-Gm-Message-State: AIkVDXLymzA9khU1je4a6eI7fGSee4CIbsV2MWU65yxtprZxwynUM1J8tsxqAQQJsbVBVN93OgIPMDr7azS1ydcM
X-Received: by 10.237.34.116 with SMTP id o49mr59857537qtc.37.1483499654669;
	Tue, 03 Jan 2017 19:14:14 -0800 (PST)
MIME-Version: 1.0
Received: by 10.12.130.133 with HTTP; Tue, 3 Jan 2017 19:13:54 -0800 (PST)
In-Reply-To: <CAD5xwhg3QeHZF1Oepo3dnCAth0EO3wCqyeT4a21gQ2uxZ5dTfQ@mail.gmail.com>
References: <mailman.11263.1483391161.31141.bitcoin-dev@lists.linuxfoundation.org>
	<400152B9-1838-432A-829E-13E4FC54320C@gmail.com>
	<CAD5xwhjHFzFzKws10TG-XioZoRVZ_oZbMF_xDOy5xNWtzFTsEw@mail.gmail.com>
	<6A91D4E4-750D-42C0-B593-3D5014B8A3F7@xbt.hk>
	<CAD5xwhg3QeHZF1Oepo3dnCAth0EO3wCqyeT4a21gQ2uxZ5dTfQ@mail.gmail.com>
From: "Russell O'Connor" <roconnor@blockstream.io>
Date: Tue, 3 Jan 2017 22:13:54 -0500
Message-ID: <CAMZUoK=-3dGapPQTfKdd4oMQukiTyN1v123Yjo4ihO6YOHuBZQ@mail.gmail.com>
To: Jeremy <jlrubin@mit.edu>, 
	Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Content-Type: multipart/alternative; boundary=001a113e7bf6f1076205453c2dee
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID, HTML_MESSAGE, RCVD_IN_DNSWL_LOW,
	RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	smtp1.linux-foundation.org
Cc: Steve Davis <steven.charles.davis@gmail.com>
Subject: Re: [bitcoin-dev] Script Abuse Potential?
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Wed, 04 Jan 2017 03:14:17 -0000

--001a113e7bf6f1076205453c2dee
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

For the record, the OP_CAT limit of 520 bytes was added by Satoshi
<https://github.com/bitcoin/bitcoin/commit/4bd188c4383d6e614e18f79dc337fbab=
e8464c82#diff-8458adcedc17d046942185cb709ff5c3R425>
on the famous August 15, 2010 "misc" commit, at the same time that OP_CAT
was disabled.
The previous limit was 5000 bytes.

On Tue, Jan 3, 2017 at 7:13 PM, Jeremy via bitcoin-dev <
bitcoin-dev@lists.linuxfoundation.org> wrote:

> Sure, was just upper bounding it anyways. Even less of a problem!
>
>
> RE: OP_CAT, not as OP_CAT was specified, which is why it was disabled. As
> far as I know, the elements alpha proposal to reenable a limited op_cat t=
o
> 520 bytes is somewhat controversial...
>
>
>
> --
> @JeremyRubin <https://twitter.com/JeremyRubin>
> <https://twitter.com/JeremyRubin>
>
> On Mon, Jan 2, 2017 at 10:39 PM, Johnson Lau <jl2012@xbt.hk> wrote:
>
>> No, there could only have not more than 201 opcodes in a script. So you
>> may have 198 OP_2DUP at most, i.e. 198 * 520 * 2 =3D 206kB
>>
>> For OP_CAT, just check if the returned item is within the 520 bytes limi=
t.
>>
>> On 3 Jan 2017, at 11:27, Jeremy via bitcoin-dev <
>> bitcoin-dev@lists.linuxfoundation.org> wrote:
>>
>> It is an unfortunate script, but can't actually
>> =E2=80=8Bdo
>>  that much
>> =E2=80=8B it seems=E2=80=8B
>> . The MAX_SCRIPT_ELEMENT_SIZE =3D 520 Bytes.
>> =E2=80=8B Thus, it would seem the worst you could do with this would be =
to (10000-520*2)*520*2
>> bytes  ~=3D~ 10 MB.
>>
>> =E2=80=8BMuch more concerning would be the op_dup/op_cat style bug, whic=
h under a
>> similar script =E2=80=8Bwould certainly cause out of memory errors :)
>>
>>
>>
>> --
>> @JeremyRubin <https://twitter.com/JeremyRubin>
>> <https://twitter.com/JeremyRubin>
>>
>> On Mon, Jan 2, 2017 at 4:39 PM, Steve Davis via bitcoin-dev <
>> bitcoin-dev@lists.linuxfoundation.org> wrote:
>>
>>> Hi all,
>>>
>>> Suppose someone were to use the following pk_script:
>>>
>>> [op_2dup, op_2dup, op_2dup, op_2dup, op_2dup, ...(to limit)...,
>>> op_2dup, op_hash160, <addr_hash>, op_equalverify, op_checksig]
>>>
>>> This still seems to be valid AFAICS, and may be a potential attack
>>> vector?
>>>
>>> Thanks.
>>>
>>>
>>> _______________________________________________
>>> bitcoin-dev mailing list
>>> bitcoin-dev@lists.linuxfoundation.org
>>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>>>
>>>
>> _______________________________________________
>> bitcoin-dev mailing list
>> bitcoin-dev@lists.linuxfoundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>>
>>
>>
>
> _______________________________________________
> bitcoin-dev mailing list
> bitcoin-dev@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>
>

--001a113e7bf6f1076205453c2dee
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>For the record, the OP_CAT limit of 520 bytes was <a =
href=3D"https://github.com/bitcoin/bitcoin/commit/4bd188c4383d6e614e18f79dc=
337fbabe8464c82#diff-8458adcedc17d046942185cb709ff5c3R425">added by Satoshi=
</a> on the famous August 15, 2010 &quot;misc&quot; commit, at the same tim=
e that OP_CAT was disabled.<br></div>The previous limit was 5000 bytes.<br>=
<div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Tue, Jan =
3, 2017 at 7:13 PM, Jeremy via bitcoin-dev <span dir=3D"ltr">&lt;<a href=3D=
"mailto:bitcoin-dev@lists.linuxfoundation.org" target=3D"_blank">bitcoin-de=
v@lists.linuxfoundation.org</a>&gt;</span> wrote:<br><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr"><div style=3D"font-family:arial,helvetica,sans-se=
rif;font-size:small;color:#000000">Sure, was just upper bounding it anyways=
. Even less of a problem!</div><div style=3D"font-family:arial,helvetica,sa=
ns-serif;font-size:small;color:#000000"><br></div><div style=3D"font-family=
:arial,helvetica,sans-serif;font-size:small;color:#000000"><br></div><div s=
tyle=3D"font-family:arial,helvetica,sans-serif;font-size:small;color:#00000=
0">RE: OP_CAT, not as OP_CAT was specified, which is why it was disabled. A=
s far as I know, the elements alpha proposal to reenable a limited op_cat t=
o 520 bytes is somewhat controversial...</div><div style=3D"font-family:ari=
al,helvetica,sans-serif;font-size:small;color:#000000"><br></div><div style=
=3D"font-family:arial,helvetica,sans-serif;font-size:small;color:#000000"><=
br></div><div class=3D"gmail_extra"><br clear=3D"all"><div><div class=3D"m_=
6723432281491834920m_-6203106839964574959gmail_signature" data-smartmail=3D=
"gmail_signature"><div dir=3D"ltr">--<br><a href=3D"https://twitter.com/Jer=
emyRubin" target=3D"_blank">@JeremyRubin</a><a href=3D"https://twitter.com/=
JeremyRubin" target=3D"_blank"></a></div></div></div><div><div class=3D"h5"=
>
<br><div class=3D"gmail_quote">On Mon, Jan 2, 2017 at 10:39 PM, Johnson Lau=
 <span dir=3D"ltr">&lt;<a href=3D"mailto:jl2012@xbt.hk" target=3D"_blank">j=
l2012@xbt.hk</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div s=
tyle=3D"word-wrap:break-word"><div>No, there could only have not more than =
201 opcodes in a script. So you may have 198 OP_2DUP at most, i.e. 198 * 52=
0 * 2 =3D 206kB</div><div><br></div><div>For OP_CAT, just check if the retu=
rned item is within the 520 bytes limit.</div><div><div class=3D"m_67234322=
81491834920m_-6203106839964574959h5"><br><div><blockquote type=3D"cite"><di=
v>On 3 Jan 2017, at 11:27, Jeremy via bitcoin-dev &lt;<a href=3D"mailto:bit=
coin-dev@lists.linuxfoundation.org" target=3D"_blank">bitcoin-dev@lists.lin=
uxfounda<wbr>tion.org</a>&gt; wrote:</div><br class=3D"m_672343228149183492=
0m_-6203106839964574959m_659871600986875938Apple-interchange-newline"><div>=
<div dir=3D"ltr"><div style=3D"font-family:arial,helvetica,sans-serif;font-=
size:small"><span style=3D"font-family:arial,sans-serif;color:rgb(34,34,34)=
;font-size:12.800000190734863px">It is an unfortunate script, but can&#39;t=
 actually=C2=A0</span><div style=3D"display:inline">=E2=80=8Bdo</div><span =
style=3D"font-family:arial,sans-serif;color:rgb(34,34,34);font-size:12.8000=
00190734863px">=C2=A0that much</span><div style=3D"display:inline">=E2=80=
=8B it seems=E2=80=8B</div><span style=3D"font-family:arial,sans-serif;colo=
r:rgb(34,34,34);font-size:12.800000190734863px">. The MAX_SCRIPT_ELEMENT_SI=
ZE =3D 520 Bytes.</span><div style=3D"font-family:arial,sans-serif;color:rg=
b(34,34,34);font-size:12.800000190734863px;display:inline"><font face=3D"ar=
ial, helvetica, sans-serif">=E2=80=8B Thus, it would seem the worst you cou=
ld do with this would be to=C2=A0</font>(10000-520*2)*520*2 bytes =C2=A0~=
=3D~ 10 MB.</div></div><div style=3D"font-size:12.800000190734863px"><br></=
div><div style=3D"font-size:12.800000190734863px"><div style=3D"font-family=
:arial,helvetica,sans-serif;font-size:small">=E2=80=8BMuch more concerning =
would be the op_dup/op_cat style bug, which under a similar script =E2=80=
=8Bwould certainly cause out of memory errors :)</div><div><br></div></div>=
</div><div class=3D"gmail_extra"><br clear=3D"all"><div><br clear=3D"all"><=
div><div class=3D"m_6723432281491834920m_-6203106839964574959m_659871600986=
875938gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr">=
--<br><a href=3D"https://twitter.com/JeremyRubin" target=3D"_blank">@Jeremy=
Rubin</a><a href=3D"https://twitter.com/JeremyRubin" target=3D"_blank"></a>=
</div></div></div>
</div>
<br><div class=3D"gmail_quote">On Mon, Jan 2, 2017 at 4:39 PM, Steve Davis =
via bitcoin-dev <span dir=3D"ltr">&lt;<a href=3D"mailto:bitcoin-dev@lists.l=
inuxfoundation.org" target=3D"_blank">bitcoin-dev@lists.linuxfounda<wbr>tio=
n.org</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style=3D=
"word-wrap:break-word"><div><div style=3D"color:rgb(34,34,34);font-family:a=
rial,sans-serif;font-size:12.800000190734863px">Hi all,</div><div style=3D"=
color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8000001907348=
63px"><br></div><div style=3D"color:rgb(34,34,34);font-family:arial,sans-se=
rif;font-size:12.800000190734863px">Suppose someone were to use the followi=
ng pk_script:</div><div style=3D"color:rgb(34,34,34);font-family:arial,sans=
-serif;font-size:12.800000190734863px"><br></div><div class=3D"m_6723432281=
491834920m_-6203106839964574959m_659871600986875938m_-8615729711671762748m_=
8591747901013163489gmail_signature" style=3D"color:rgb(34,34,34);font-famil=
y:arial,sans-serif;font-size:12.800000190734863px"><div dir=3D"ltr">[op_2du=
p, op_2dup, op_2dup, op_2dup, op_2dup, ...(to limit)..., op_2dup,=C2=A0op_h=
ash160, &lt;addr_hash&gt;, op_equalverify, op_checksig]</div><div dir=3D"lt=
r"><br></div><div>This still seems to be valid AFAICS, and may be a potenti=
al attack vector?</div><div><br></div><div>Thanks.</div></div></div><div><b=
r></div></div><br>______________________________<wbr>_________________<br>
bitcoin-dev mailing list<br>
<a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org" target=3D"_blank">=
bitcoin-dev@lists.linuxfoundat<wbr>ion.org</a><br>
<a href=3D"https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev" =
rel=3D"noreferrer" target=3D"_blank">https://lists.linuxfoundation.<wbr>org=
/mailman/listinfo/bitcoin-d<wbr>ev</a><br>
<br></blockquote></div><br></div>
______________________________<wbr>_________________<br>bitcoin-dev mailing=
 list<br><a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org" target=3D=
"_blank">bitcoin-dev@lists.linuxfoundat<wbr>ion.org</a><br><a href=3D"https=
://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev" target=3D"_blank=
">https://lists.linuxfoundation.<wbr>org/mailman/listinfo/bitcoin-d<wbr>ev<=
/a><br></div></blockquote></div><br></div></div></div></blockquote></div><b=
r></div></div></div></div>
<br>______________________________<wbr>_________________<br>
bitcoin-dev mailing list<br>
<a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-dev@lists.=
<wbr>linuxfoundation.org</a><br>
<a href=3D"https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev" =
rel=3D"noreferrer" target=3D"_blank">https://lists.linuxfoundation.<wbr>org=
/mailman/listinfo/bitcoin-<wbr>dev</a><br>
<br></blockquote></div><br></div></div></div>

--001a113e7bf6f1076205453c2dee--