The RapBattle protocol is designed to facilitate fair head-to-head battles between Rapper NFTs using on-chain randomness to determine winners. Each battle should have genuinely unpredictable outcomes based on participant skill levels, ensuring that no player can systematically game the battle system. The randomness mechanism is intended to prevent exploitation while maintaining competitive integrity based on NFT training and skill development.
The go_on_stage_or_battle()
function uses timestamp::now_seconds()
as its sole source of randomness, making battle outcomes completely predictable. The outcome formula rnd = timestamp % total_skill
followed by winner = if (rnd < defender_skill) { defender } else { challenger }
allows sophisticated attackers to calculate exact battle results before committing funds and manipulate transaction timing to guarantee victory. This predictable behavior violates the protocol's core fairness assumption and enables systematic drainage of the entire battle prize pool system.
The vulnerability stems from the randomness implementation in the battle resolution logic:
Likelihood:
Technical users routinely analyze smart contract code before participating in DeFi protocols, making discovery of the predictable timestamp formula highly probable during normal due diligence processes.
Battle timing is entirely user-controlled through the go_on_stage_or_battle()
function, enabling attackers to monitor the mempool, calculate exact timestamps when their transactions will execute, and only submit transactions for battles they're mathematically guaranteed to win.
Impact:
Systematic battle manipulation enables sophisticated attackers to achieve 100% win rates while honest players experience normal randomness, creating complete economic extraction from all battle prize pools.
Protocol integrity violation destroys the core competitive gaming experience, leading to honest player exodus, protocol abandonment, and total system collapse when the predictable outcome pattern becomes publicly known.
The following test demonstrates the predictable nature of battle outcomes by successfully predicting exact winners based on timestamp manipulation:
Replace the predictable timestamp-based randomness with proper cryptographic randomness using Aptos Framework's secure randomness API:
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.