Potential Vulnerability in the PuppyRaffle Contract – Addressing Refund & Winner Selection Edge Case #286
Replies: 3 comments 3 replies
-
What a catch, Keep grinding. |
Beta Was this translation helpful? Give feedback.
0 replies
-
interesting, was about to create a discussion on this. |
Beta Was this translation helpful? Give feedback.
2 replies
-
LFG! I think we covered this in the original report? It's been a while I'd have to double check 😅 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I wanted to share a potential vulnerability I identified in the
PuppyRaffle
contract. I am aware Patrick mentions that not all issues will be addressed during the course, allow me to share my excitement though :) .Description of the Issue
When an active player calls the
PuppyRaffle:refund
function, they are refunded, and their address in theplayers
array is set toaddress(0)
. However, when thePuppyRaffle:selectWinner
function is called, if the randomly chosen winner index corresponds to an exited player (address(0)
), the prize pool is sent to the zero address, effectively burning the funds.Proof of Concept
The following test demonstrates the issue:
Recommended Mitigation
To avoid selecting a refunded player, the
selectWinner
function can be updated to skip indices that referenceaddress(0)
by implementing a loop:This ensures that only valid, active players are considered for winner selection.
Let's keep grinding, WAGMI!
Beta Was this translation helpful? Give feedback.
All reactions