The createOffer function is vulnerable to race conditions due to the non-atomic incrementation and use of the offerId. When multiple users attempt to create offers simultaneously, it could lead to duplicate offerId assignments or overwriting of offers, potentially causing data corruption and inconsistent state in the marketplace.
In the createOffer function, the offerId is incremented after checking various conditions and performing external calls. However, since the incrementation and use of offerId are not atomic, concurrent execution of this function by multiple users can result in the same offerId being assigned to different offers. This could cause:
Duplicate Offer IDs: Multiple offers sharing the same offerId, leading to conflicts and data inconsistencies.
Overwriting of Offers: The offer data could be overwritten by subsequent transactions, resulting in the loss of previous offer information.
This issue is critical in a decentralized environment where multiple users might interact with the contract simultaneously.
Data Inconsistency: Duplicate or overwritten offerId could lead to inconsistencies in the offer mappings, breaking the integrity of the marketplace.
Potential Loss of Offers: Offers created with the same offerId might overwrite each other, causing some offers to be lost.
Security Risks: This could be exploited by malicious actors to create conflicting offers, potentially disrupting the marketplace's operations.
The root cause of this issue is the non-atomic nature of the offerId incrementation and usage in the createOffer function. The lack of synchronization between the increment and the use of offerId across multiple transactions leads to race conditions.
Manual Review
Consider using a more robust ID generation method, such as using a combination of user address, timestamp, and a nonce to create a unique ID for each offer.
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.