The protocol uses virtual addresses as keys to store allmost all of the data. Those addresses are generated via the GenerateAddress lib. However collision of addresses is possible due to the nature of the custom address generation algorithm. This might lead to DOS of some of PreMarket functions.
PreMarkets generates virtual addresses based on the offerId value.
The specific algorithm for generating those addreses is the following
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/libraries/GenerateAddress.sol#L17
Consider this scenario:
A and B are 2 different _id args passed to generateOfferAddress()
The result A of uint256(keccak256(abi.encode(_id, "offer")))) is : 777
The result B of uint256(keccak256(abi.encode(_id, "offer")))) is : uint160.max + 778
When the result B(uint160.max + 778) is casted to uint160(next step of the algo) it overflows and the value becomes: 777
Now the 2 different inputs, produce the same address(numerical value)-> Hash collision
DOS of PreMarkets.createOffer() , listOffer(), createTaker(). This is due to the validation in those functions. They revert if the address exists
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L67-L81
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L206-L209
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L365-L367
Manual review
Consider using uint256 as ids for the data structures, instead of addresses.
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.