Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: medium
Invalid

Potential Race Condition with offerId

Summary

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.

Description

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.

Impact

  • 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.

Root Cause

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.

Tools Used

Manual Review

Recommendations

  • 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.

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!