fuzz: Add input for from_bech32_charset off-by-one bug#7327
Merged
rustyrussell merged 1 commit intoJun 20, 2024
Conversation
Contributor
Author
|
cc @morehouse |
Contributor
|
This input doesn't seem to trigger the error case fixed by #7322. To test I applied this patch and recompiled: Then I did: $ ./tests/fuzz/fuzz-bolt12-bech32-decode tests/fuzz/corpora/fuzz-bolt12-bech32-decode/crash-0018e3d297beda62648c4cda4fff4537bcbf1986
Running: tests/fuzz/corpora/fuzz-bolt12-bech32-decode/crash-0018e3d297beda62648c4cda4fff4537bcbf1986
Executed tests/fuzz/corpora/fuzz-bolt12-bech32-decode/crash-0018e3d297beda62648c4cda4fff4537bcbf1986 in 0 ms
***
*** NOTE: fuzzing was not performed, you have only
*** executed the target code on a fixed set of inputs.
*** |
Contributor
Author
Very interesting, I'm gonna try to have a closer look tomorrow but just skimming the code again now, could this potentially be caused by the signedness of |
Contributor
|
Seems like you nailed it: --- a/common/bech32_util.c
+++ b/common/bech32_util.c
@@ -81,6 +81,7 @@ bool from_bech32_charset(const tal_t *ctx,
datalen = bech32_len - (sep + 1 - bech32);
u5data = tal_arr(NULL, u5, datalen);
for (size_t i = 0; i < datalen; i++) {
+ if (sep[1+i] == (char)128) abort();
int c = sep[1+i];
c = fixup_char(c, &upper, &lower);
if (c < 0 || c >= 128)$ make
$ ./tests/fuzz/fuzz-bolt12-bech32-decode tests/fuzz/corpora/fuzz-bolt12-bech32-decode/crash-0018e3d297beda62648c4cda4fff4537bcbf1986
...
==243216== ERROR: libFuzzer: deadly signal
...
#6 0x7f72318cc8fe in abort (/lib64/libc.so.6+0x268fe)
#7 0x471146 in from_bech32_charset common/bech32_util.c:84:30 |
morehouse
approved these changes
May 22, 2024
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the triggering input for the bug described in #7322 to the
fuzz-bolt12-bech32-decodecorpus (as suggested in #7322 (comment)).