Function 'deployToken' in contract 'TokenFactory' sets the address for token symbol, it does not check whether already exists a token with a certain symbol when deployed a new token.
Medium vulnerability, the overwritten token will remain hidden as the function getTokenAddressFromSymbol will now return the new token.
It could exist a overwritten token whose address would be never obtained as the mentioned function does return the new token's address.
The code should check if the mapping s_tokenToAddress[symbol] is already set, the solution would be:
function deployToken(string memory symbol, bytes memory contractBytecode) public onlyOwner returns (address addr) {
require(s_tokenToAddress[symbol] == address(0), "It already exists a token with this symbol");
assembly {
addr := create(0, add(contractBytecode, 0x20), mload(contractBytecode))
}
s_tokenToAddress[symbol] = addr;
emit TokenDeployed(symbol, addr);
}
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.