The PreMarket::createOffer
lacks proper validation for the tokenAddress
parameter. This oversight could potentially lead to the creation of offers with invalid or malicious token addresses, posing risks to the system's integrity and user funds.
The PreMarket::createOffer
function is designed to allow users to create a new offer in the marketplace. The function takes several parameters encapsulated in the CreateOfferParams
struct, one of which is tokenAddress
. However, the function does not perform any validation to ensure that the provided tokenAddress
is neither a zero address (address(0)
) nor a valid token contract address.
The tokenAddress
is directly used to transfer collateral without any prior validation. This lack of validation introduces several risks:
Zero Address Exploit: An attacker could pass address(0)
as the tokenAddress
, which would lead to the system attempting to interact with the zero address. This could result in unexpected behavior or system failure.
Invalid Contract Address: An attacker could provide an address that does not point to a valid ERC20 token contract. This could cause the transaction to fail or even lead to loss of funds if the contract interacts with an incompatible or malicious contract.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L39-L157
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/interfaces/IPerMarkets.sol#L297-L306
The lack of token address validation could lead to:
Creation of offers with non-existent token addresses, leading to failed transactions when interacting with these offers.
Potential for creating offers with malicious token contracts, which could be used for phishing attacks or other exploits.
Inconsistency in the system if invalid token addresses are allowed, potentially causing issues with token transfers or balance calculations.
Possible financial losses for users interacting with offers that have invalid token addresses.
Manual Review
To address this vulnerability, it is crucial to implement proper validation for the tokenAddress
parameter before it is used within the createOffer
function.
Zero Address Check: Ensure that the tokenAddress
is not the zero address (address(0)
):
add this validation to the check within the function
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.