The users' voting power is calculated incorrectly.
Proof of Concept
In the VotingEscrowUpgradeableV2.onDetachFromManagedNFT function, newBalance_ is subtracted from both permanentTotalSupply and newManagedLocked.amount.
As a result, this causes incorrect balance of NFT.
Let's consider the following scenario:
Alice locks 100 FNX permanently: permanentTotalSupply = 100.
Bob creates a lock with 100 FNX and attaches it to the managedToken: permanentTotalSupply = 200.
After some time, Alice detaches from the managedToken and receives 10 FNX as lockedRewards from managedNFTManager: permanentTotalSupply = 200 - 100 - 10 = 90.
When Bob tries to vote, his NFT balance is reported as 90, even though he locked 100 FNX permanently.
Tools Used
Manual Review
Recommended Mitigation Steps
It is recommended to change the code as following:
Lines of code
https://github.com/code-423n4/2024-09-fenix-finance/blob/main/contracts/core/VotingEscrowUpgradeableV2.sol#L295-L314
Vulnerability details
Impact
The users' voting power is calculated incorrectly.
Proof of Concept
In the
VotingEscrowUpgradeableV2.onDetachFromManagedNFT
function,newBalance_
is subtracted from bothpermanentTotalSupply
andnewManagedLocked.amount
.newBalance_
is greater than the actual deposited amount because it includeslockedRewards
received frommanagedNFTManager
at L218.As a result, this causes incorrect balance of NFT.
Let's consider the following scenario:
permanentTotalSupply
= 100.managedToken
:permanentTotalSupply
= 200.managedToken
and receives 10 FNX aslockedRewards
frommanagedNFTManager
:permanentTotalSupply
= 200 - 100 - 10 = 90.Tools Used
Manual Review
Recommended Mitigation Steps
It is recommended to change the code as following:
Assessed type
Other