Skip to content

Hex string with non-hex data appended to it accepted as valid hex argument to hash160/ripemd160/hash256/sha256 #25

@practicalswift

Description

@practicalswift

Hex string with non-hex data appended to it accepted as valid hex argument to hash160/ripemd160/hash256/sha256.

Accepted since 40 chars of hex:

$ ./miniscript <<< "hash160(ffffffffffffffffffffffffffffffffffffffff)"
      0 scriptlen=27 maxops=4 type=B safe=no nonmal=yes dissat=yes input=1n output=1 miniscript=hash160(ffffffffffffffffffffffffffffffffffffffff)

Not accepted since 48 chars of hex (we want 40 chars of hex):

$ ./miniscript <<< "hash160(ffffffffffffffffffffffffffffffffffffffffcafebabe)"
Failed to parse as policy or miniscript 'hash160(ffffffffffffffffffffffffffffffffffffffffcafebabe)'

Unexpectedly accepted despite being 48 chars (note the non-hex "z" as the 41:th char):

$ ./miniscript <<< "hash160(ffffffffffffffffffffffffffffffffffffffffzafebabe)"
      0 scriptlen=27 maxops=4 type=B safe=no nonmal=yes dissat=yes input=1n output=1 miniscript=hash160(ffffffffffffffffffffffffffffffffffffffffzafebabe)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions