Beginner FriendlyFoundryGameFi
100 EXP
View results
Submission Details
Severity: low
Invalid

The owner of MartenitsaVoting can extend the voting period indefinitly

Summary

In MartenitsaVoting the Owner of the contract can call startVoting when the Voting period is almost over extending the period.

Impact

If the Owner want a particular Martenitsa to win, the Owner can extend the period for the vote untill that Martenitsa is the winning one.

Proof of Concept:
Add this test to MartenitsaVoting.t.sol

Proof Of Code
function testOwnerCanExtendTheVotingPeriod() public listMartenitsa {
vm.warp(block.timestamp + 1 days - 1);
// The voting period of 1 day is almost finished
voting.startVoting();
// The owner restart the counter
vm.warp(block.timestamp + (1 days / 2));
// The voting period is exended and it's still possible to vote
vm.prank(bob);
voting.voteForMartenitsa(0);
assert(voting.getVoteCount(0) == 1);
}

Tools Used

Foundry

Recommendations

In MartenitsaVoting add a state variable bool voteStarted and check if the vote is started before changing startVoteTime

contract MartenitsaVoting is Ownable {
MartenitsaMarketplace private _martenitsaMarketplace;
MartenitsaMarketplace.Listing list;
HealthToken private _healthToken;
uint256 public startVoteTime;
uint256 public duration = 1 days;
uint256[] private _tokenIds;
+ bool voteStarted = false;
...
function startVoting() public onlyOwner {
+ require(!voteStarted, "Vote already started");
startVoteTime = block.timestamp;
emit Voting(startVoteTime, duration);
}
Updates

Lead Judging Commences

bube Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.