Repository navigation
Reject non-canonical bech32 in Cosmos and Cardano addresses - #1959
Merged
Merged
Conversation
gemcoder21
approved these changes
Nov 18, 2026
gemcoder21
left a comment
Contributor
There was a problem hiding this comment.
Reviewed: both parsers now reject non-canonical padding and Bech32m, and a real 103-character Cardano address still parses on the new path.
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.
Why: Follow-up to #1957. The Cosmos and Cardano address parsers used
bech32::decode, which drops leftover padding bits without checking them. A Cosmos address with one extra padding character and a valid checksum passed validation as the same 20-byte address, and a Cardano address with non-zero padding bits in its last character passed as the same address. No funds are at risk, since both decode to the same bytes, but the non-canonical forms should be rejected.What changed: Both parsers validate the padding before converting the payload to bytes. They also now accept only the Bech32 checksum;
bech32::decodeaccepted Bech32m as well, which neither chain uses.Proof: New test cases reject a padded Cosmos address, a Bech32m Cosmos address, and a Cardano address with non-zero padding. All three were accepted before the change. Existing valid-address tests still pass.