Closed c4-bot-9 closed 9 months ago
raymondfam marked the issue as insufficient quality report
raymondfam marked the issue as duplicate of #339
alcueca marked the issue as not a duplicate
alcueca marked the issue as duplicate of #339
alcueca marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2024-01-curves/blob/516aedb7b9a8d341d0d2666c23780d2bd8a9a600/contracts/Curves.sol#L465
Vulnerability details
Impact
The mint() function is used to deploy an ERC20 token for token subjects. This function can only be called by the token subject themselves. But another way to deploy an ERC20 token without the token subject's permission is through the withdraw() function. Passing 0 as the value for parameter
amount
allows anyone to create an ERC20 token with the default name and symbol (with the counter appended to it).For the case where a regular user or famous individual (influencer or celebrity) wants an ERC20 token with a custom name and symbol, they can do so by calling setNameAndSymbol() and calling mint() thereafter. The issue here is that an attacker can frontrun the setNameAndSymbol() transaction with a zero amount withdraw() call. This would make the user devoid of using a custom name and symbol. This would have a negative social impact on the Curves platform if the individual is famous, which would cause them to migrate away from the platform. This case is also true for a regular user except that the user won't be having many followers to influence.
Additionally, even if a token subject is not using the Curves platform currently (i.e. has not initiated a curve) but will in the future, the ERC20 token can still be deployed by the attacker early on. When the token subject onboards the platform, the individual realises they cannot have a custom name and symbol. It makes sense for this kind of attack to be targeted on famous individuals or organizations with known public addresses.
This issue has been marked as Medium-severity since:
Proof of Concept
Here is the whole process:
First, let's see how much gas fees would it take for the attacker to target this attack on all users.
Let's assume the active users on the Curves protocol are 500 (based on current DefiLlama friend.tech data). Out of those, 100 use the custom name and symbol feature.
Gas fee on Form network currently = 1.24 gwei (see here)
From the tests, we can see a withdraw() function call costs 153428 gas.
Fees = 153428 (gas) 1.24 (gwei) 100 (users) = 19025072 gwei = 0.019025072 ETH (use Ethereum Unit Converter)
Therefore, for 100 users who use the custom token name and symbol feature, the fees required would be 0.019025072 ETH (currently only 50$). Note that this is only the fees required for one attacker. There will be more users who could deploy ERC20 tokens without requiring the attacker's involvement.
Coded POC
This POC demonstrates that a token subject alice gets frontrun by bob (a regular user or attacker), which makes alice devoid of using a custom name and symbol for her ERC20 token.
Here is how to run this POC:
test
folder.forge test --match-test testCustomNameAndSymbolAttack
Attack confirmation
Tools Used
Manual Review
Recommended Mitigation Steps
Disable 0 value withdraw() calls, which allows this attack to occur. For this, check if amount parameter passed is 0 or not.
Assessed type
DoS