[Medium-1] Hardcoded `monsterMultiplier` in case of `stakedTimeBonus` disregards the updates done to `monsterMultiplier` through `setMonsterMultiplier()`
The staking contract hardcoded the monster multiplier when calculating the staked time bonus, so any governance update to the multiplier via setMonsterMultiplier would not affect that bonus. An attacker could exploit this to receive a higher staked time bonus than intended, potentially gaining more voting power.
curiousapple Follow with hansfriese
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-11-frankendao-judging/issues/56
Found by
curiousapple, hansfriese
Summary
[Medium-1] Hardcoded monsterMultiplier in case of stakedTimeBonus disregards the updates done to monsterMultiplier through setMonsterMultiplier()
Vulnerability Detail
FrankenDAO allows users to stake two types of NFTs, Frankenpunks and Frankenmonsters , one of which is considered more valuable, ie: Frankenpunks,
This is achieved by reducing votes applicable for Frankenmonsters by monsterMultiplier.
function getTokenVotingPower(uint _tokenId) public override view returns (uint) {
if (ownerOf(_tokenId) == address(0)) revert NonExistentToken();
// If tokenId < 10000, it's a FrankenPunk, so 100/100 = a multiplier of 1
uint multiplier = _tokenId < 10_000 ? PERCENT : monsterMultiplier;
// evilBonus will return 0 for all FrankenMonsters, as they are not eligible for the evil bonus
return ((baseVotes * multiplier) / PERCENT) + stakedTimeBonus[_tokenId] + evilBonus(_tokenId);
}
This monsterMultiplier is initially set as 50 and could be changed by governance proposal.
function setMonsterMultiplier(uint _monsterMultiplier) external onlyExecutor {
emit MonsterMultiplierChanged(monsterMultiplier = _monsterMultiplier);
}
However, one piece of code inside the FrakenDAO staking contract doesn't consider this and has a monster multiplier hardcoded.
function stake(uint[] calldata _tokenIds, uint _unlockTime)
----
function _stakeToken(uint _tokenId, uint _unlockTime) internal returns (uint) {
if (_unlockTime > 0) {
--------
stakedTimeBonus[_tokenId] = _tokenId < 10000 ? **fullStakedTimeBonus : fullStakedTimeBonus / 2;**
}
--------
Hence any update done to monsterMultiplier would not reflect in the calculation of stakedTimeBonus, and thereby votes.
Impact : Medium
Any update done to monsterMultiplier would not be reflected in stakedTimeBonus; it would always remain as /2 or 50%.
Likelihood: Medium
One needs to pass a governance proposal to change the monster multiplier, so this is definitely not a high likelihood; it's not low as well, as there is a clear provision in spec regarding this.
Code Snippet
https://github.com/sherlock-audit/2022-11-frankendao/blob/main/src/Staking.sol#L393
Tool used
Manual Review
Recommendation
Consider replacing the hardcoded value with monsterMultiplier
Discussion
zobront
Fixed: https://github.com/Solidity-Guild/FrankenDAO/pull/12
jack-the-pug
Fix confirmed
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 staked time bonus calculation used a hardcoded division by 2 for monster NFTs instead of referencing the configurable monsterMultiplier variable.
Impact
Any update to the monster multiplier would not affect the staked time bonus, so it would always remain at 50% for monsters, potentially giving them more voting power than intended.
What the attacker needed
Governance proposal to change multiplier; stake a Frankenmonster NFT
The fix
The hardcoded value should be replaced with the monsterMultiplier variable, and the fix was confirmed.
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.
In this staking system, users get voting power based on their staked NFTs. Some NFTs are meant to give less voting power, controlled by a multiplier that can be changed by governance. However, one part of the code ignored this multiplier and used a fixed value, so changing the multiplier had no effect there. This could let someone get more voting power than they should.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.