fix(x/distribution): vulnerable incrementReferenceCount in distribution (#19301)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
This commit is contained in:
Naveen
2024-02-07 09:25:33 +00:00
committed by GitHub
co-authored by Aleksandr Bezobchuk Likhita Polavarapu
parent e604e54b5c
commit 4b8f32657b
2 changed files with 6 additions and 1 deletions
+4
View File
@@ -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.
+2 -1
View File
@@ -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)
}