The deployToken function in the provided code does not check if a symbol already exists before assigning a new address to it. This allows a malicious/absent-minded owner to replace the address associated with a symbol.
The deployToken function is called to create a new token with a given symbol and bytecode. However, the function does not perform any validation to ensure that the symbol is unique. As a result, a malicious owner can call the deployToken function multiple times with the same symbol and different bytecode, effectively replacing the address associated with the symbol.
Foundry PoC (in test file) :
This vulnerability allows a malicious/absent-minded owner to override the address associated with a token symbol. This can have various consequences, such as:
Changing the behavior of existing contract interacting with the TokenFactory to find contract address.
Confusing users and causing financial losses.
Cannot put again in the mapping the replaced contract.
Manual review
To mitigate this vulnerability, the deployToken function should include a check to ensure that the symbol does not already exist before assigning a new address to it. Example : require(s_tokenToAddress[symbol] == address(0))
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.