The contract uses timestamp::now_microseconds() % 401 + 100
to generate a “random” slice size (100–500 APT). This approach is not cryptographically secure. As documented by Aptos, using the current timestamp for randomness is vulnerable to manipulation: “a malicious user may bias the result by picking the transaction submission time; a malicious validator can bias the result by selecting which block the transaction goes to.”aptos.dev. In other words, the block proposer (validator) or the caller can influence timestamp::now_microseconds()
to skew the outcome.
** Likelihood **:
Attackers (or even the owner/validator) can predict or influence the random value. For example, an attacker could delay or front-run the registration transaction to a time when time % 401
yields a high slice value. This undermines the fairness of the airdrop.
** Impact **:
Malicious actors may consistently receive larger slice amounts or ensure a desired outcome. This violates the stated “random surprise” promise. In the worst case, a validator could manipulate block timing so that a particular user always gets the maximum or some controlled value. The randomness becomes effectively deterministic for an attacker with sufficient control.
Suppose the attacker observes that time % 401 == 400
(max modulo result) yields the largest slice. The attacker submits the register_pizza_lover
transaction exactly when now_microseconds() % 401 == 400
. They will receive a slice of 500 APT. Repeating this (or a validator choosing when to include the transaction) can bias rewards. Example PoC assuming that get_random_slice
is entry
and uses timestamp::now_microseconds()
to compute the random, so anyone can call it. If the attacker time submission for time % 401 == 400
, they will be assigned the max slice:
Use a secure randomness source by implementing a commit-reveal scheme off-chain or use a verifiable random function (VRF). Or use an on-chain randomness API provided by APTOS (aptos_framework::randomness::u64_range
) that delivers uniform, unbiased random values according to the documentation. For example:
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.