The normal behavior calculates customer demand size pseudo-randomly using a seed from block.timestamp and msg.sender, hashed to determine base (1-5) and potential extra items based on reputation.
The specific issue is that the seed is predictable (timestamp is known pre-submission, sender is fixed), allowing users or miners to time transactions for favorable outcomes, manipulating demand size for optimal reputation effects or failures.
Likelihood:High
Users time transactions to achieve desired timestamps, directly influencing the seed and demand outcome.
Miners or validators front-run or delay blocks to manipulate timestamp for self-benefit in the simulation.
Impact:Low
Minor unfairness in game mechanics, such as consistently high/low demands without real randomness.
No direct fund loss, but subtle influence on reputation and sales patterns.
This test demonstrates the vulnerability by funding the company (10 ETH) and producing 10 items as OWNER, advancing time to a known timestamp (target_ts), then simulating the contract's seed calculation offline using keccak(timestamp || sender) to predict demand size (predicted_requested via base % 5 + extra chance based on reputation). It triggers a demand as PATRICK, measures inventory reduction (actual_requested), and asserts they match, proving attackers can pre-compute and time transactions for favorable outcomes (e.g., max items for rep gains).
Mitigations, in order of security:
1) Chainlink VRF (production)
Provably random values with cryptographic proof
Implementation example (via a Chainlink VRF service):
2) Commit–reveal scheme
Two-phase randomness with no trusted third party
Requires multiple transactions
3) Enhanced on-chain entropy (weaker, faster)
*Add less predictable inputs (e.g., block.prevrandao if available)
*Reduce predictability but not as robust as VRF
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.