Storm-Labs-Inc / cove-contracts-boosties

Core smart contracts of the Cove Protocol
Other
18 stars 6 forks source link

Security: Reward Manipulation in function updatePool #337

Open smartsmartsec opened 7 months ago

smartsmartsec commented 7 months ago

Impact

Affected component(s)

function updatePool in MiniChefV3.sol

Attack vector(s)

An attacker can exploit the updatePool function by manipulating lpSupply or altering the state variables indirectly through other contract interactions. This can corrupt the reward calculation, leading to erroneous updates in accRewardPerShare.

Suggested description of the vulnerability for use in the CVE

The smart contract's updatePool function suffers from insufficient validation and reliance on external inputs in calculating accRewardPerShare. The function updates rewards based on lpSupply, which is vulnerable to external manipulation, leading to potential denial of service or economic damage through the unjust distribution of rewards. An attacker manipulating these inputs could result in an inaccurate reward calculation, affecting all participants in the pool.

Discoverer(s)/Credits

xFuzz

Proposed Solution

  1. Validation of lpSupply Adjustments: Implement stringent checks to validate any adjustments to lpSupply, ensuring that modifications are only possible through secure, predefined paths. This includes validating inputs and state changes to prevent unauthorized manipulations.
  2. Secure Reward Calculation Logic: Enhance the reward calculation logic by safeguarding against potential arithmetic errors. Use established libraries like SafeMath to handle all arithmetic operations, ensuring overflow and underflow are prevented.
  3. Isolation of Reward Calculation: Isolate the reward calculation process from direct influence by external contracts or calls. This can be achieved by caching the lpSupply value at the start of each transaction and using this cached value throughout the reward calculation.
  4. Periodic Audits and Monitoring: Conduct regular audits of the smart contract, focusing on the reward distribution mechanism and lpSupply management. Implement monitoring systems to alert developers and administrators of unusual activities or discrepancies in lpSupply.

Reference(s)