You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
…x,SetIndex (#9196)
Fixes unchecked negative index access that'd cause panics, in CompactBitArray's:
* CompactUnmarshal, which blindly used the result of binary.Uvarint
* GetIndex
* SetIndex
Fixes#9164Fixes#9165
Summary of Bug
I audited this code
cosmos-sdk/crypto/types/compact_bit_array.go
Lines 246 to 263 in bffcae5
and look at this code
cosmos-sdk/crypto/types/compact_bit_array.go
Lines 253 to 254 in bffcae5
all one needs to do is pass in bad bytes for the size and that'll be returned in
n
which is naively passed to a slice and hence a crash :-(for example here is an excerpt that'll crash https://play.golang.org/p/UMRoxgM1sL7 or inlined
which crashes with
panic: runtime error: slice bounds out of range [-11:] goroutine 1 [running]: main.main() /tmp/sandbox752607808/prog.go:8 +0xc6
In fact, I wrote a fuzz pass and it found 6 crashes in less than 4 seconds, it took me 5 seconds to read and figure it out as a human
Remedy
We shouldn't be naively slicing here, we should return an error in these situations
Version
bffcae5
For Admin Use
/cc @cuonglm
The text was updated successfully, but these errors were encountered: