Repository navigation
Conversation
Pairing.mul_n_aggregate took the randomization bit-length as a signed int
and passed it to the native blst_pairing_mul_n_aggregate_pk_in_g{1,2} as
(size_t)nbits with no checks. A negative nbits converts to SIZE_MAX, and any
nbits larger than scalar.Length*8 makes POINTonE{1,2}_mult_w5 read the scalar
as a wider value than the caller supplied, reading past the scalar buffer. The
Go and Rust bindings already validate this; the C# one did not. Reject nbits
that does not fit the scalar before the native call.
Collaborator
|
As it says in the beginning of the modified .cs file "DO NOT EDIT THIS FILE." :-) Anyway, I've moved the tweaked modifications to the right place. Thanks! |
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.
Pairing.mul_n_aggregatetakes the randomization bit-length as a signedintand forwards it to the nativeblst_pairing_mul_n_aggregate_pk_in_g{1,2}as(size_t)nbitswith no range check. A negativenbitsbecomesSIZE_MAX, and anynbitsgreater thanscalar.Length*8makesPOINTonE{1,2}_mult_w5read the scalar as a wider value than the caller supplied, so the native side reads past the end of the scalar buffer (the C core only guardsnbits != 0). The Go binding already rejects this (randBits < 0 || randBits > 256) and Rust validatesscalar.len()againstnbits; the C# binding was the one left unchecked.Both overloads now reject an
nbitsthat does not fit the scalar before the native call.Reproduced against the native path with AddressSanitizer (
nbits = 256, 1-byte scalar):A 32-byte scalar with
nbits = 256reads in bounds and is unaffected.poc.csgets a regression case that fails without the guard and passes with it;dotnet run -c Releaseis green.