Submitted by cmichel
When unbonding, the pick_validator function is supposed to choose a random validator to unstake from.
However, this randomness can be predicted knowing the block height which is very easy to predict.
As validators are paid rewards proportional to their stake, choosing where to bond and unbond from directly impacts validator rewards.
Combined with being able to choose the validator when bonding (see execute_bond) a validator can steal rewards and increase their own.
An unbond must always remove stake from the validator the stake was originally bonded to, otherwise, its exploitable by the attack above.
Consider keeping track of all bonds with a bond_id and create a map of bond_id -> validator.
If a validators stake decreased due to slashing, take the remaining unstake amount proportionally from all other validators.
bitn8 (Anchor) disagreed with severity
Alex the Entreprenerd (triage) commented:
Albert Chon (judge) decreased severity to Medium and commented:
