31555 - [SC - Low] RewardsDistributoramountToCompound - L The stal...

Submitted on May 21st 2024 at 08:32:49 UTC by @OxSCSamurai for Boost | Alchemix

Report ID: #31555

Report type: Smart Contract

Report severity: Low

Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/RewardsDistributor.sol

Impacts:

  • Contract fails to deliver promised returns, but doesn't lose value

Description

Brief/Intro

Summary:

  • Due to seemingly accidental oversight the staleThreshold variable was accidentally left at a value suitable for testing phase only. The original value was 30 days, but the current value is 60 days.

  • 30 days and older would normally be deemed stale prices, but since 60 days is currently used it means only 60 days and older would now be deemed stale prices, so if prices between 30 days and 60 days are used, they will be accepted as valid prices when they are actually stale prices, and the protocol/users wont be aware of the problem.

Vulnerability Details

Impact Details

Impact:

Most likely impact in scope: Contract fails to deliver promised returns, but doesn't lose value

Likelihood: medium Impact: high Severity: low - medium

Potential impacts:

  • compounding lower/higher amount than expected versus if the price was not stale, so the user/voter would get either more or less rewards than they should have received

  • potential protocol instability due to unstable/invalid pricing

References

https://github.com/alchemix-finance/alchemix-v2-dao/blob/9e14da88d8db05794623d8ab5f449451a10c15ac/src/RewardsDistributor.sol#L118

Proof of Concept

PoC:

I used the existing unmodified protocol test:

  • Minter.t.sol::testCompoundRewards()

  • and test run command: make test_file_debug_test FILE=Minter TEST=testCompoundRewards

Function under test:

  • I made some modifications for PoC testing purposes, to simplify the testing process, see my audit tag comments below:

Test 1: running the test with the 60 days stale threshold active, and making sure that the priceTimestamp is 59 days old, as can see from above modifications:

  • The test completed successfully, so a very stale price of 59 days old was used, and the system accepted it, which should have been an invalid price due to extreme staleness.

Test 2: now running the test with the correct 30 days stale threshold value, and keeping everything else same as for above test, should now revert as expected:

  • reverted as expected because of stale price over 30 days

Suggested bugfix:

Last updated

Was this helpful?