Core Contracts

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

the allocateFunds function in the Treasury.sol incorrectly overwrites state instead of updating/adding to it

Vulnerability Details

the allocateFunds function in the Treasury.sol incorrectly overwrites _allocations mapping instead of updating/adding to it.

When the allocateFunds function is called by the trusted role for allocating funds to a specifies receppient. When the mapping is updated in the function i.e alllocations instead of adding to it the mapping is bieng overwritten instead. For example lets say the owner allocates 100 tokens to a receipient and then some time later to the same reciepient the owner wants his allocation to be 150 so he next time calls the function with amount = 50 bu instead of adding in the allocations mapping to 150, it will be updated to 50.

Recommendations

Update the code like this :
+_allocations[msg.sender][recipient] += amount;
-_allocations[msg.sender][recipient] = amount;

Code Snippets

function allocateFunds(
address recipient,
uint256 amount
) external override onlyRole(ALLOCATOR_ROLE) {
if (recipient == address(0)) revert InvalidRecipient();
if (amount == 0) revert InvalidAmount();
_allocations[msg.sender][recipient] = amount;
emit FundsAllocated(recipient, amount);
}```
Updates

Lead Judging Commences

inallhonesty Lead Judge 3 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.