The BidBeastsNFTMarket::withdrawAllFailedCredits function makes it possible for users to retrieve ETH that has not been payed out due to failed transaction from protocol to user.
The issue with the withdrawAllFailedCredits function is that the failedTransferCredits mapping retrieves the failed credits from _receiver address, then updates the failed credits of msg.sender to 0 and sends the _receiver credits to msg.sender.
Likelihood:
The likelihood of an transaction failing over a long period of time is high.
Anyone can make a transfer to revert and then call the withdrawAllFailedCreditsfunction.
Impact:
The attacker only needs to find or make one failed transfer to be able to drain the protocol for ETH.
The user that did not get paid is at risk of loosing their ETH.
Attacker makes a contract that has a receive function that reverts.
Attacker makes first bid with the contract that reverts.
Attacker makes a higher bid from another address which triggers the refund to previous bidder. This transaction reverts and mapping failedTransferCreditsgets updated with a balance.
Attacker then calls withdrawAllFailedCreditsfunction with the contract address that reverts as parameter. Does call this function multiple times until the protocol is drained for ETH.
First add this contract to the test suite. It simulates an address that fails to receive ETH so that their failedTransferCredits mapping gets a balance.
Then add this test to the test suite:
This will be the output. As you can see the attacker has drained all but 1 wei from the protocol:
Update the function so that the receivers failedTransferCreditsmapping is updated to 0 and the funds gets sent to receiver
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.