The PizzaDrop contract should generate unpredictable random slice selections to ensure fair distribution among participants
The contract uses timestamp::now_microseconds()
for randomness generation, which is predictable and manipulable by validators
Likelihood:
Validators control block timestamps and can manipulate microsecond precision to influence outcomes
The modulo operation creates predictable patterns exploitable in every transaction
Impact:
Unfair slice distribution allowing malicious actors to consistently claim desired pizza slices
Loss of user trust in the randomness mechanism and platform integrity
The vulnerability allows validators to manipulate block timestamps to achieve desired random outcomes. Since get_random_slice()
uses timestamp::now_microseconds() % 8
, an attacker controlling validation can influence the microsecond precision to target specific slice values. This completely breaks the fairness assumption of random distribution.
The fix implements Aptos's secure randomness API using the #[randomness]
annotation. This provides cryptographically secure randomness that cannot be manipulated by validators or any other party. The new_generator()
creates a secure random number generator seeded with entropy from the Aptos randomness beacon, ensuring truly unpredictable outcomes for fair pizza slice distribution.
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.