Beginner FriendlyGameFi
100 EXP
View results
Submission Details
Severity: medium
Valid

Predictable Randomness in get_random_slice Allows Reward Manipulation

Description The function get_random_slice uses timestamp::now_microseconds() to generate randomness for pizza slice distribution:

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.

Updates

Appeal created

bube Lead Judge 12 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Predictable randomness

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.