The contract is designed to assign a random airdrop amount between 100 and 500 APT to a user upon registration. The issue is that the randomness is derived from timestamp::now_microseconds()
, which is a predictable on-chain value, allowing for the outcome to be manipulated.
Likelihood:
This will occur when a sophisticated user or validator monitors the blockchain's timestamp.
They can then precisely time their transaction to be included in a block with a timestamp that results in a maximum or high-value payout.
Impact:
Loss of Fairness: The core promise of a random and fair distribution is broken, as certain users can guarantee themselves a larger share of the airdrop pool.
Reputational Damage: The project's credibility is damaged when the distribution mechanism is proven to be gameable, leading to a loss of community trust.
An attacker can predict the outcome of the "random" number generation by reading the current block timestamp. By knowing the timestamp, they can calculate the random_amount
before the transaction is even executed.
The mitigation requires replacing the insecure timestamp-based logic with a call to a secure on-chain randomness source, as intended by the #[randomness]
attribute.
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.