Skip to content

DecodeBase58(const std::string& str, …) is a bit too liberal when decoding? #17718

@practicalswift

Description

@practicalswift

When fuzzing the base58 functions I noticed that DecodeBase58(const std::string& str, …) is perhaps a bit too liberal in what input it accepts when decoding.

I naïvely assumed that DecodeBase58(const std::string& str, …) would return false when passing it a str which contains at least one character that is not any of the base58 characters (all alphanumeric characters except for "0", "I", "O", and "l") or the whitespace characters.

That is not the case:

  • str contains goodDecodeBase58(const std::string& str, …) == true (as expected)
  • str contains bad0IOlDecodeBase58(const std::string& str, …) == false (as expected)
  • str contains good\x00bad0IOlDecodeBase58(const std::string& str, …) == true(!)

The reason is that DecodeBase58(const std::string& str, …) calls DecodeBase58(const char* psz, …) which will only consider the string up to the first \x00.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions