Skip to content

PSBT parser rejects unknown keys with an empty value #560

Closed

Description

@bitcoisas

BIP 174 doesn't set a minimum <valuelen>, and says unknown types should be ignored and passed through. libwally rejects a PSBT whose only unusual field is an unknown output key (0xf0) with an empty value. Bitcoin Core accepts it.

Empty value, rejected (WALLY_EINVAL):

cHNidP8BADwCAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AQAAAAAAAAAAAAAAAAAAAAHwAAA=

Same PSBT with a 1-byte value, accepted:

cHNidP8BADwCAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AQAAAAAAAAAAAAAAAAAAAAHwAQAA

From reading the code: pull_unknown_key_value gets a non-NULL pointer with val_len == 0 from pull_varlength_buff, and map_add rejects it through BYTES_INVALID(val, val_len). That check is still in src/map.c on master (f7b0a15).

Found through bitcoinfuzz, testing at 374df23 with WALLY_PSBT_PARSE_FLAG_STRICT. I only tested an output map key. Global and input unknowns go through the same function, so I'd expect the same there.

Happy to open a PR for this if you'd like, just let me know which approach you'd prefer (handling it in pull_unknown_key_value or in map_add). :)

Activity

  1. jgriffiths commented on Nov 17, 2026

    @jgriffiths
    Contributor

    Hi @bitcoisas thanks for reporting this. Fixed in #562 which I will merge once our internal CI has passed it, cheers!

  2. jgriffiths commented on Nov 17, 2026

    @jgriffiths
    Contributor

    Merged, so closing, thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions