BidBeastsNFTMarket::withdrawAllFailedCredits Allows Attacker to Drain Contract FundsNormally, a withdrawal function that returns previously failed transfers (a pull-payment pattern) must only allow the actual beneficiary to withdraw their own credits, and it must follow checks-effects-interactions or use a reentrancy guard. The mapping that stores credits (e.g., failedTransferCredits) must be cleared for the beneficiary before sending funds.
In the current implementation, the function reads credits for _receiver but clears the mapping for msg.sender and sends funds to msg.sender. This allows any caller to repeatedly withdraw the credited amount belonging to another address, because the beneficiary's mapping entry is never cleared. The contract balance can be drained by looping calls.
Likelihood
Any time failedTransferCredits[_receiver] > 0, any attacker can call this function with _receiver set to the victim and drain the victim's credited amount to themselves.
The vulnerability is exploitable by a simple externally-owned account or contract; no privileged access is required.
Impact
Complete or partial draining of contract funds via repeated withdrawals, leading to direct user and contract balance loss.
Loss of trust, user funds stolen, and marketplace functionality impaired. This is a direct financial impact and thus critical.
paste the code below in the test suite BidBeastsMarketPlaceTest.t.sol
ensure to add the attacker address
This PoC shows the attacker receives amount repeatedly because the contract clears failedTransferCredits[msg.sender] (attacker) rather than failedTransferCredits[_receiver] (victim).
Remove the _receiver parameter and use msg.sender directly to avoid confusion.
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.