Root Cause: The withdrawAllFailedCredits function lacks a validation to ensure the _receiver address is not the zero address (address(0)). If the failedTransferCredits mapping contains a non-zero balance for address(0)—potentially due to a bug in another function like _payout—any user can call withdrawAllFailedCredits(address(0)) to withdraw those funds. The absence of this check, combined with the existing issue of clearing failedTransferCredits[msg.sender] instead of _receiver, enables unauthorized access.
Impact: This vulnerability allows any user to steal funds credited to the zero address, leading to potential financial loss. It exacerbates the related mapping update bug, enabling repeated exploitation without affecting the zero address balance, thereby undermining the contract’s security and user trust.
The withdrawAllFailedCredits function in the BidBeastsNFTMarket contract does not verify that the _receiver address is not the zero address (0x0). If the failedTransferCredits mapping contains a non-zero balance for address(0) (e.g., due to a bug in another function like _payout), any user can call withdrawAllFailedCredits(address(0)) to withdraw those funds. This allows unauthorized access to funds credited to the zero address, which should not be accessible.
Likelihood: Medium. The vulnerability depends on the failedTransferCredits[address(0)] having a non-zero balance, which may occur due to bugs in payout logic or external interactions. The likelihood increases in complex contracts with multiple fund-handling functions.
Impact: Medium. Unauthorized withdrawals from the zero address result in financial loss, though the impact is limited to the amount credited there. Combined with the mapping bug, it amplifies trust and security concerns, though it does not affect all users directly.
This test demonstrates the vulnerability by showing that an attacker can withdraw funds credited to the zero address (address(0)) without any authorization. The test sets a balance of 2 ether for address(0) in the failedTransferCredits mapping and verifies that an attacker can steal these funds.
Add the following test to the BidBeastsNFTMarketTest.t.sol test file to reproduce the issue:
Setup: The zero address is credited with 2 ether in failedTransferCredits[address(0)] via storage manipulation.
Attack: The attacker calls withdrawAllFailedCredits(address(0)), receiving 2 ether while resetting their own (zero) balance.
Result: The zero address’s credits remain 2 ether (unaffected due to the mapping bug), confirming the vulnerability.
To prevent unauthorized withdrawals from the zero address, add a check to ensure _receiver is not address(0). Additionally, consider addressing the related issue of incorrect mapping updates (resetting msg.sender instead of _receiver) to fully secure the function.
Example Fix:
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.