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
ratelimit/keeper: potential inconsistencies and data races in store due to iterating while deleting keys in Keeper.RemoveAllChannelPendingSendPackets
#5
Open
odeke-em opened this issue
Mar 9, 2024
· 0 comments
deleting from the store while an iterator that has been acquired is being traversed. The cosmos/store package doesn't guarantee the safety and immutability of the backing storage, so it is quite dangerous to delete keys while using an iterator. I could be wrong but seeing no guarantees from the store package, and having implemented some of the underlying integrations, this problem jumps off the page for me.
Remedy
Please collect the keys into a slice from traversing the iterator, close the iterator, then delete them afterwards in a new loop.
While auditing this repository for security issues, I noticed that there is a potential data race that could plague this code
ibc-rate-limiting/ratelimit/keeper/pending_send.go
Lines 69 to 71 in 29a35e9
deleting from the store while an iterator that has been acquired is being traversed. The cosmos/store package doesn't guarantee the safety and immutability of the backing storage, so it is quite dangerous to delete keys while using an iterator. I could be wrong but seeing no guarantees from the store package, and having implemented some of the underlying integrations, this problem jumps off the page for me.
Remedy
Please collect the keys into a slice from traversing the iterator, close the iterator, then delete them afterwards in a new loop.
/cc @alexanderbez @julienrbrt @tac0turtle
The text was updated successfully, but these errors were encountered: