Test: Add P2SH scriptSig stack-size boundary tests #36465

pull benthecarman wants to merge 2 commits into bitcoin:master from benthecarman:p2sh-stack-size-boundary changing 2 files +19 −0
  1. benthecarman commented at 5:59 AM on October 8, 2026: contributor

    VerifyScript runs a P2SH scriptPubKey on the stack the scriptSig leaves before handling the redeemScript. The 20-byte push in HASH160 <20> EQUAL adds one item, so a scriptSig that leaves 1,000 items fails with STACK_SIZE, while 999 items is valid.

    An implementation that checks the redeemScript hash without running the scriptPubKey accepts the 1,000-item spend. No existing vector leaves the scriptSig at this boundary, so such an implementation can pass every row.

    Add 999 and 1,000 item cases with P2SH and WITNESS, and the 1,000 item case with no flags, which fails the same way because the scriptPubKey always runs.

    Also add the case as a feature_taproot spender, so its dump can be added to the script assets (bitcoin-core/qa-assets#297).

    These were discovered by finding gaps in an alternate implementation (rbitcoin)

  2. DrahtBot added the label Tests on Oct 8, 2026
  3. DrahtBot commented at 5:59 AM on October 8, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. brunoerg commented at 12:30 PM on October 8, 2026: contributor

    Can you please remove the LLM as co-author? See AI policy

  5. Test: Add P2SH scriptSig stack-size boundary tests
    VerifyScript runs a P2SH scriptPubKey on the stack the scriptSig
    leaves before handling the redeemScript. The 20-byte push in
    HASH160 <20> EQUAL adds one item, so a scriptSig that leaves 1,000
    items fails with STACK_SIZE, while 999 items is valid.
    
    An implementation that checks the redeemScript hash without running
    the scriptPubKey accepts the 1,000-item spend. No existing vector
    leaves the scriptSig at this boundary, so such an implementation can
    pass every row.
    
    Add 999 and 1,000 item cases with P2SH and WITNESS, and the 1,000
    item case with no flags, which fails the same way because the
    scriptPubKey always runs.
    6002e8c70f
  6. benthecarman force-pushed on Oct 8, 2026
  7. Test: Add P2SH stack size case to taproot test
    Add a feature_taproot spender whose P2SH scriptSig leaves 999 items
    on success and 1,000 on failure. The scriptPubKey runs on that stack,
    and its 20-byte push makes the 1,000-item spend exceed the stack size
    limit. An implementation that only compares the redeemScript hash
    accepts it.
    
    Naming the case lets its dump be added to the script assets.
    2ba00d5b5d
  8. DrahtBot added the label CI failed on Oct 8, 2026
  9. DrahtBot removed the label CI failed on Oct 8, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-08 23:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me