Insufficient validation of tokens when created in PlayCollateralTokenFactory::createCollateralToken
The PlayCollateralTokenFactory contract's createCollateralToken function does not check whether a token with the same name and symbol already exists, so anyone can create duplicate tokens. An attacker could deploy tokens that look identical to a legitimate one, potentially confusing users and enabling scams.
- Disclosed after under an hour
#39539 [SC-Insight] Insufficient validation of tokens when created in `PlayCollateralTokenFactory::c
Submitted on Feb 1st 2025 at 01:29:46 UTC by @Bx4 for Audit Comp | Butter
- Report ID: #39539
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-butter-cfm-v1-playmoney
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
In PlayCollateralTokenFactory when creating a new token via createCollateralToken the token details are not validated this makes it easy to create duplicate tokens.
Vulnerability Details
in the createCollateralToken we can see that tokens are created with specified token names, symbols and other params as seen below
function createCollateralToken(string memory name, string memory symbol, uint256 initialSupply, address owner)
external
returns (address)
{
PlayCollateralToken newToken = new PlayCollateralToken(name, symbol, initialSupply, CONDITIONAL_TOKENS, owner);
emit PlayCollateralTokenCreated(address(newToken));
return address(newToken);
}
However this function does not validate the tokens being created and as a result another user can create a duplicate token of a pre-existing token.
Impact Details
Attackers can create duplicate of token to lure users to trust duplicate token instead of original token. This makes the contract fail to return a unique list of tokens like it should.
FOR INSTANCE: An attacker could create multiple tokens with the same name and symbol using the createCollateralToken function. This lack of validation could lead to confusion among users, who might mistake one token for another, potentially leading to financial loss or scams.
References
Similar vulnerabilities have been disclosed by notable firms
one example is : https://solodit.cyfrin.io/issues/insufficient-validation-of-token-name-and-symbol-in-liquidityfreelaunchfactory-zokyo-none-zap-markdown
Proof of Concept
Proof of Concept
Add this test to your foundry test environment and run. You will see that the assertion statements never fail which inidicates duplicate tokens can be created with the same name and symbol.
function testDuplicateTokensCreate() public {
address owner = address(this);
address owner1 = address(0xabc);
uint256 supply = 120e18;
address tokenAddr = factory.createCollateralToken("KWAMEtoken","KTN",supply, owner);
address tokenAddr1 = factory.createCollateralToken("KWAMEtoken","KTN",supply, owner1);
address tokenAddr2 = factory.createCollateralToken("KWAMEtoken","KTN",supply, owner);
PlayCollateralToken token1 = PlayCollateralToken(tokenAddr);
PlayCollateralToken token2 = PlayCollateralToken(tokenAddr1);
PlayCollateralToken token3 = PlayCollateralToken(tokenAddr2);
token1.transfer(address(0xabd),10e18);
console2.log(token2.balanceOf(address(0xabd)));
assertEq(token1.name(),"KWAMEtoken");
assertEq(token2.name(), "KWAMEtoken");
assertEq(token3.name(),"KWAMEtoken");
assertEq(token2.symbol(),"KTN");
assertEq(token1.symbol(),"KTN");
assertEq(token3.symbol(),"KTN");
}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the factory lacks a registry or uniqueness check on token name and symbol before deploying a new token.
Impact
Attackers could create duplicate tokens to mislead users into trusting a fake token, and the contract fails to return a unique list of tokens as intended.
What the attacker needed
Ability to call createCollateralToken
The fix
The factory should be fixed to reject token creation when the name or symbol already exists, for example by keeping a registry of used names and symbols.
How it was found
- Call createCollateralToken with a chosen name, symbol, supply and owner.
- Call it again with the same name and symbol but a different owner.
- Call it a third time with the same name and symbol and the original owner.
- Observe that all three calls succeed and the tokens share the same name and symbol.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A factory contract is a program that creates other contracts. Here it creates tokens, which are digital assets with a name and a ticker symbol. Because the factory never checks if a name or symbol is already taken, anyone can make a copycat token that looks the same as a real one, which could trick people.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.