boostedValue should be added to permanentTotalSupply for permanently locked tokens
The boosted value added to a token's locked amount was not included in permanentTotalSupply, so the last user to unlock a permanent lock could cause an underflow and be unable to unlock. This could leave the last user's tokens temporarily locked.
Unlocking tokens from the permanent locking can be DoSed.
Proof of Concept
In the VotingEscrowUpgradeableV2._processLockChange function, boostedValue is added to the token’s locked amount at L465. However, boostedValue is not added to permanentTotalSupply for permanently locked tokens at L470.
Indeed. After refactoring and changes, this point, although known, was missed in the new code.
It is difficult to understand the severity of this issue, it seems to be Overseverity. If we go with the worst-case scenario, the last user/users will not be able to unlock the permanent lock on their veNFTs, which will lead them to some additional temporary lock until the problem is resolved, as they would have to wait 182 days for full unlocking anyway.
@alcueca - I think this is high severity. This vulnerability leads not only to a DoS but also to an incorrect calculation of voting power in the _balanceOfNFT function due to the incorrect accumulation of permanentTotalSupply.
@KupiaSec, @alcueca - In the balanceOfNFT calculation, data regarding the permanentTotalSupplyis not used, and the impact of not accounting boostedValue in permanentTotalSupply is limited only to the calculation of the total voting power. This does not affect on votes processing, but only the outcome (votingPowerTotalSupply()). The voting power for a user’s veNFT will still be calculated correctly.
This statement most likely arose because similar structures and pieces of code are used for the general voting power calculation and for the user. However, last_point in _checkpoint is from supplyPointsHistory, whereas in balanceOfNFT, nftPointHistory is used.
@alcueca, @KupiaSec - I believe there is some wrong assumption in this issue. The last_point.permanent and lastPoint.permanent are not the same thing in this logic.
last_point.permanent is related to supplyPointsHistory[]this mapping which is tracking the total supply changes.
However, lastPoint.permanent that used in _balanceOfNFT() is from nftPointHistory[][]this mapping which is recording the changes over time for every veNFT.
There is a confusion for two variables and I agree there is no incorrect calculation of voting power by the permanentTotalSupply. But there still exists DoS vulnerability.
I think the last permanent lock being affected reasonably often merits a medium severity. Thanks @KupiaSec for retracting your previous statement about permanentTotalSupply.
The original report as published on Code4rena, by KupiaSec. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the boostedValue was added to the locked amount but not to permanentTotalSupply when a lock became permanent.
Impact
The last user to unlock a permanent lock could be unable to do so, leaving their tokens temporarily locked; the text notes they would have to wait 182 days for full unlocking anyway.
What the attacker needed
A user locks tokens permanently; another user deposits enough to get a boost; the boosted user unlocks first
The fix
The code should be changed so that permanentTotalSupply is increased by both amount_ and boostedValue when a lock becomes permanent.
How it was found
Alice and Bob each create locks with 100 FNX for a 1-week duration.
Alice and Bob lock their tokens permanently, making permanentTotalSupply 200.
Alice deposits 1000 FNX, which adds a boostedValue of 100 to her locked amount.
Alice unlocks her token from the permanent lock, reducing permanentTotalSupply to 0.
Bob tries to unlock his token from the permanent lock, but the transaction reverts because permanentTotalSupply is 0.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
When you lock tokens permanently, the contract keeps a running total of all permanently locked tokens. A bonus amount was added to individual locks but not to that total, so when the last person tried to unlock, the contract tried to subtract more than the total and failed. This meant the last user could not unlock their tokens until the issue was fixed.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.