Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Valid

`updateUserBoost` Function Resets `workingSupply` Incorrectly, Leading to Data Inconsistencies

Summary

The updateUserBoost function directly sets the workingSupply to the newly calculated boost value, which can lead to inconsistencies between workingSupply and totalBoost. When a user interacts with a supported pool for the first time, the newBoost can return a high default value (e.g., 10000), causing the workingSupply to be incorrectly inflated.

Vulnerability Details

When the function is called under these conditions:

  • The user has never interacted with the specified pool (userBoost.amount defaults to 0).

  • The pool is already supported and has an existing poolBoost state.

The newBoost calculation can return a high value (e.g., 10000) due to the default veToken calculation logic. This value is then directly assigned to poolBoost.workingSupply without considering the existing poolBoost.totalBoost.

Problematic Code Segment

poolBoost.workingSupply = newBoost; // @audit-issue workingSupply may be set to an inflated value (e.g., 10000)

Example Scenario

  1. Initial State:

    • poolBoost.totalBoost = 10_000_000

    • poolBoost.workingSupply = 10_000_000

  2. First-Time User Interaction:

    • oldBoost = 0 (user has no prior interaction)

    • newBoost = 10000 (from _calculateBoost)

    • poolBoost.totalBoost updates to 10_010_000 correctly.

    • However:

      poolBoost.workingSupply = newBoost; // Now set to 10,000 instead of maintaining the totalBoost-related proportion.
    • Result: workingSupply becomes 10,000, while totalBoost is 10,010,000, leading to data inconsistency.

Impact

  • Data Inconsistency: workingSupply becomes lower than totalBoost, potentially affecting calculations relying on accurate supply metrics.

  • Reward Distribution Errors: Misalignment between workingSupply and totalBoost can distort pool-based calculations, affecting user rewards and overall system integrity.

  • Potential Manipulation: Malicious actors may exploit this to alter the working supply for personal gain.

Tools Used

Manual code review and logical analysis of state variable updates.

Recommendations

Update the assignment of workingSupply to reflect accumulated boosts rather than resetting it:

Suggested Fix

Instead of:

poolBoost.workingSupply = newBoost;

Use:

poolBoost.workingSupply = poolBoost.workingSupply + (newBoost - oldBoost);

This ensures that workingSupply is incremented or decremented relative to the previous boost values, maintaining consistency with totalBoost.

Alternatively, if workingSupply should mirror totalBoost:

poolBoost.workingSupply = poolBoost.totalBoost;

This ensures both metrics remain aligned and avoids potential data inconsistencies.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

BoostController::updateUserBoost overwrites workingSupply with single user's boost value instead of accumulating, breaking reward multipliers and allowing last updater to capture all benefits

Support

FAQs

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