Summary
In Treasury.sol contract in allocateFunds function if _totalValue >= amountthen that will give correct result. Otherwise _totalValue < amount will give wrong result. Because of that Allocater may assign wrong amount to recipient.
Vulnerability Details
In Treasury.sol contract in allocateFunds function
* @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();
@>>
1. `_totalValue >= amount`then function will give correct result.
2. `_totalValue < amount`then function will give wrong result.
*/
_allocations[msg.sender][recipient] = amount;
emit FundsAllocated(recipient, amount);
}
Consider this two situation -
_totalValue >= amountthen function will give correct result.
_totalValue < amountthen function will give wrong result.
Impact
Allocater may assign wrong amount to recipient.
Tools Used
Manual Review
Recommendations
In Treasury.sol contract in allocateFunds function add this line if ( _totalValue < amount) revert InsufficientAmount();
function allocateFunds(
address recipient,
uint256 amount
) external override onlyRole(ALLOCATOR_ROLE) {
if (recipient == address(0)) revert InvalidRecipient();
if (amount == 0) revert InvalidAmount();
@> + if ( _totalValue < amount) revert InsufficientAmount();
_allocations[msg.sender][recipient] = amount;
emit FundsAllocated(recipient, amount);
}