MartenitsaEvent::stopEvent
loops through the unbounded array participants
, making this function vulnerable to economic Denial of Service (eDoS) or even regular DoS attacks.
MartenitsaEvent::stopEvent
is designed to reset the producer status (tracked by mapping isProducer
) of all participants at the end of an event. To perform this reset, the function iterates over the participants
array that, however, is an unbounded array: there is no limit on the number of participants that can join an event. Consequently, this function is vulnerable to economic Denial of Service (eDoS) or even regular DoS attacks.
(eDoS: Executing the stopEvent
function would not hit the gas limit, thus avoiding a complete Denial of Service (DoS), but it would consumes an inordinate amount of gas that would makes the transaction economically unfeasible for the protocol owner to perform.)
The following test simulates a scenario where 40,000 participants join an event, which results in the stopEvent function consuming an amount of gas that would exceed typical block gas limits today (30 million):
As seen, hitting the gas limit would require about 40,000 participants. While this number might seem big, consider that
it is not inconceivable, and not without precedent, that a protocol gets so popular that even more people want to join its events;
participants are economacially incentivized to perform a DoS to retain their producer status forever;
performing an eDoS requires a lot less participants, but effectively gives the same results.
Issues arise even without a DoS or eDoS:
Increased Transaction Costs: Even without malicious intent, regular usage could lead to high gas costs. The more legitimate users join events, the more the cost of calling stopEvent
will be.
Contract Clogging: With the participants
array not being cleared (another bug), repeated events can lead to unchecked growth in its size, further exacerbating the issue.
A DoS or eDoS would result in:
Irreversible Temporary Statuses: Participants from the event will indefinitely maintain their producer status.
Economic Manipulation: Retaining their producer status allows participants to indefinitely create, list, and sell Martenitsa NFTs. This unlimited production and sale capability can lead to market manipulation and unfair economic advantages, as these users exploit their persistent producer privileges without temporal restrictions.
Manual review, Foundry.
Consider implementing one or more of the following changes:
Limit the number of participants:
You can consider doing this in a more sophisticated manner: e.g. declaring the max number of participants as a non-constant variable, and add a function with which you could adjust its value within reasonable, safe limits. Additionally, if your events get super popular, you can just run more events after each other.
Clear the participants
array in MartenitsaEvent::stopEvent
:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.