kernel: reject trailing bytes in object creation #36647

pull fametrano wants to merge 1 commits into bitcoin:master from fametrano:kernel-reject-trailing-bytes changing 3 files +17 −3
  1. fametrano commented at 8:12 AM on October 24, 2026: none

    btck_transaction_create and btck_block_create ignore any bytes after the serialized object, so the object's serialized length does not match the buffer.

    I return null when bytes remain, as for other malformed input, and say so in the header. Two new checks in test_kernel append one byte to a valid transaction and to a valid block. They fail on master and pass with the change. The other kernel tests and the unit tests pass.

    This is one of several PRs from a large audit of Bitcoin Core that I did with the help of LLM tools. The audit produced its evidence all at once, which is why the PRs arrive together. I understand each change fully and will answer review questions myself.

  2. kernel: reject trailing bytes in object creation
    btck_transaction_create and btck_block_create deserialize one object and
    ignore any bytes that follow it. The object's serialized length then
    differs from the buffer's.
    
    I return null when bytes remain after the object, as for other malformed
    input, and say so in the header. The kernel tests pass a valid
    transaction and a valid block with one extra byte.
    fc75592ed7
  3. DrahtBot added the label Validation on Oct 24, 2026
  4. DrahtBot commented at 8:12 AM on October 24, 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-->

    LLM Linter (✨ experimental)

    Possible places where comparison-specific test macros should replace generic comparisons:

    • src/test/kernel/test_kernel.cpp: BOOST_CHECK_THROW(Transaction{trailing_tx_data}, std::runtime_error) → Prefer BOOST_CHECK_EXCEPTION(..., HasReason{"..."}) to check the detailed error message.
    • src/test/kernel/test_kernel.cpp: BOOST_CHECK_THROW(Block{trailing_block_data}, std::runtime_error) → Prefer BOOST_CHECK_EXCEPTION(..., HasReason{"..."}) to check the detailed error message.

    <sup>2026-10-24 08:12:44</sup>

  5. sedited commented at 8:51 AM on October 26, 2026: contributor

    You are observing the current behaviour correctly, but absent a reported defect, I don't think there is any reason to change this. Closing.

  6. sedited closed this on Oct 26, 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-27 17:51 UTC

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