bech32: add BIP-173 padding validation #8419
Open
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.
@brunoerg has been doing differential fuzzing on
CLightning
and discovered an offer that crashes our differential fuzzing target inbitcoinfuzz
. I found thatCLightning
accepts malformed offers containing invalid bech32 data that violates the BIP-173 specification, creating interoperability issues with other Lightning implementations (rust-lightning
,lightning-kmp
) that correctly reject such data.BIP-173 says:
offer:
lightning-kmp check: https://github.com/ACINQ/bitcoin-kmp/blob/master/src/commonMain/kotlin/fr/acinq/bitcoin/Bech32.kt#L206
rust-lightning check: https://github.com/rust-bitcoin/rust-bech32/blob/master/src/primitives/iter.rs#L180
BOLT12 is missing a test case like this. Perhaps this could be a useful new test vector?
Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked: