The RapBattle protocol implements a CRED token reward system designed to incentivize NFT staking through daily token distributions. Players who stake their Rapper NFTs should receive proportional CRED rewards that can be withdrawn and used for battle wagering, creating a sustainable token economy. The minting mechanism is intended to ensure all earned rewards reach eligible players without token loss or economic distortion.
The mint()
function contains a critical logic error where coin::destroy_zero()
is called on non-zero token amounts when players haven't registered for CRED tokens. The destruction function expects zero-value coins but receives actual reward amounts (1-4 CRED per unstaking event), causing either runtime aborts or permanent token loss from circulation. This bug enables players to gain free NFT stat improvements while the protocol loses economic value, creating systematic deflation and potential protocol insolvency.
The vulnerability stems from the flawed error handling in the token minting logic:
Likelihood:
New users frequently interact with protocols without fully understanding token registration requirements, making unregistered staking attempts common during normal protocol usage.
The staking mechanism automatically attempts reward distribution regardless of user registration status, triggering the bug systematically. Advanced users may deliberately exploit this behavior to gain stat improvements without economic cost.
Impact:
Economic manipulation enables players to receive valuable NFT upgrades (skill improvements worth 5-10 points each) while causing permanent CRED token loss from protocol circulation.
Systematic exploitation leads to protocol insolvency through token deflation, unfair competitive advantages for bug exploiters, and potential runtime failures that could brick the unstaking functionality entirely.
The following test demonstrates the token destruction bug during normal staking operations:
Implement automatic account registration instead of attempting to destroy non-zero tokens:
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.
The contest is complete and the rewards are being distributed.