The randomness in lines 124 & 125 are obtained insecurely/awkwardly. This exact issue has been addressed on the aptos documentation page (https://aptos.dev/build/smart-contracts/randomness)
The intention is to generate a random number to make the competition as fair as possible to all the participants, so users can randomly get a slice between 100-500
The problem is that the "randomness" is predictable since it comes from the block timestamp
Likelihood: Highly likely because it determines how many slices you will get, so anyone aware of this issue will likely try to exploit it (including myself yes. I would stoop that low for pizza)
Reason 1 // Describe WHEN this will occur (avoid using "if" statements)
since the randomness is obtained from the block timestamp, it eliminates the randomization element and it is predictable
Reason 2
The competition wouldn't be fair anymore
Impact: High Impact
Impact 1
a malicious user may bias the result by picking the transaction submission time
Impact 2
a malicious validator can bias the result easily by selecting which block the transaction goes to
P.S: both impacts are taken straight from the horse's mouth, exactly as worded on the aptos documentation page.
A malicious user can compare results and call the function over and over until they get 500 slices instead of whatever is assigned to them on random
First let's run a local node
Then we initialize an account
After that, we deploy the contract
Run the claim function twice in a row, back to back
First result is 137 and the second result is 138, this clearly shows a pattern connected to the time factor since if you increased the time gap between the function calls, the gap between the slices increases with it.
Very predictable and allows me and anyone else to wait for the perfect time to gain the maximum amount of slices
The best way to achieve randomness as securely as possible is to use aptos' randomness API
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.