Skip to content

Commit

Permalink
fix(x/distribution): vulnerable incrementReferenceCount in distributi…
Browse files Browse the repository at this point in the history
…on (#19301)

Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Likhita Polavarapu <[email protected]>
  • Loading branch information
3 people authored Feb 7, 2024
1 parent e604e54 commit 4b8f326
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions x/distribution/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Client Breaking Changes

* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) Deprecate `CommunityPool` and `FundCommunityPool` rpc methods. Use `x/protocolpool` module's rpc methods instead.

### Bug Fixes

* [#19301](https://github.com/cosmos/cosmos-sdk/pull/19301) Fix vulnerability in `incrementReferenceCount` in distribution.
3 changes: 2 additions & 1 deletion x/distribution/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ func (k Keeper) incrementReferenceCount(ctx context.Context, valAddr sdk.ValAddr
if err != nil {
return err
}

historical.ReferenceCount++
if historical.ReferenceCount > 2 {
panic("reference count should never exceed 2")
}
historical.ReferenceCount++
return k.ValidatorHistoricalRewards.Set(ctx, collections.Join(valAddr, period), historical)
}

Expand Down

0 comments on commit 4b8f326

Please sign in to comment.