fix(cggmp24): don't panic on out-of-range signer index in validate_consistency - #236
Open
Joshuaisikah wants to merge 1 commit into
Open
Conversation
…nsistency
`DirtyKeyShare::validate_consistency` indexed `aux.N[usize::from(core.i)]`
directly. Both current callers only ever pass a `core` that's already been
through `is_valid()` (or is a `Valid<_>` by type), so `core.i` is in range
in practice today. But `validate_consistency` itself has no way to enforce
that, and a future caller (or a refactor that reorders the checks) could
trivially reintroduce a panic here.
Replace the direct index with `.get(...).ok_or(PartyIndexOutOfBounds)`, and
add a regression test that calls `validate_consistency` directly with a
deliberately out-of-range `core.i`, bypassing the public API's guards, to
prove the function is safe on its own rather than relying on caller
discipline.
Also checked key-share/src/valid.rs per the issue's hedge ("may be present
there too") — found no unguarded indexing to fix there.
Fixes LFDT-Lockness#201
Signed-off-by: Joshua Isika <joshuaiska@gmail.com>
Joshuaisikah
force-pushed
the
fix/key-share-index-out-of-bounds
branch
from
August 6, 2026 10:14
fbe77fa to
554623d
Compare
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.
Fixes #201
DirtyKeyShare::validate_consistency(incggmp24/src/key_share.rs) indexedaux.N[usize::from(core.i)]directly. Both current callers only ever pass acorethat's already been throughis_valid()(or is aValid<_>by type), socore.iis in range in practice today. Butvalidate_consistencyitself has no way to enforce that on its own — it's relying entirely on caller discipline, and a future caller (or a refactor that reorders the existing checks) could trivially reintroduce a panic here.Changes
.get(usize::from(core.i)).ok_or(InvalidKeyShareReason::PartyIndexOutOfBounds)?PartyIndexOutOfBoundserror variantvalidate_consistency_rejects_out_of_range_signer_index) that callsvalidate_consistencydirectly with a deliberately out-of-rangecore.i, bypassing the public API's guards, to prove the function is safe on its own rather than relying on the invariant its callers happen to uphold today. Verified locally that this test panics against the old code (index out of bounds: the len is 2 but the index is 5) and passes cleanly against the fix.I also checked
key-share/src/valid.rs, per the issue's hedge that "the similar problem may be present" there too — I didn't find any unguarded indexing in that file, so no changes were needed there.Testing
All pass.