The _setFinallizedVaultBalance() function is called from setWinner() to capture the vault balance at the end of the event for winner payout calculations. Under normal behavior, this function should verify that the event has ended before finalizing the balance, ensuring accurate calculations for winner payouts.
However, the function on line 146 checks block.timestamp <= eventStartDate, which verifies if the event has started, not if it has ended. While setWinner() already ensures block.timestamp > eventEndDate before calling this function, the check in _setFinallizedVaultBalance() is checking the wrong condition. The function should verify that block.timestamp > eventEndDate to ensure the event has ended before finalizing the balance. This creates a logic inconsistency and could cause issues if the function is ever called from other contexts or if the code is refactored in the future.
This logic error occurs whenever _setFinallizedVaultBalance() is called, as it checks the wrong timing condition, verifying event start instead of event end
The bug manifests as a logic inconsistency that, while currently mitigated by setWinner()'s check, could cause issues if the function is refactored or called from other contexts
The timing check is incorrect and doesn't verify the intended condition (event end), creating a logic inconsistency in the codebase
If the function is ever called from other contexts or the code is refactored, the incorrect check could allow premature finalization before the event ends, leading to incorrect payout calculations
Explanation of PoC:
This proof of concept demonstrates the incorrect timing check. The test shows that _setFinallizedVaultBalance() checks if the event has started, but it should check if the event has ended. While the current implementation is protected by setWinner()'s check, the logic is incorrect.
Test Results:
✅ _setFinallizedVaultBalance() checks block.timestamp <= eventStartDate
✅ Should check block.timestamp <= eventEndDate instead
✅ Logic inconsistency confirmed
Explanation:
The recommended mitigation corrects the timing check to verify that the event has ended, not just started. This ensures the function correctly validates the timing condition and maintains consistency with the intended behavior.
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.