The Auction contract calculates the price of ZENO tokens using block.timestamp, which miners can manipulate within a small window (typically ±30 seconds). This allows miners to influence the auction price to their advantage, enabling them to buy ZENO tokens at artificially low/high prices and profit unfairly.
https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/zeno/Auction.sol#L69
Exploit Scenario
Auction Setup: An auction runs from startTime to endTime, decaying the price from startingPrice to reservePrice.
Miner Participation: A miner submits a transaction to buy ZENO tokens.
Timestamp Manipulation: The miner mines the block and sets block.timestamp to a value that skews the price calculation.
Code Proof:
In Auction.sol, the price calculation relies on block.timestamp:
Attack Simulation:
Auction Parameters:
startTime: 12:00 PM
endTime: 1:00 PM
startingPrice: 100 USDC
reservePrice: 50 USDC
Fair Price at 12:30 PM:
Miner Manipulation:
The miner sets block.timestamp to 12:25 PM (5 minutes earlier).
Result: Miner buys ZENO at 75 USDC (fair) but tricks the contract into charging 79.16 USDC, pocketing the difference.
Unfair Profits: Miners extract value at the expense of honest participants.
Protocol Drainage: Repeated exploitation could drain funds from the auction pool.
Manual reviews, static analysis
Replace block.timestamp with a decentralized oracle (e.g., Chainlink) to ensure tamper-proof timestamps.
Step 1: Integrate Chainlink’s Timestamp Oracle
Step 2: Modify Price Calculation to Use Oracle Time
Step 3: Add Sanity Checks
Ensure the oracle timestamp is within an acceptable deviation from block.timestamp:
Why This Fix Works
- Decentralized Time Source: Chainlink oracles provide tamper-proof timestamps.
Manipulation Resistance: Miners cannot influence oracle-reported timestamps.
Graceful Degradation: If the oracle fails, the require statement halts the contract, preventing exploitation.
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.