Unbounded State Variables Pose Risk to Contract Stability
Description
The ProofOfHumanityExtended and CrossChainProofOfHumanity contracts contain state variables that can be modified by the governor without any upper bounds. Specifically, the sharedStakeMultiplier, winnerStakeMultiplier, loserStakeMultiplier, and transferCooldown variables can be set to arbitrarily large values. This lack of upper bounds could potentially lead to unexpected behavior, contract instability, or even render certain functionalities unusable.
The proposed fix introduces upper bounds for the stake multipliers and transfer cooldown. The MAX_STAKE_MULTIPLIER is set to 10000 (100% in basis points), assuming the multipliers are used in percentage calculations. The MAX_TRANSFER_COOLDOWN is set to 365 days as an example, but this should be adjusted based on the specific requirements of the system. These changes ensure that even if a malicious or compromised governor attempts to set extreme values, they will be constrained within reasonable limits, maintaining the intended functionality and stability of the contract.
The governor is trusted.
As per Kleros Coop development guidelines:
Don't protect the user from himself. Client execution is almost free, but smart contract execution isn't, so limit smart contracts to blocking malicious behavior and let clients prevent the stupid ones.
Do not over-engineer. Over-engineering lowers security, increases gas costs, and decreases convincibility. Kiss ♥.
As per contest rules are excluded:
Comments about the governor/owner being malicious (they are considered trusted and will be moved to the DAO).
Issues about the ability for a governor/owner to set parameters in a way breaking the contract (they are trusted to be both non-malicious and non-stupid).
Github username: -- Twitter username: -- Submission hash (on-chain): 0x338e55fc6fc966b513e970aebc3d1e1f269e8b059ee300b88ecee2f21f0b75d2 Severity: low
Description:
Unbounded State Variables Pose Risk to Contract Stability
Description
The ProofOfHumanityExtended and CrossChainProofOfHumanity contracts contain state variables that can be modified by the governor without any upper bounds. Specifically, the
sharedStakeMultiplier
,winnerStakeMultiplier
,loserStakeMultiplier
, andtransferCooldown
variables can be set to arbitrarily large values. This lack of upper bounds could potentially lead to unexpected behavior, contract instability, or even render certain functionalities unusable.Proof of Concept (PoC)
https://github.com/hats-finance/Proof-Of-Humanity-V2-0xef0709445d394a22704850c772a28a863bb780b0/blob/master/contracts/extending-old/ProofOfHumanityExtended.sol#L639-L644
https://github.com/hats-finance/Proof-Of-Humanity-V2-0xef0709445d394a22704850c772a28a863bb780b0/blob/master/contracts/CrossChainProofOfHumanity.sol#L182-L183
Revised Code File
The proposed fix introduces upper bounds for the stake multipliers and transfer cooldown. The
MAX_STAKE_MULTIPLIER
is set to 10000 (100% in basis points), assuming the multipliers are used in percentage calculations. TheMAX_TRANSFER_COOLDOWN
is set to 365 days as an example, but this should be adjusted based on the specific requirements of the system. These changes ensure that even if a malicious or compromised governor attempts to set extreme values, they will be constrained within reasonable limits, maintaining the intended functionality and stability of the contract.