The Swan
contract exhibits a timing vulnerability related to asset listing and relisting functionality. Specifically, the vulnerability arises when an asset is initially listed and subsequently relisted before the intended listing period expires. This issue occurs because the createdAt
timestamp is updated to the current block.timestamp
upon relisting, effectively ignoring the prior listing history and creating the potential for unexpected contract behavior.
The core of the vulnerability lies in the improper handling of the createdAt
timestamp during the relisting process. When an asset is relisted, the contract sets a new createdAt
value to the current block.timestamp
. This update overrides the original listing’s timing data, leading to the following issues:
Inconsistent Timing Information: The updated createdAt
upon relisting disregards the initial listing time, potentially causing logic relying on the original timing (e.g., restrictions based on round duration or asset history) to fail.
Round Overlap Ignored: Since previous contract states before block.timestamp
are ignored, the relisted asset may appear "new," disregarding the duration it was previously listed.
Event Overlap Risk: By updating the listing’s createdAt
upon relisting, the contract may inadvertently enable relisting within an active round, which could bypass intended checks (such as limitations on listing frequency or time-based pricing adjustments).
This vulnerability impacts the integrity of time-based functionality and round-based mechanics within the Swan
contract:
User Confusion: Users or buyers relying on consistent timing information might interpret relisted assets incorrectly, potentially undermining their trust in the platform.
Round Abuses: The ability to relist with a new timestamp could potentially bypass round-based restrictions, allowing an asset to be relisted multiple times within a single round, thus violating the intended contract flow.
Event Emission Discrepancy: Events emitted upon relisting will reflect updated times without accurate historical context, which could impact audits and data analysis of the marketplace activity.
Manual Code Review: To identify logical and structural flaws in the contract's time-tracking mechanisms.
Static Analysis (e.g., Slither): Used for detecting any related code patterns and to verify the integrity of functions handling state updates and timestamp logic.
To mitigate this vulnerability, consider the following recommendations:
Separate Initial and Relisting Timestamps: Store the initial createdAt
timestamp separately from any updates on relisting, allowing the contract to maintain a complete history of the asset’s timeline.
Add Relisting Restriction Logic: Enforce timing restrictions that prevent an asset from being relisted within the same round or a specified period after the initial listing.
Implement Conditional Logic Based on Rounds: Ensure that relisting checks for round completion before updating the createdAt
timestamp. This logic should be based on round-specific parameters instead of a general timestamp to maintain compatibility across multiple rounds.
Enhanced Event Logging: Include both the original and updated timestamps in relisting events to ensure transparency and accurate tracking of listing history.
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.