move
let time = timestamp::now_microseconds();
let random_val = time % 401;
let random_amount = 100 + random_val;
This is insecure because:
Block timestamps are predictable.
Validators can manipulate timestamps within a range.
Attackers can exploit predictability to maximize rewards.
As a result, rewards that should be fairly distributed can be gamed by attackers, breaking fairness and undermining trust in the system.
##Risk
Attackers can:
Predict outcomes by calculating time % 401 locally.
Run a bot to submit claims only when rewards are highest.
Exploit validator timestamp manipulation to bias results.
Impact:
Unfair distribution of pizza slices.
Reward drain by a single attacker.
Loss of fairness and trust in the application.
##Proof of Concept (PoC)
Attacker bot simulation:
move
fun attacker_bot() {
let t = timestamp::now_microseconds();
let predicted = (t % 401) + 100;
// Only claim when reward is high
if (predicted > 480) {
pizza_drop::claim_slice();
}
}
Expected Outcome:
Average user reward ≈ 300.
Attacker reward ≈ 480–500 consistently.
System fairness is broken.
##Recommended Mitigation
Avoid using block timestamps as a randomness source.
Option 1: Use Aptos’ VRF (Verifiable Random Function)
move
let random_seed = aptos_std::rand::u64();
let random_val = random_seed % 401;
let random_amount = 100 + random_val;
Option 2: Commit-Reveal Scheme
Users commit to a random seed in one transaction.
Reveal the seed in a later transaction.
Combine seeds from multiple users for final randomness.
This ensures randomness is unpredictable, unbiased, and unmanipulatable.
The `get_random_slice` function should only be called by the owner via the `register_pizza_lover` function. Also, the `owner` is trusted and will not choose a specific time for a new user to register. Therefore, I disagree with the claim of most reports in this group that an attacker can manipulate the random number of pizza slices. But I agree with the root cause of the reports in this group, that the random distribution is not completely random.
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.