Core Contracts

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

Fund mismanagement in Treasury

Summary

The allocateFunds function incorrectly overwrites allocations instead of accumulating them, leading to fund mismanagement and potential financial discrepancies.

Vulnerability Details

The current code would not be problematic if the amount to be allocated was calculated before the allocateFunds function was called. However, there is no such implementation, and the amount passed is never checked to see if it is updated with the user's current allocated funds. This results in overwriting, which would cause a loss of funds for the user.

  • Affected Function: Treasury:allocateFunds

  • Issue:

/**
* @notice Allocates funds to a recipient
* @dev Only callable by accounts with ALLOCATOR_ROLE
* Records allocation without transferring tokens
* @param recipient Address to allocate funds to
* @param amount Amount of funds to allocate
*/
function allocateFunds(
address recipient,
uint256 amount
) external override onlyRole(ALLOCATOR_ROLE) {
if (recipient == address(0)) revert InvalidRecipient();
if (amount == 0) revert InvalidAmount();
//@audit users allocation being overwritten rather than updated
_allocations[msg.sender][recipient] = amount;
emit FundsAllocated(recipient, amount);
}

This resets the allocations instead of adding or subtracting them by deleting the previous allocations.

Impact

  • Loss of previous allocations, affecting fund tracking

  • Incorrect financial records and misallocations

Recommendations

  • Modify the function to accumulate and also to subtract allocations.

Conclusion

The current implementation of allocateFunds leads to unintended fund overwriting, resulting in financial inconsistencies. By modifying the function to properly adjust allocations instead of replacing them, the contract can ensure accurate fund tracking and prevent user losses. Implementing proper validation and accumulation logic will enhance security.

Updates

Lead Judging Commences

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

Treasury::allocateFunds should increase or decrease funds to avoid recipient frontrunning and double spending

Support

FAQs

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

Give us feedback!