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

`MartenitsaEvent:stopEvent` function does not remove new producers from `producers` array after the end of event.

Summary

Description: stopEvent function is made to removes the producer role of the participants after the event is ended. But it only remove new producers from isProducer mapping and leaves the array producers without changes.

function stopEvent() external onlyOwner {
require(block.timestamp >= eventEndTime, "Event is not ended");
for (uint256 i = 0; i < participants.length; i++) {
- isProducer[participants[i]] = false;
}
}

Vulnerability Details

Proof of Concept:

  • This is not a big problem as isProducer mapping is used for access control checks in functions
    and after the end of Martenitsa Event user will not be able to create or list his tokens for sale.

  • But it breaks MartinisaToken:getAllProducers function and now it returns an array with wrong value as new producers are not removed from the array after the end of event.

Proof of Code:

Code for a bad function
function getAllProducers() external view returns (address[] memory) {
- return producers;
}

Impact

MartinisaToken:getAllProducers function will return an array with wrong values as new producers are not removed from the array producers after the end of event.

Tools Used

Manual review.

Recommendations

I propose to refactor _addProducer function in MartenitsaEvent contract and remove adding new producers to producers array or create a nested for loop to remove new producers from producers array and added it to stopEvent function.

Code for Adding
for (uint i = 0; i < participants.length; i++) {
for (uint j = 0; j < producers.length; j++) {
if (participants[i] == producers[j]) {
producers[j] = address(0);
}}}
Updates

Lead Judging Commences

bube Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Producers array not updated

Support

FAQs

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