Delegate can keep can keep delegatee trapped indefinitely
A delegate can repeatedly open proposals so that their delegatees are always locked and cannot unstake or redelegate. This traps users indefinitely in the delegation.
rvierdiiev Follow with curiousapple and 0x52
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-11-frankendao-judging/issues/23
Found by
rvierdiiev, curiousapple, 0x52
Summary
Users are allowed to delegate their votes to other users. Since staking does not implement checkpoints, users are not allowed to delegate or unstake during an active proposal if their delegate has already voted. A malicious delegate can abuse this by creating proposals so that there is always an active proposal and their delegatees are always locked to them.
Vulnerability Detail
modifier lockedWhileVotesCast() {
uint[] memory activeProposals = governance.getActiveProposals();
for (uint i = 0; i < activeProposals.length; i++) {
if (governance.getReceipt(activeProposals[i], getDelegate(msg.sender)).hasVoted) revert TokenLocked();
(, address proposer,) = governance.getProposalData(activeProposals[i]);
if (proposer == getDelegate(msg.sender)) revert TokenLocked();
}
_;
}
The above modifier is applied when unstaking or delegating. This reverts if the delegate of msg.sender either has voted or currently has an open proposal. The result is that under those conditions, the delgatee cannot unstake or delegate. A malicious delegate can abuse these conditions to keep their delegatees forever delegated to them. They would keep opening proposals so that delegatees could never unstake or delegate. A single users can only have a one proposal opened at the same time so they would use a secondary account to alternate and always keep an active proposal.
Impact
Delegatees can never unstake or delegate to anyone else
Code Snippet
https://github.com/sherlock-audit/2022-11-frankendao/blob/main/src/Staking.sol#L166-L174
Tool used
Manual Review
Recommendation
There should be a function to emergency eject the token from staking. To prevent abuse a token that has been emergency ejected should be blacklisted from staking again for a certain cooldown period, such as the length of current voting period.
Discussion
zobront
In the case that a user did this, Admins would create a contract that all "stuck" users approve, and they would veto and unstake all tokens in one transaction. It would be inconvenient, but no long term harm would be caused.
I still think it's valid as a Medium, as this is obviously a situation we'd like to avoid being possible.
zobront
Fixed: https://github.com/Solidity-Guild/FrankenDAO/pull/18
This fix addresses the risk laid out in the issue, that a delegate may repeatedly propose to keep votes locked.
We chose to not address the similar risk with voting because admins need to explicitly verify proposals before they can be voted on, so in the event this happens, admins would just hold off on verifying to give them a chance to undelegate.
We decided to go this direction because the cooldown period would add extra complexity and slightly increase gas fees on txs that we plan to refund a lot of.
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 lock condition checks whether the delegate has an active proposal or has voted, and a malicious delegate can keep that condition true by continuously proposing.
Impact
Delegatees can never unstake or delegate to anyone else, though admins could intervene by vetoing and unstaking tokens via a special contract.
What the attacker needed
Victim delegates to attacker; attacker has a second account; attacker can create proposals
The fix
The issue was fixed by adding a mechanism to address the risk of repeated proposals locking votes.
How it was found
- The attacker becomes the delegate of a victim.
- The attacker opens a proposal, which locks the victim's tokens.
- The attacker uses a second account to open another proposal as the first closes, keeping a proposal always active.
- The victim tries to unstake or redelegate but the transaction reverts because the delegate has an active proposal.
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 system, users can lend their voting power to someone else, called a delegate. Normally they can take it back, but a rule blocks that while the delegate has an active proposal or has voted. A malicious delegate can keep making new proposals so the block never lifts, trapping the user.
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.