fix(sdk): reject overlong pubkeys in add/remove member builders - #6463
Open
sanjay3290 wants to merge 1 commit into
Open
fix(sdk): reject overlong pubkeys in add/remove member builders#6463sanjay3290 wants to merge 1 commit into
sanjay3290 wants to merge 1 commit into
Conversation
Signed-off-by: Sanjay Ramadugu <sramadugu1@gmail.com> Co-authored-by: Sanjay Ramadugu <sramadugu1@gmail.com>
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.
Problem
build_add_memberandbuild_remove_membervalidatetarget_pubkeywithcheck_hex_len(s, 64, ...). That helper is a minimum-length check:So a 65-or-more character hex string passes validation and is written straight into the
ptag. Every other pubkey site inbuilders.rsusescheck_pubkey_hex, which is the exact-length check (s.len() != 64) and returns the value lowercased. These two builders are the only ones that reached for the git-object helper instead.check_hex_lenalso returnsSdkError::InvalidDiffMeta, which is the wrong variant for a member operation —check_pubkey_hexreturnsInvalidInput.Change
Use the existing
check_pubkey_hexin both builders and take the normalized value it already returns, replacing the separateto_ascii_lowercase()call at the tag site. No new helper, no behaviour change for valid 64-char input.Tests
Three tests in the existing
mod tests:build_add_member_rejects_overlong_pubkey— a 65-char pubkey now returnsInvalidInput; fails onmain.build_remove_member_rejects_overlong_pubkey— same for remove.add_remove_member_lowercases_pubkey— an uppercase 64-char pubkey still lands lowercased in theptag, so the normalization is not lost in the swap.Verification