The use of block.timestamp
for checking time-based conditions in the closePot
function is potentially susceptible to minor manipulation by miners. While the likelihood of such manipulation is low, it can still introduce minor inaccuracies in time-based logic. Additionally, the current duration of 90 days is safe from overflow concerns, but caution is needed if extending this duration beyond 195 days due to potential overflow issues.
The closePot
function uses block.timestamp
to ensure that 90 days have passed since the contract was deployed before allowing the pot to be closed:
The issue with using block.timestamp
is that miners can manipulate it slightly (by up to 900 seconds). While this does not constitute a high risk in most cases, it could lead to minor inaccuracies in enforcing the exact 90-day period. The potential for manipulation is generally low, but it is important to note that the 90 days is not an exact duration and could be affected by minor timestamp variations.
Additionally, while a 90-day duration is within a safe range, using a significantly longer duration (such as 195 days or more) could lead to overflow issues in Solidity’s time calculations, as highlighted in external sources.
The impact of this vulnerability includes:
Minor Timestamp Manipulation: Miners could slightly manipulate block.timestamp
, leading to minor inaccuracies in time-based logic. This manipulation is generally low in likelihood but can introduce timing discrepancies.
Potential Overflow Concerns: While 90 days is safe, extending the period significantly (e.g., to 195 days or more) could risk overflow issues, potentially affecting time-based conditions and logic in the contract.
Non-Exact Duration: Users relying on exact time durations should be aware of the slight potential discrepancies introduced by block.timestamp
.
Manual Review
External Source Reference: Solodit Issue: M-05 Expiration Calculation Overflows
While the current usage of 90 days is generally safe, consider the following recommendations to mitigate potential issues:
Acknowledge Minor Discrepancies: Understand and communicate that block.timestamp
is not an exact measure and can have slight discrepancies. Design your application logic accordingly to tolerate small variations.
Limit Duration to Safe Range: Keep time-based conditions within a safe range (such as 90 days) to avoid potential overflow issues. If longer durations are needed, ensure calculations are handled in a way that prevents overflows.
Consider Alternatives for High Accuracy Needs: For applications where exact timing is critical, consider alternative approaches that do not rely solely on block.timestamp
, such as using an off-chain oracle to provide time data.
While it is acceptable to use a 90-day period in the current implementation, if the duration were to be extended significantly (e.g., to 195 days), additional caution and safeguards would be necessary to prevent potential overflow issues and ensure accurate time-based conditions.
By following these recommendations, the contract can handle time-based conditions more reliably while mitigating the potential minor risks associated with using block.timestamp
.
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.