Tadle

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

Generating order address using its ID makes the protocol vulnerable to blockchain re-orgs.

Summary

In Tadle, offers are identified through a generated address based on its offer unique identifier, this ID is incremented each time a new offer is created.

PreMarkets.sol#L39-L157

function createOffer(CreateOfferParams calldata params) external payable {
...
address makerAddr = GenerateAddress.generateMakerAddress(offerId);
address offerAddr = GenerateAddress.generateOfferAddress(offerId);
address stockAddr = GenerateAddress.generateStockAddress(offerId);
...
offerId = offerId + 1;
...
}

However, as offer IDs are not based on the offer's data:

GenerateAddress.sol#L16-L18

function generateOfferAddress(uint256 _id) internal pure returns (address) {
return address(uint160(uint256(keccak256(abi.encode(_id, "offer")))));
}

This could cause users to accept the wrong offer in the event a blockchain re-org occurs.

Vulnerability Details

Assume the following transactions occur in separate blocks:

  • Block 1: Alice calls createOffer() to sell 1000 points for 1000 USDC, offer ID is 0

  • Block 2: Bob calls createTaker() to exchange 1000 USDC for Alice's 1000 points, offer ID is 1

  • Block 3: Alice calls createOffer() to sell 10 points for 1000 USDC, offer ID is 2

A blockchain re-org occurs and Block 1 is dropped in place of Block 3:

  • Alice's second offer now has the publication ID 0 instead of 2.

  • Bob's call to createTaker() in Block 2 is applied on top of the re-orged blockchain:

This causes Bob to accept a different offer than he intended to, since the second transaction submitted by Alice will have the same order address as the first transaction that was dropped.

Impact

Given that Tadle will be deployed on Ethereum and other EVM compatible chains, which may have experienced large re-orgs in the past such as Polygon, the likelihood of the scenario described above occuring due to a blockchain re-org is not low since it can lead to loss of funds.

Tools Used

Manual Review

Recommendations

Consider identifying offers with a method that is dependent on its contents and ID.

Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

[invalid] finding-PreMarkets-createTaker-reorg

Invalid, the taker should be creating a taker offer for an already existing maker offer that has been finalized, i.e. createOffer has been successfully executed before reorg occurs, so this is a non-issue

Support

FAQs

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