Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when decoding bech32 string containing an uppercase 'O' #22

Closed
sgeisler opened this issue Jun 21, 2018 · 3 comments · Fixed by #23
Closed

Panic when decoding bech32 string containing an uppercase 'O' #22

sgeisler opened this issue Jun 21, 2018 · 3 comments · Fixed by #23
Assignees
Labels

Comments

@sgeisler
Copy link
Contributor

Fuzz tests in rust-bitcoin/rust-bitcoin#100 uncovered the bug that if the bech32 data part contains an uppercase 'O' the parser panics. This is due to insufficient checks that only check the lowercase variants of the forbidden characters (before normalizing them to their lowercase variant):

if b == b'1' || b == b'b' || b == b'i' || b == b'o' {
    return Err(Error::InvalidChar(b))
}

To avoid such issues in the future I will have a look at fuzz testing this crate (#21).

@sgeisler sgeisler added the bug label Jun 21, 2018
@sgeisler sgeisler self-assigned this Jun 21, 2018
@sgeisler
Copy link
Contributor Author

sgeisler commented Jun 22, 2018

I had a look at the code from before the introduction of u5. The same bug was present before (silently outputting vectors with elements >=32, in this case 255) and only uncoverd by the range checks of u5. I will open a fix PR soon.

@clarkmoody
Copy link
Member

Well that certainly is a bug! What were you thinking of using for fuzz testing?

@sgeisler
Copy link
Contributor Author

sgeisler commented Jun 22, 2018

The fuzzing code can probaly be copied from rust-bitcoin with some minor changes. The main objective will be to find panic scenarios (we don't need reference data for that). I'd say a stretch goal is to link the C/C++ version from bitcoin core as a reference and check if they can cope with each other's output/produce the same output given the same input.

sgeisler added a commit to sgeisler/rust-bech32 that referenced this issue Jun 22, 2018
@sgeisler sgeisler mentioned this issue Jun 22, 2018
5 tasks
sgeisler added a commit to sgeisler/rust-bech32 that referenced this issue Jun 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants