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

fuzz: add x/bank/types.AddressFromBalancesStore #9060

Merged
merged 1 commit into from
Apr 15, 2021
Merged

fuzz: add x/bank/types.AddressFromBalancesStore #9060

merged 1 commit into from
Apr 15, 2021

Conversation

cuonglm
Copy link
Contributor

@cuonglm cuonglm commented Apr 7, 2021

Description

Add fuzzing for x/bank/types.AddressFromBalancesStore

Updates #7921


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@cuonglm
Copy link
Contributor Author

cuonglm commented Apr 7, 2021

cc @odeke-em

@odeke-em
Copy link
Collaborator

odeke-em commented Apr 7, 2021

Thank you @cuonglm, looks like you found a bug in the code, nice! Could you please extract a reproduction case and file a bug and reference where you found it?

@cuonglm
Copy link
Contributor Author

cuonglm commented Apr 7, 2021

Thank you @cuonglm, looks like you found a bug in the code, nice! Could you please extract a reproduction case and file a bug and reference where you found it?

Yeah, I'm doing exactly what you said :)

@odeke-em
Copy link
Collaborator

odeke-em commented Apr 7, 2021

I've filed for you #9062.

mergify bot pushed a commit that referenced this pull request Apr 7, 2021
…9061)

Currently, AddressFromBalancesStore uses the input key without any
validation, so an empty key or an invalid key length cause it panics.

This commit fixes the problem, by returning an error in case of invalid
key was passed.

Found by fuzzing added in #9060.

Fixed #9062
odeke-em pushed a commit that referenced this pull request Apr 15, 2021
…9112)

addrLen is encoded in a byte, so it's an uint8. The code in
AddressFromBalancesStore cast it to int for bound checking, but wrongly uses "addrLen+1", which can be overflow.

To fix this, just cast addrLen once and use it in all places.

Found by fuzzing added in #9060.

Fixes #9111
@cuonglm
Copy link
Contributor Author

cuonglm commented Apr 15, 2021

@odeke-em can we merge this now? I ran it for the whole day with latest master and no crash found anymore.

@odeke-em
Copy link
Collaborator

odeke-em commented Apr 15, 2021 via email

Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @cuonglm!

@odeke-em odeke-em merged commit fb87279 into cosmos:fuzz-packages Apr 15, 2021
elias-orijtech pushed a commit to elias-orijtech/cosmos-sdk that referenced this pull request Apr 11, 2022
elias-orijtech pushed a commit to elias-orijtech/cosmos-sdk that referenced this pull request Apr 11, 2022
elias-orijtech pushed a commit to elias-orijtech/cosmos-sdk that referenced this pull request May 6, 2022
elias-orijtech pushed a commit to elias-orijtech/cosmos-sdk that referenced this pull request May 6, 2022
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

Successfully merging this pull request may close these issues.

2 participants