The TokenDivider
contract uses abi.encodePacked()
with dynamic strings to generate the names and symbols of the fractioned ERC20 tokens. This approach can potentially lead to hash collisions, although in the current implementation, the risk is mitigated by the structure of the generated names.
Code Location:
Severity: Medium
The use of abi.encodePacked()
with dynamic strings can theoretically lead to hash collisions. In the current context, this could allow an attacker to create NFTs with specially designed names to generate ERC20 tokens with identical names, which could create confusion for users.
For example:
NFT1 with name="A" and symbol="BC"
NFT2 with name="" and symbol="ABC"
Could theoretically generate tokens with similar names after concatenation.
A test was created to demonstrate the potential issue:
Manual code analysis
Foundry tests
Aderyn (static analysis tool)
Replace abi.encodePacked()
with abi.encode()
to avoid potential collisions:
Alternatively, add a unique separator between the concatenated strings:
Or use bytes.concat()
which is more suitable for string concatenation:
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.