fix: Reject witness version > 16 in validate_segwit#279
Open
alexgrad42 wants to merge 1 commit into
Open
Conversation
BIP-173 and BIP-350 state that the witness version must be between 0 and 16 inclusive. However, `CheckedHrpstring::validate_segwit` only validated the length of the witness program, allowing invalid versions from 17 to 31 to be incorrectly treated as valid. Fix this by explicitly checking if the extracted `witness_version` exceeds 16, returning `InvalidWitnessVersion` if it does. Fixes rust-bitcoin#274
Member
|
This and your other PRs smell like LLM. Please make an attempt to convince me otherwise. |
Member
|
They are clearly LLM-generated but many of them are correct the first time, and they are helping to burn down the pile of Loupe bug reports. I am reviewing them quite adversarially. |
Member
|
This check already exists in multiple places -- notably But now the check happens twice, because I don't think we can let a drive-by LLM fix this. We need to back up and have a human decide at what level the check needs to happen, and maybe better-encapsulate some constructors. |
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.
BIP-173 and BIP-350 state that the witness version must be between 0 and 16 inclusive. However,
CheckedHrpstring::validate_segwitonly validated the length of the witness program, allowing invalid versions from 17 to 31 to be incorrectly treated as valid.Fix this by explicitly checking if the extracted
witness_versionexceeds 16, returningInvalidWitnessVersionif it does.Fixes #274