The event emission in the Game.sol::declareWinner function logs incorrectly as the lines of code do not follow CEI pattern.
The declare::Winner function is expected to log the GameEnded event with the following data:
currentKing, pot, block.timestamp, gameRound.
The potential re-entrancy issue is not clear in this case as there is no external interaction taking place here. However, this seemingly harmless pattern can be exploited in case of a code upgrade or integration where this function may be called by another function. It is thus recommended to follow the CEI pattern.
Likelihood:
The issue is bound to occur as the event would be emmitted whenever the winner is declared by a caller.
Impact:
This bug can lead to misleading logic when events are being relied upon due to the misleading emitted contract state.
Furthermore, the issue would be a re-entrancy attack vector if the contract should interact externally with others, or contract upgrades with other new functions.
The recommended mitigation is to follow the CEI pattern for best practice and use a variable to store the pot as shown below:
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.