Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@odeke-em
Copy link

odeke-em commented Mar 9, 2024

While auditing this repository for security issues, I noticed that there is a potential data race that could plague this code

for ; iterator.Valid(); iterator.Next() {
store.Delete(iterator.Key())
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant