_syncVotingPower can revert in underflow in NFTBoostVault.sol and ARCDVestingVault.sol
The _syncVotingPower function can underflow when reducing voting power, causing a revert. An attacker could trigger this by withdrawing an NFT with a high multiplier or when an admin revokes a grant, potentially blocking those operations.
Submitted by ladboy233, also found by Topmark
Lines of code:
Proof of Concept
Note this function:
function _syncVotingPower(address who, NFTBoostVaultStorage.Registration storage registration) internal {
History.HistoricalBalances memory votingPower = _votingPower();
uint256 delegateeVotes = votingPower.loadTop(registration.delegatee);
uint256 newVotingPower = _currentVotingPower(registration);
// get the change in voting power. Negative if the voting power is reduced
int256 change = int256(newVotingPower) - int256(uint256(registration.latestVotingPower));
// do nothing if there is no change
if (change == 0) return;
if (change > 0) {
votingPower.push(registration.delegatee, delegateeVotes + uint256(change));
} else {
// if the change is negative, we multiply by -1 to avoid underflow when casting
votingPower.push(registration.delegatee, delegateeVotes - uint256(change * -1));
}
registration.latestVotingPower = uint128(newVotingPower);
emit VoteChange(who, registration.delegatee, change);
}
We need to pay special attention to this line of code:
votingPower.push(registration.delegatee, delegateeVotes - uint256(change * -1));
It is possible that delegateeVotes - changes can revert in underflow. This only happens when we try to reduce the voting power.
In _withdrawNFT, if an NFT with a high multipler is removed in NFTBoostVault.sol it can cause the voting power to decrease.
// update the delegatee's voting power based on multiplier removal
_syncVotingPower(msg.sender, registration);
Or, in ARCDVestingVault.sol when an admin tries to revoke a user’s grant.
// update the grant's withdrawn amount
if (amount == withdrawable) {
grant.withdrawn += uint128(withdrawable);
} else {
grant.withdrawn += uint128(amount);
withdrawable = amount;
}
// update the user's voting power
_syncVotingPower(msg.sender, grant);
Recommended Mitigation Steps
Before calling delegateeVotes - uint256(change * -1), make sure delegateeVotes > uint256(change * -1), otherwise just set to 0.
PowVT (Arcade.xyz) confirmed and commented via duplicate issue #540:
Will look into underflow scenarios here where there is a multiplier boost.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code subtracts a negative change without checking that the delegatee's current votes are at least as large as the decrease, leading to an unsigned integer underflow.
Impact
Withdrawing an NFT with a high multiplier or revoking a grant could revert, potentially locking funds or preventing administrative actions.
What the attacker needed
User has an NFT with a high multiplier; or admin revokes a grant
The fix
Before subtracting, check that delegateeVotes is greater than the decrease; otherwise set the new voting power to zero.
How it was found
- A user has an NFT with a high multiplier boosting their voting power.
- The user withdraws the NFT, which reduces their voting power.
- _syncVotingPower is called to update the delegatee's votes.
- The subtraction underflows and the transaction reverts.
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.
When a user's voting power decreases, the code subtracts the decrease from the delegatee's total votes. If the total votes are smaller than the decrease, the subtraction goes below zero and the transaction fails. This can stop users from withdrawing NFTs or admins from revoking grants.
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.