Skip to content
Business logic Audit finding Intermediate

Unbounded `_unlockTime` allows the attacker to get a huge `stakedTimeBonus` and dominate the voting

The staking contract did not enforce a maximum unlock time, allowing an attacker to set an extremely large unlock time and receive an enormous staked time bonus. This could give the attacker a huge number of votes and let them dominate voting.

WatchPug Follow with koxuan, neumo and 5 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-frankendao-judging/issues/53

Found by

WATCHPUG, koxuan, neumo, hansfriese, curiousapple, bin2chen, Trumpero, John

Summary

stakingSettings.maxStakeBonusTime is not enforced, allowing the attacker to gain a huge stakedTimeBonus by using a huge value for _unlockTime.

Vulnerability Detail

There is no max _unlockTime check in _stakeToken() to enforce the stakingSettings.maxStakeBonusTime.

As a result, an attacker can set a huge value for _unlockTime and get an enormous stakedTimeBonus.

Impact

The attacker can get a huge amount of votes and dominate the voting.

Code Snippet

https://github.com/sherlock-audit/2022-11-frankendao/blob/main/src/Staking.sol#L389-L394

https://github.com/sherlock-audit/2022-11-frankendao/blob/main/src/Staking.sol#L356-L384

Tool used

Manual Review

Recommendation

Change to:

Solidity
  function _stakeToken(uint _tokenId, uint _unlockTime) internal returns (uint) {
    if (_unlockTime > 0) {
      unlockTime[_tokenId] = _unlockTime;
      uint time = _unlockTime - block.timestamp;
      uint maxtime = stakingSettings.maxStakeBonusTime;
      uint maxBonus = stakingSettings.maxStakeBonusAmount;
      if (time < stakingSettings.maxStakeBonusTime){
        uint fullStakedTimeBonus = (time * maxBonus) / maxtime;
      }else{
        uint fullStakedTimeBonus = maxBonus;
      }
      stakedTimeBonus[_tokenId] = _tokenId < 10000 ? fullStakedTimeBonus : fullStakedTimeBonus / 2;
    }

Discussion

zobront

Fixed: https://github.com/Solidity-Guild/FrankenDAO/pull/13

jack-the-pug

Fix confirmed

The original report as published on Sherlock, by WATCHPUG. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

Impact

An attacker could obtain a huge amount of votes and dominate the voting.

What the attacker needed

Ability to stake tokens

The fix

The fix was to cap the time bonus at `stakingSettings.maxStakeBonusAmount` when the unlock time exceeds `stakingSettings.maxStakeBonusTime`.

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 can lock their tokens for a chosen period and earn bonus voting power based on how long they lock. The code forgot to check that the lock period is not longer than the maximum allowed, so someone could lock for an absurdly long time and get a massive bonus, giving them far too much voting power.

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.

More by WatchPug

View all

197 more disclosed reports, best first.

More from FrankenDAO

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.