The withdrawAllFailedCredits() function allows users to withdraw ETH that failed to transfer to them during normal operations, implementing a pull-over-push pattern for safety.
The function incorrectly uses msg.sender instead of _receiver when resetting the credits balance to zero, allowing attackers to steal any user's accumulated failed credits.
Likelihood:
Occurs when any user has accumulated failed transfer credits from refunded bids or seller proceeds
Happens when an attacker monitors the failedTransferCredits mapping for non-zero balances
Impact:
Complete theft of all failed transfer credits from any user
Victim's credits remain unchanged in storage while attacker receives the ETH
Victim cannot withdraw their own credits after theft (balance shows as non-zero but contract lacks funds)
The following test demonstrates how an attacker can steal another user's failed transfer credits. The vulnerability exists because the function reads the credit amount from the _receiver parameter but resets msg.sender's balance to zero instead. This mismatch allows anyone to withdraw another user's credits while leaving the victim's balance unchanged in storage.
The fix requires ensuring consistency between the address used for reading the credit balance and the address used for resetting it to zero. Additionally, the funds should be sent to the correct recipient. The function should either allow users to withdraw only their own credits (using msg.sender throughout) or properly implement admin withdrawal functionality.
Option 1: Users can only withdraw their own credits (Recommended)
Option 2: Fix the current implementation to work correctly
withdrawAllFailedCredits allows any user to withdraw another account’s failed transfer credits due to improper use of msg.sender instead of _receiver for balance reset and transfer.
withdrawAllFailedCredits allows any user to withdraw another account’s failed transfer credits due to improper use of msg.sender instead of _receiver for balance reset and transfer.
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.