The BidBeastsNFTMarketPlace.sol::withdrawAllFailedCredits() allows users with failed credits to withdraw them to a recipient address they prefer. However, the function incorrectly reads the credits of the receiver failedTransferCredits[_receiver], instead of the caller, which is wrong as receiver is not obligated to have failed credits - receiver just acts as a transfer destination. Also, the funds are never send to the receiver but to the caller. This flawed flow gives attackers a perfect opportunity to exploit it and steal funds.
Also, since the _receiver’s balance is never reduced, the same credits can be withdrawn multiple times, allowing an attacker to completely drain the contract’s ETH.
Likelihood:
High.
Impact:
Users failed credits can be stolen by malicious actors.
The market's ETH can be drained completely.
Consider the following example:
Admin mints an NFT to Alice.
Alice lists her NFT in the market.
The auction begins and Bob places his bid.
Another user comes and places a bigger bid - maybe wins the auction.
Bob will be refunded his bid, but if something goes wrong, the tx wil not revert, but instead the failed credits of Bob will be increased, allowing him to redeem them later to a new receiver address via withdrawAllFailedCredits.
An attacker can frontrun Bob and pass receiver = Bob.
Bob's credit will be send to attacker.
This is just one attack path, but the failed credits can be stolen from the nft seller as well, or any user who has a record in the failedTransferCredits mapping.
Instead of reading the amount to withdraw from the receiver record => amount = failedTransferCredits[_receiver], use msg.sender and in the .call transfer the funds to the receiver address.
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.