crypto/types: CompactBitArray doesn't defensively check that .SetIndex has a positive index before indexing #9164
Closed
Description
opened on Apr 22, 2021
Summary of Bug
If we audit this code
cosmos-sdk/crypto/types/compact_bit_array.go
Lines 55 to 71 in c4864e9
we'll notice
cosmos-sdk/crypto/types/compact_bit_array.go
Lines 60 to 68 in c4864e9
the code in (*CompactBitArray).SetIndex assumes that it'll always take in a positive index. However, the stakes have changed, the cosmos-sdk will be used in every way and our mandate is ensuring reliability and security. We have an explicit check in there that the index won't cause out of bounds, we should simply add one too to ensure that we don't accept negative values.
Version
Latest with bffcae5
For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate contributors tagged
- Contributor assigned/self-assigned
/cc @cuonglm
Activity