Beginner FriendlyFoundryBridge
100 EXP
View results
Submission Details
Severity: low
Valid

Token symbol mismatch in TokenFactory's deploy() function

Summary

The token symbol passed in to TokenFactory's deploy() function is not representative of the actual symbol of the token.

Vulnerability Details

TokenFactory's deploy() function is deploying an arbitrary contract at an address using create. After that it is setting the symbol of the supposed deployed "token" to the address of the deployed contract.

Code
function deployToken(string memory symbol, bytes memory contractBytecode) public onlyOwner returns (address addr) {
assembly {
addr := create(0, add(contractBytecode, 0x20), mload(contractBytecode))
}
s_tokenToAddress[symbol] = addr;
emit TokenDeployed(symbol, addr);
}

Assuming this will be a L1Token, the actual symbol of the token is hardcoded to BBT in it's constructor. Meaning it cannot be altered.

Code
constructor() ERC20("BossBridgeToken", "BBT") {
_mint(msg.sender, INITIAL_SUPPLY * 10 ** decimals());
}

This can be the cause of confusion when checking for the address of the token using the TokenFactory smart contract. The only way to get the address of the token through TokenFactory is getTokenAddressFromSymbol() function, which retrieves the value from a mapping. Meaning that passing in BBT as the symbol of the token may not be representative of the actual symbol stored in the mapping.

Impact

This won't cause any breaking errors in the protocol, but can be the cause of confusion.

Tools Used

Manual Review

Recommendations

Either pass in the same token symbol as the deployed contract, or better to avoid collisions in the map instead of token symbol, pass in something like a unique deployedTokenIdentifier that would be unique to each token and avoid confusion altogether.

Updates

Lead Judging Commences

0xnevi Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

deployToken: non-unique symbol for tokens

Support

FAQs

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