_processLockChange
fails to account for boostedValue
when incrementing permanentTotalSupply
#6
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-11
🤖_primary
AI based primary recommendation
🤖_06_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2024-09-fenix-finance/blob/main/contracts/core/VotingEscrowUpgradeableV2.sol#L470
Vulnerability details
Impact
This could lead to an inaccurate balance between the actual locked amount and the permanentTotalSupply. In the worst case, users might not be able to unlock their permanent locks due to over-deduction by previous users with boosted balances.
Proof-of-Concept
The
_proccessLockChange
function is responsible for updating the locked balance of an NFT. When processing a lock change, the function checks if the lock is eligible for a boost reward from the VeBoost contract.If the lock is eligible, the function calculates the boost amount and adds it to the total locked amount.
However, when updating
permanentTotalSupply
(for permanent lock case), the function only adds the original deposit amount, excluding the boosted amount. This can lead to an inaccurate permanent total supply calculation, as shown in the following code snippet:In the code above,
permanentTotalSupply
is only incremented by the originalamount_
value, whileboostedValue
is added tonewLocked.amount
. This means that when a user withdraws their locked tokens, the contract will deduct more than was originally added topermanentTotalSupply
, leading to an underestimation of the permanent total supply.Recommended Mitigations
Assessed type
Context
The text was updated successfully, but these errors were encountered: