Subject: Re: [bitcoin-dev] Script Abuse Potential?

From: "Russell O'Connor" <[email-masked]>
Date: Tue, 3 Jan 2017 22:13:54 -0500

For the record, the OP_CAT limit of 520 bytes was added by Satoshi
<https://github.com/bitcoin/bitcoin/commit/4bd188c4383d6e614e18f79dc337fbabe8464c82#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 <
[email-masked]> 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 to
> 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 <[email-masked]> 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 = 206kB
>>
>> For OP_CAT, just check if the returned item is within the 520 bytes limit.
>>
>> On 3 Jan 2017, at 11:27, Jeremy via bitcoin-dev <
>> [email-masked]> wrote:
>>
>> It is an unfortunate script, but can't actually
>> ​do
>>  that much
>> ​ it seems​
>> . The MAX_SCRIPT_ELEMENT_SIZE = 520 Bytes.
>> ​ Thus, it would seem the worst you could do with this would be to (10000-520*2)*520*2
>> bytes  ~=~ 10 MB.
>>
>> ​Much more concerning would be the op_dup/op_cat style bug, which under a
>> similar script ​would 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 <
>> [email-masked]> 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
>>> [email-masked]
>>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>>>
>>>
>> _______________________________________________
>> bitcoin-dev mailing list
>> [email-masked]
>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>>
>>
>>
>
> _______________________________________________
> bitcoin-dev mailing list
> [email-masked]
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>
>