bip174: add test case for an invalid valuedata due to its size #1971

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2025-09-psbt-invalid-data-size changing 1 files +5 −1
  1. brunoerg commented at 8:00 pm on September 18, 2025: none

    A PSBT should be considered invalid if the size of <valuedata> doesn’t match the specified size in <valuesize>. However we don’t have any test case for it (and might be not well specified?). During differential fuzzing I noticed this is currently verified in Bitcoin Core (see below) but not checked in other implementations (e.g. btcd), causing a mismatch between them.

     0// Takes a stream and multiple arguments and unserializes them first as a vector then each object individually in the order provided in the arguments
     1template<typename Stream, typename... X>
     2void UnserializeFromVector(Stream& s, X&&... args)
     3{
     4    size_t expected_size = ReadCompactSize(s);
     5    size_t remaining_before = s.size();
     6    UnserializeMany(s, args...);
     7    size_t remaining_after = s.size();
     8    if (remaining_after + expected_size != remaining_before) {
     9        throw std::ios_base::failure("Size of value was not the stated size");
    10    }
    11}
    
  2. bip174: add test case for an invalid valuedata due to its size 97885721b8
  3. murchandamus added the label Proposed BIP modification on Sep 18, 2025
  4. murchandamus added the label Pending acceptance on Sep 18, 2025
  5. murchandamus added the label Bug fix on Sep 18, 2025
  6. murchandamus commented at 8:29 pm on September 18, 2025: contributor
    cc: @achow101

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-10-12 03:10 UTC

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