The voteForMartenitsa
function in the MartenitsaVoting.sol
contract allows users to vote for a particular Martenitsa token. However, a potential vulnerability exists in the continuous pushing of token IDs into an array after each vote. This approach could lead to an out-of-gas error if the array grows too large, especially in scenarios where a large number of votes are cast for the same token ID consecutively.
The vulnerability lies in the continuous appending of token IDs to the _tokenIds
array within the voteForMartenitsa
function. Each time a user votes, the token ID is added to the array, potentially causing it to grow significantly over time. In scenarios where a large number of votes are cast for the same token ID in quick succession, the array could become excessively large, leading to an out-of-gas error during transaction execution.
This vulnerability could disrupt the voting process and affect the fairness and accuracy of the voting mechanism, potentially impacting the announcement of winners and overall system functionality.
The impact of this vulnerability could be significant, potentially resulting in out-of-gas errors during transaction execution, disruption of the voting process, and inaccuracies in determining the winners of the voting process. It could undermine the integrity of the voting system and erode user trust in the platform.
manual code review.
To mitigate this vulnerability and ensure the stability and efficiency of the voting mechanism, it is recommended to revise the approach for storing token IDs. Consider alternative data structures or storage mechanisms that can handle large amounts of data without impacting gas costs significantly. Additionally, implementing gas-efficient coding practices and optimizing data storage can help prevent out-of-gas errors and ensure the smooth operation of the voting system.
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.