DeFiLayer 1Layer 2
14,723 OP
View results
Submission Details
Severity: medium
Invalid

Missing Update of `self.last_update` in `update_profit_max_unlock_time` Function

Summary

In the update_profit_max_unlock_time function of ScrvusdOracleV2.vy, the variable self.last_update is not updated with the latest block timestamp. This inconsistency may affect functions that rely on self.last_update for time-dependent calculations, potentially leading to incorrect price updates or profit unlock mechanisms.

Vulnerability details

  • The function update_profit_max_unlock_time is responsible for updating the profit_max_unlock_time value.

  • It performs an access control check and ensures that _block_number is valid.

  • However, unlike the update_price function, which updates self.last_update, this function fails to do so.

  • self.last_update is used in various calculations, particularly in _smoothed_price, which influences price updates and unlocking mechanisms.

  • As a result, any logic dependent on self.last_update may operate on outdated timestamps, leading to unexpected behavior.

Impact

  • Incorrect Unlock Time Calculation: The lack of self.last_update updates could result in stale timestamp values, affecting the smooth unlocking of profits.

  • Potential Exploit Opportunity: Attackers may leverage this issue to manipulate the unlocking mechanism, causing unintended delays or accelerating profit unlocking inconsistently.

  • Inconsistent State Updates: Other functions relying on self.last_update for time-based calculations may not reflect the correct time progression, leading to inaccurate price or supply values.

Recommendation

  • Ensure that self.last_update is updated to block.timestamp in the update_profit_max_unlock_time function, similar to how it's handled in update_price.

  • Modify the function as follows:

    @external
    def update_profit_max_unlock_time(_profit_max_unlock_time: uint256, _block_number: uint256) -> bool:
    access_control._check_role(UNLOCK_TIME_VERIFIER, msg.sender)
    assert self.last_block_number <= _block_number, "Outdated"
    self.last_block_number = _block_number
    prev_value: uint256 = self.profit_max_unlock_time
    self.profit_max_unlock_time = _profit_max_unlock_time
    # Fix: Update self.last_update to current timestamp
    ++ self.last_update = block.timestamp
    return prev_value != _profit_max_unlock_time
Updates

Lead Judging Commences

0xnevi Lead Judge
7 months ago
0xnevi Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.