Skip to content
DoS Audit finding Beginner

If a user sets their curve token symbol as the default one plus the next token counter instance it will render the whole default naming functionality obsolete

A user could set a token symbol matching the next default-generated symbol, causing the default naming logic to revert when another user's token tries to receive its automatic name. This blocks the default naming functionality indefinitely, though manual naming still works.

iamandreiski Follow with UbiquitousComputing, dutra and 47 others

Originally disclosed on Code4rena

Submitted by iamandreiski, also found by UbiquitousComputing, dutra, 0x0bserver, m4ttm, peritoflores, cheatc0d3, imare, Tychai0s, FastChecker, Soul22, kodyvim, deepplus, whoismatthewmc1, nonseodion (1, 2), Matue, erebus, ether_sky, Draiakoo, LouisTsai, 0xprinc, aslanbek, Cosine, BugzyVonBuggernaut, KupiaSec, ke1caM, jesjupyter, PENGUN, spacelord47, SpicyMeatball, dimulski, ktg, DanielArmstrong, nmirchev8 (1, 2), KingNFT, Mylifechangefast_eth, SovaSlava, zaevlad, jasonxiale, hals, AlexCzm, 51l3nt, cats, EV_om, ZanyBonzy, ubl4nk, cccz, pkqs90, israeladelaja, jangle, Krace, and haxatron

https://github.com/code-423n4/2024-01-curves/blob/516aedb7b9a8d341d0d2666c23780d2bd8a9a600/contracts/Curves.sol#L338-L362

https://github.com/code-423n4/2024-01-curves/blob/516aedb7b9a8d341d0d2666c23780d2bd8a9a600/contracts/Curves.sol#L47

If a malicious user or just an unbeknownst one decides to name/set their curve token symbol as “CURVE N” “N” can/will be substituted to whatever the next number is in the _curvesTokenCounter it can render the whole default naming functionality in the protocol useless as it will be DoS’d indefinitely.

Proof of Concept

When a user decides to call the buyCurvesTokenWithName without specifying the name/symbol of their token and/or their token hasn’t been deployed and exists without a name/symbol and calls mint(), withdraw() etc. without setting the name/symbol they will be assigned a default one.

The default name/symbol will be assigned using the following lines of code:

  // If the token's symbol is CURVES, append a counter value
        if (keccak256(bytes(symbol)) == keccak256(bytes(DEFAULT_SYMBOL))) {
            _curvesTokenCounter += 1;
            name = string(abi.encodePacked(name, " ", Strings.toString(_curvesTokenCounter)));
            symbol = string(abi.encodePacked(symbol, Strings.toString(_curvesTokenCounter)));
        }

        if (symbolToSubject[symbol] != address(0)) revert InvalidERC20Metadata();

Since two exact symbols can’t coexist in the Curves ecosystem, due to symbol checks (as shown in if the if-clause above) a malicious user can decide to set their token symbol as “CURVES N” -> substituting the N with whatever the next number is in the _curvesTokenCounter.

Example if currently _curvesTokenCounter = 4, they can set their symbol as “CURVES 5” and this will render the whole default naming functionality of the protocol obsolete indefinitely.

Even though setNameAndSymbol() exists (which prevents a complete protocol DoS) and users will be able to manually set their name/symbol since the default functionality won’t work; this still renders the whole default naming functionality useless and inoperable.

Foundry Proof of Concept to show this:

    function testTokenDefaultNaming() public {

        //user1 creates a token without assigning it a name/symbol
        vm.startPrank(user1);
        curves.buyCurvesToken(user1, 1);
        vm.stopPrank();

        //user2 creates another token with name/symbol as the default ones next in line
        vm.prank(user2);
        curves.buyCurvesTokenWithName(user2, 1, "Curves 1", "CURVES1");

        //This will always revert as default naming functionality won't work anymore
        vm.startPrank(user1);
        vm.expectRevert();
        curves.withdraw(user1, 1);
        vm.stopPrank();
    }

Recommended Mitigation Steps

Forbid users to include CURVES in their symbol by including checks when manually setting name/symbol or creating a token with name/symbol and reserve these keywords only for the default naming functionality or rethink how the architecture can be changed to make including symbols/names by users mandatory.

andresaiello (Curves) confirmed


The original report as published on Code4rena, by iamandreiski. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 default naming scheme uses a predictable counter and does not reserve the generated names, so a user can pre-claim the next default symbol and make the automatic naming revert.

Impact

The default naming functionality is rendered useless and inoperable indefinitely, but a complete protocol denial of service is prevented because users can still set names manually.

What the attacker needed

Ability to create a token; knowledge of the next counter value

The fix

The report recommends forbidding users from including CURVES in their symbol or making manual naming mandatory.

How it was found

  1. User1 creates a token without assigning a name or symbol.
  2. User2 creates a token with the next default name and symbol.
  3. User1 calls withdraw and the transaction reverts because default naming no longer works.

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.

The contract gives tokens without a name an automatic name like 'CURVES1', 'CURVES2' and so on. A user can pick a name that the system is about to hand out next, and because names must be unique, the automatic naming then fails for the next person. The token can still be named by hand, so the whole system does not stop working.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by iamandreiski

View all

5 more disclosed reports, best first.

More from Curves

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.