Skip to content
DoS Audit finding Beginner

NFT Token ID contains forbidden character by design which prevents any domain from being issued at all

The domain registration function builds an NFT token ID containing a colon, but the underlying NFT module forbids colons in token IDs, so every registration reverts. This prevents any domain from being claimed, effectively causing a permanent denial of service.

0xluk3 Follow

Originally disclosed on Code4rena

Submitted by 0xluk3

The usernames module allows for registering a domain. This happens in function register_domain. On registration, a NFT is minted to the buyer, with field Token ID in format domain:timestamp. However the : character is forbidden by underlying nft.move module which is also the reason why original unit tests fail.

Due to this, the protocol cannot be used in its current state, because no NFTs can be currently minted, thus, no domains can be claimed. Hence, this is equivalent to a permanent DoS.

Proof of Concept

In register_domain, the name string is being appended .init:timestamp in line 358-360.

Running original unit tests, e.g., initiad move test --log_level trace --path ./usernames-module -f end_to_end. a debug print was added in line 362: std::debug::print(&name);

BUILDING Usernames
Running Move unit tests
[debug] "abc.init:100"
[ FAIL    ] 0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a::usernames::end_to_end

Test failures:

Failures in 0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a::usernames:

┌── end_to_end ──────
│ error[E11001]: test failure
│    ┌─ /home/move/.move/https___github_com_initia-labs_movevm_git_b6320db6def0aa9438abdb0e7f3f5bda711c8081/precompile/modules/initia_stdlib/sources/token/nft.move:94:37
│    │
│ 86 │     fun assert_token_id(token_id: &String) {
│    │         --------------- In this function in 0x1::nft
│    ·
│ 94 │             error::invalid_argument(EINVALID_TOKEN_ID)
│    │                                     ^^^^^^^^^^^^^^^^^ Test was not expected to error, but it aborted with code 65545 originating in the module 0000000000000000000000000000000000000000000000000000000000000001::nft rooted here
│
│
│ stack trace
│ 	nft::create(/home/move/.move/https___github_com_initia-labs_movevm_git_b6320db6def0aa9438abdb0e7f3f5bda711c8081/precompile/modules/initia_stdlib/sources/token/nft.move:112)
│ 	initia_nft::mint_internal(/home/move/.move/https___github_com_initia-labs_movevm_git_b6320db6def0aa9438abdb0e7f3f5bda711c8081/precompile/modules/initia_stdlib/sources/token/initia_nft.move:212-219)
│ 	initia_nft::mint_nft_object(/home/move/.move/https___github_com_initia-labs_movevm_git_b6320db6def0aa9438abdb0e7f3f5bda711c8081/precompile/modules/initia_stdlib/sources/token/initia_nft.move:189-196)
│ 	usernames::register_domain(./sources/name_service.move:365-372)
│ 	usernames::end_to_end(./sources/name_service.move:753)
│
└──────────────────

Tracking back the error call stack:

This function is provided below:

    fun assert_token_id(token_id: &String) {
        let len = string::length(token_id);
        assert!(
            len <= MAX_NFT_TOKEN_ID_LENGTH,
            error::out_of_range(ENFT_TOKEN_ID_TOO_LONG)
        );
        assert!(
            string::index_of(token_id, &string::utf8(b":")) == len,
            error::invalid_argument(EINVALID_TOKEN_ID)
        );
    }

In the second assertion it requires : to be NOT present in the token_id. index_of will be equal to len only if the searched character will not be present in the string.

Since the name is passed as 4th argument to mint_nft_object, which is defined as:

    public fun mint_nft_object(
        creator: &signer,
        collection: String,
        description: String,
        token_id: String,
        uri: String,
        can_burn: bool
    )

Then, using a : by default causes the NFT to be not issued and function reverts.

Using a simple PoC:

#[test(chain = @0x1, source = @usernames, user1 = @0x2, user2 = @0x3, lp_publisher = @0x3)]
fun my_poc_just_register(
    chain: signer,
    source: signer,
    user1: signer,
    user2: signer,
    lp_publisher: signer,
) acquires CoinCapsInit, ModuleStore {
    // Setup environment
    deploy_dex(&chain, &lp_publisher);
    let chain_addr = signer::address_of(&chain);
    let addr1 = signer::address_of(&user1);

    // Give tokens to users for registration
    init_mint_to(chain_addr, &user1, 100);
    init_mint_to(chain_addr, &user2, 100);

    // Initialize the name service with short durations for testing
    initialize(
        &source,
        100,  // price for 3 char
        50,   // price for 4 char
        10,   // default price
        1000, // min duration
        1000, // grace period
        string::utf8(b"https://test.com/"),
        string::utf8(b"https://test.com/"),
    );

    // Set initial block time
    std::block::set_block_info(100, 1000);

    // Step 1: Register all domains
    let domain_name1 = string::utf8(b"abc");
    let domain_name2 = string::utf8(b"def");
    let domain_name3 = string::utf8(b"ghi");

    std::debug::print(&string::utf8(b"\n=== Registering all domains ==="));
    register_domain(&user1, domain_name1, 1000);
    register_domain(&user1, domain_name2, 1000);
    register_domain(&user1, domain_name3, 1000);
}

initiad move test --log_level trace --path ./usernames-module -f my_poc_just_register

Line 359 is changed:

string::append_utf8(&mut name, b"-");//@audit was ":"

Result:

Running Move unit tests
[debug] "
=== Registering all domains ==="
[debug] "abc.init-1000"
[debug] "def.init-1000"
[debug] "ghi.init-1000"
[ PASS    ] 0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a::usernames::my_poc_just_register

Recommended mitigation steps

Change the colon : to other separator.

andrew (Initia) confirmed and commented:

Fixed this in this commit.


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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

The target is the usernames module of Initia Move, a name service that lets a user register a domain. Registration happens in the function register_domain. When a registration succeeds, the module mints an NFT to the buyer, and the NFT's Token ID field is built in the format domain:timestamp.

The problem is that the : character is forbidden by the underlying nft.move module. Because the token ID always contains a colon, the mint always fails, so no domain can ever be claimed. The researcher characterises this as equivalent to a permanent denial of service: the protocol cannot be used in its current state.

Setup

The work was done against the usernames-module of the Code4rena audit repository for Initia Move. The tool used is the Move test runner, invoked through initiad. The relevant stdlib sources are pulled from the Move VM repository at a pinned commit, and the failing assertion lives in nft.move inside the initia_stdlib precompile modules.

No accounts, roles or network access are needed beyond a local Move test environment. The preconditions are simply a checkout of the module and the ability to run its unit tests.

Finding it

In register_domain, the name string is appended .init:timestamp in lines 358-360 of name_service.move. The resulting token ID therefore always contains a colon.

That looked wrong because the original unit tests fail. Running the existing end-to-end test with tracing enabled, and with a debug print added at line 362 (std::debug::print(&name);), shows the constructed name and then an abort:

Bash
initiad move test --log_level trace --path ./usernames-module -f end_to_end
Text
BUILDING Usernames
Running Move unit tests
[debug] "abc.init:100"
[ FAIL    ] [redacted]::usernames::end_to_end

Test failures:

Failures in [redacted]::usernames:

┌── end_to_end ──────
│ error[E11001]: test failure
│    ┌─ /home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/nft.move:94:37
│    │
│ 86 │     fun assert_token_id(token_id: &String) {
│    │         --------------- In this function in 0x1::nft
│    ·
│ 94 │             error::invalid_argument(EINVALID_TOKEN_ID)
│    │                                     ^^^^^^^^^^^^^^^^^ Test was not expected to error, but it aborted with code 65545 originating in the module 0000000000000000000000000000000000000000000000000000000000000001::nft rooted here
│
│
│ stack trace
│ 	nft::create(/home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/nft.move:112)
│ 	initia_nft::mint_internal(/home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/initia_nft.move:212-219)
│ 	initia_nft::mint_nft_object(/home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/initia_nft.move:189-196)
│ 	usernames::register_domain(./sources/name_service.move:365-372)
│ 	usernames::end_to_end(./sources/name_service.move:753)
│
└──────────────────

The debug line shows the name being built as abc.init:100, and the test aborts with code 65545 (EINVALID_TOKEN_ID) originating in 0x1::nft.

Exploitation

Step 1: Trace the failing call stack

The abort is raised inside nft::create, reached from initia_nft::mint_internal, which is reached from initia_nft::mint_nft_object, which is called by usernames::register_domain. Following the stack back gives the chain:

  1. It fails in mint_nft_object in name_service.move (lines 364-371).
  2. Then in initia_nft.move lines 189-196.
  3. Then in the same file, lines 212-219.
  4. Then in nft.move line 112, on the call to assert_token_id(&token_id);.

Step 2: Read the assertion that rejects the token ID

The function at nft.move lines 86-96 is:

Text
    fun assert_token_id(token_id: &String) {
        let len = string::length(token_id);
        assert!(
            len <= MAX_NFT_TOKEN_ID_LENGTH,
            error::out_of_range(ENFT_TOKEN_ID_TOO_LONG)
        );
        assert!(
            string::index_of(token_id, &string::utf8(b":")) == len,
            error::invalid_argument(EINVALID_TOKEN_ID)
        );
    }

The second assertion requires that : is not present in the token_id. index_of returns a value equal to len only when the searched character is absent from the string. If the colon is present, index_of returns its position, the comparison fails, and the function aborts with EINVALID_TOKEN_ID.

Step 3: Confirm the name reaches the token ID

The name is passed as the fourth argument to mint_nft_object, which is defined as:

Text
    public fun mint_nft_object(
        creator: &signer,
        collection: String,
        description: String,
        token_id: String,
        uri: String,
        can_burn: bool
    )

So the colon that register_domain appends by default causes the NFT not to be issued, and the function reverts.

Step 4: Reproduce with a minimal proof of concept

The researcher wrote a test that registers three domains:

Text
#[test(chain = @0x1, source = @usernames, user1 = @0x2, user2 = @0x3, lp_publisher = @0x3)]
fun my_poc_just_register(
    chain: signer,
    source: signer,
    user1: signer,
    user2: signer,
    lp_publisher: signer,
) acquires CoinCapsInit, ModuleStore {
    // Setup environment
    deploy_dex(&chain, &lp_publisher);
    let chain_addr = signer::address_of(&chain);
    let addr1 = signer::address_of(&user1);

    // Give tokens to users for registration
    init_mint_to(chain_addr, &user1, 100);
    init_mint_to(chain_addr, &user2, 100);

    // Initialize the name service with short durations for testing
    initialize(
        &source,
        100,  // price for 3 char
        50,   // price for 4 char
        10,   // default price
        1000, // min duration
        1000, // grace period
        string::utf8(b"https://test.com/"),
        string::utf8(b"https://test.com/"),
    );

    // Set initial block time
    std::block::set_block_info(100, 1000);

    // Step 1: Register all domains
    let domain_name1 = string::utf8(b"abc");
    let domain_name2 = string::utf8(b"def");
    let domain_name3 = string::utf8(b"ghi");

    std::debug::print(&string::utf8(b"\n=== Registering all domains ==="));
    register_domain(&user1, domain_name1, 1000);
    register_domain(&user1, domain_name2, 1000);
    register_domain(&user1, domain_name3, 1000);
}

The test deploys the DEX, funds two users, initialises the name service with test prices and durations, sets the block info, and then calls register_domain three times for abc, def and ghi. It is run with:

Bash
initiad move test --log_level trace --path ./usernames-module -f my_poc_just_register

Step 5: Show the fix by changing the separator

Line 359 is changed to use a hyphen instead of a colon:

Text
string::append_utf8(&mut name, b"-");//@audit was ":"

With that change, the same test passes and the debug output shows the three token IDs built with the hyphen:

Text
Running Move unit tests
[debug] "
=== Registering all domains ==="
[debug] "abc.init-1000"
[debug] "def.init-1000"
[debug] "ghi.init-1000"
[ PASS    ] [redacted]::usernames::my_poc_just_register

Root cause

The usernames module builds the NFT token ID as domain:timestamp, but the underlying nft.move module rejects any token ID containing a colon. The usernames module builds the token ID with a colon, which nft.move rejects. The failure is deterministic: every registration produces a token ID with a colon, so every mint aborts and every registration reverts.

The original unit tests fail for this reason.

Impact

No NFTs can be minted, so no domains can be claimed. The researcher describes this as equivalent to a permanent denial of service: the protocol cannot be used in its current state.

Fix

The recommended mitigation is to change the colon : to another separator. Changing line 359 to a hyphen makes the test pass. andrew (Initia) confirmed the issue and commented that it was fixed in a commit.

Variants to test

  1. Check other modules that construct token IDs or object IDs from user input plus a separator, and compare the constructed format against the NFT module's assert_token_id rules. A positive result is a mint that aborts with EINVALID_TOKEN_ID.
  2. Look for other reserved or forbidden characters enforced by shared stdlib assertions (length limits, character restrictions) and check whether callers validate against them before calling into the stdlib. A positive result is a caller that can produce an input the stdlib rejects.
  3. Run the project's own unit tests with tracing enabled and a debug print of the constructed identifier. A positive result is a test that fails on an assertion in a dependency module rather than in the module under test.

Hunting notes

This kind of bug tends to hide at the boundary between an application module and a shared library that enforces format rules on identifiers. During recon, the signals are failing or skipped unit tests, identifiers assembled by string concatenation with a separator, and calls into mint or create functions whose arguments are built from user input without validation.

The report traces the abort from register_domain to the assertion in nft.move, reproduces it with a test that registers three domains, and shows that changing the separator makes the same test pass. The report shows the failure occurs and that changing the separator makes the test pass.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

Initia Move is a blockchain project, and one of its pieces is a name service. A name service works like the phone book of the internet: instead of remembering a long, hard-to-read address, you register a short, friendly name and the system points it at the right place. In this case, users can register a domain name (think of something like abc) through a function called register_domain.

When a registration succeeds, the system gives the buyer a digital certificate of ownership. That certificate is an NFT. NFT stands for non-fungible token: a unique digital item recorded on a blockchain, which cannot be copied or swapped one-for-one like money. You can think of it as a numbered receipt that proves you own something specific.

Every NFT needs an identifier, a bit like a serial number. In this project, the identifier is built by gluing together the domain name, a colon character (:), and a timestamp. So registering abc at time 100 produces the identifier abc.init:100.

The problem is that the underlying NFT module, the shared piece of code that actually creates NFTs, refuses any identifier that contains a colon. Because the name service always puts a colon in, every attempt to create the NFT fails, and because the NFT is part of the registration, the whole registration fails too. Nobody can claim any domain at all. The researcher calls this a permanent denial of service: denial of service means making a service unusable for legitimate users, and permanent means there is no way around it from the outside.

The setup

This work was done against the usernames-module in the Code4rena audit repository for Initia Move. Code4rena is a platform where security researchers review code before or after it goes live, and an audit repository is the copy of the code that reviewers are given.

The tool used is the Move test runner, started through a command called initiad. A test runner is a program that runs small, automated checks written by the developers, so you can see whether the code behaves as expected without deploying it to a live network. Move is the programming language used here, and a unit test is one of those small automated checks.

The shared library code (the standard library, or stdlib) is pulled from the Move VM repository at a fixed commit. A commit is a saved snapshot of a code repository, and pinning to one means everyone looks at exactly the same version. The check that rejects the identifier lives in a file called nft.move, inside the initia_stdlib precompile modules. A precompile module is code that is built into the system rather than written by the application developer.

No accounts, roles or network access are needed beyond a local Move test environment. In plain terms: you only need a copy of the code on your own computer and the ability to run its tests. Nothing has to be attacked over the internet.

Finding it

In register_domain, the name string is appended .init:timestamp in lines 358 to 360 of name_service.move. Appending means adding text to the end of an existing piece of text. The result is that the identifier always contains a colon.

That looked wrong because the project's own existing tests fail. This is an important signal: if the developers' own checks do not pass, something in the code contradicts itself. To see what was happening, the researcher ran the existing end-to-end test with tracing turned on. Tracing means the program prints extra detail about what it is doing as it runs. A debug print was also added at line 362, std::debug::print(&name);, which simply prints the constructed name to the output so a human can read it. An end-to-end test is one that exercises a whole flow from start to finish, rather than a single small function.

The command used was:

Bash
initiad move test --log_level trace --path ./usernames-module -f end_to_end

Line by line: initiad is the tool being run; move test tells it to run Move tests; --log_level trace asks for the most detailed level of logging; --path ./usernames-module points at the folder containing the module; and -f end_to_end filters the run to the test named end_to_end.

The output was:

Text
BUILDING Usernames
Running Move unit tests
[debug] "abc.init:100"
[ FAIL    ] [redacted]::usernames::end_to_end

Test failures:

Failures in [redacted]::usernames:

┌── end_to_end ──────
│ error[E11001]: test failure
│    ┌─ /home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/nft.move:94:37
│    │
│ 86 │     fun assert_token_id(token_id: &String) {
│    │         --------------- In this function in 0x1::nft
│    ·
│ 94 │             error::invalid_argument(EINVALID_TOKEN_ID)
│    │                                     ^^^^^^^^^^^^^^^^^ Test was not expected to error, but it aborted with code 65545 originating in the module 0000000000000000000000000000000000000000000000000000000000000001::nft rooted here
│
│
│ stack trace
│ 	nft::create(/home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/nft.move:112)
│ 	initia_nft::mint_internal(/home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/initia_nft.move:212-219)
│ 	initia_nft::mint_nft_object(/home/move/.move/https___github_com_initia-[redacted]/precompile/modules/initia_stdlib/sources/token/initia_nft.move:189-196)
│ 	usernames::register_domain(./sources/name_service.move:365-372)
│ 	usernames::end_to_end(./sources/name_service.move:753)
│
└──────────────────

Reading this from the top: the tool builds the Usernames module, then runs the unit tests. The debug line prints abc.init:100, which is the identifier the code constructed. The test is then marked FAIL. The error block says the test was not expected to error, but it aborted with code 65545, and the abort came from the module 0x1::nft. An abort is how a Move program stops itself when a check fails; the number is a code that identifies which check failed.

The stack trace at the bottom is the list of function calls that led to the failure, from the outermost call to the innermost. It reads from the bottom up: the test usernames::end_to_end called usernames::register_domain, which called initia_nft::mint_nft_object, which called initia_nft::mint_internal, which called nft::create, where the abort happened. A stack trace is like the list of people who handed a message along until someone dropped it: it tells you the chain of handoffs.

Exploitation

Step 1: Trace the failing call stack

The abort is raised inside nft::create, reached from initia_nft::mint_internal, which is reached from initia_nft::mint_nft_object, which is called by usernames::register_domain. Following the stack back gives the chain:

  1. It fails in mint_nft_object in name_service.move (lines 364 to 371).
  2. Then in initia_nft.move lines 189 to 196.
  3. Then in the same file, lines 212 to 219.
  4. Then in nft.move line 112, on the call to assert_token_id(&token_id);.

Why do this? Because knowing exactly where the failure happens tells you whether the bug is in the application code or in the shared library, and which of the two is enforcing a rule the other one breaks. Here the application builds an identifier the library will not accept.

Step 2: Read the assertion that rejects the token ID

The function at nft.move lines 86 to 96 is:

Text
    fun assert_token_id(token_id: &String) {
        let len = string::length(token_id);
        assert!(
            len <= MAX_NFT_TOKEN_ID_LENGTH,
            error::out_of_range(ENFT_TOKEN_ID_TOO_LONG)
        );
        assert!(
            string::index_of(token_id, &string::utf8(b":")) == len,
            error::invalid_argument(EINVALID_TOKEN_ID)
        );
    }

Line by line. fun assert_token_id(token_id: &String) defines a function named assert_token_id that takes one input, token_id, which is a string (a piece of text). The & means it borrows the text rather than taking ownership of it, a detail of the Move language.

let len = string::length(token_id); stores the length of the text in a variable called len.

The first assert! checks that len <= MAX_NFT_TOKEN_ID_LENGTH, meaning the identifier is not longer than the maximum allowed. If it is too long, the program aborts with the error ENFT_TOKEN_ID_TOO_LONG. An assertion is a statement of the form "this must be true, otherwise stop".

The second assert! is the interesting one. It checks that string::index_of(token_id, &string::utf8(b":")) == len. index_of searches for a piece of text inside another and returns its position, counting from zero. If the searched text is not found, it returns the length of the whole string instead. So the check says: the position of a colon must equal the length of the string, which can only be true when there is no colon at all. If a colon is present, index_of returns its position, the comparison fails, and the function aborts with EINVALID_TOKEN_ID.

In everyday terms: the library is saying "a serial number must not contain a colon", and it enforces that by looking for a colon and stopping the program if it finds one.

Step 3: Confirm the name reaches the token ID

The name is passed as the fourth argument to mint_nft_object, which is defined as:

Text
    public fun mint_nft_object(
        creator: &signer,
        collection: String,
        description: String,
        token_id: String,
        uri: String,
        can_burn: bool
    )

This is the signature of the function: the list of inputs it accepts. public means other modules are allowed to call it. creator: &signer is the account creating the NFT; a signer is a special value in Move that proves an account authorised an action, similar to a signed permission slip. collection, description, token_id and uri are all strings: the collection name, a description, the identifier and a link to associated content. can_burn: bool is a true or false flag saying whether the NFT can be destroyed later.

The fourth argument is token_id, which is exactly where the constructed name goes. So the colon that register_domain appends by default causes the NFT not to be issued, and the function reverts. Reverting means undoing everything the function did, as if it had never been called, so the registration does not happen either.

Step 4: Reproduce with a minimal proof of concept

A proof of concept is a small, self-contained demonstration that a bug is real. The researcher wrote a test that registers three domains:

Text
#[test(chain = @0x1, source = @usernames, user1 = @0x2, user2 = @0x3, lp_publisher = @0x3)]
fun my_poc_just_register(
    chain: signer,
    source: signer,
    user1: signer,
    user2: signer,
    lp_publisher: signer,
) acquires CoinCapsInit, ModuleStore {
    // Setup environment
    deploy_dex(&chain, &lp_publisher);
    let chain_addr = signer::address_of(&chain);
    let addr1 = signer::address_of(&user1);

    // Give tokens to users for registration
    init_mint_to(chain_addr, &user1, 100);
    init_mint_to(chain_addr, &user2, 100);

    // Initialize the name service with short durations for testing
    initialize(
        &source,
        100,  // price for 3 char
        50,   // price for 4 char
        10,   // default price
        1000, // min duration
        1000, // grace period
        string::utf8(b"https://test.com/"),
        string::utf8(b"https://test.com/"),
    );

    // Set initial block time
    std::block::set_block_info(100, 1000);

    // Step 1: Register all domains
    let domain_name1 = string::utf8(b"abc");
    let domain_name2 = string::utf8(b"def");
    let domain_name3 = string::utf8(b"ghi");

    std::debug::print(&string::utf8(b"\n=== Registering all domains ==="));
    register_domain(&user1, domain_name1, 1000);
    register_domain(&user1, domain_name2, 1000);
    register_domain(&user1, domain_name3, 1000);
}

Line by line. The #[test(...)] line marks the function as a test and sets up named accounts for it: chain at address 0x1, source as the usernames module, user1 at 0x2, user2 at 0x3, and lp_publisher at 0x3. An address here is like an account number on the blockchain.

fun my_poc_just_register(...) declares the test function and lists the signers it receives, one per account set up above. acquires CoinCapsInit, ModuleStore is a Move-specific declaration saying the function will access two pieces of stored data with those names; Move requires you to declare this explicitly.

deploy_dex(&chain, &lp_publisher); sets up a decentralised exchange, a piece of the environment the test depends on. let chain_addr = signer::address_of(&chain); gets the address of the chain account and stores it. let addr1 = signer::address_of(&user1); does the same for user1.

init_mint_to(chain_addr, &user1, 100); and the same call for user2 give each user 100 tokens, so they can pay registration fees. A token here is a unit of the blockchain's currency, not a login token.

The initialize(...) call sets up the name service with test values: 100 as the price for a three-character name, 50 for a four-character name, 10 as the default price, 1000 as the minimum duration, 1000 as the grace period (extra time allowed after expiry), and two URLs as strings.

std::block::set_block_info(100, 1000); sets the simulated block time. A blockchain groups transactions into blocks, and each block has a timestamp; setting it makes the test deterministic, so the timestamp in the identifier is predictable.

Then three domain names are created as strings: abc, def and ghi. A debug print announces the registration phase. Finally register_domain is called three times for user1, each with a duration of 1000.

The test is run with:

Bash
initiad move test --log_level trace --path ./usernames-module -f my_poc_just_register

This is the same command as before, except the filter -f now selects the new test, my_poc_just_register, instead of end_to_end. The test is run with the filter selecting my_poc_just_register.

Step 5: Show the fix by changing the separator

Line 359 is changed to use a hyphen instead of a colon:

Text
string::append_utf8(&mut name, b"-");//@audit was ":"

string::append_utf8 adds text to the end of a string, &mut name means it modifies the variable name in place, and b"-" is the hyphen character. The comment //@audit was ":" records that the original character was a colon. This is a one-character change, which is worth noting: the bug is not deep in the logic, it is a single wrong character.

With that change, the same test passes and the debug output shows the three token IDs built with the hyphen:

Text
Running Move unit tests
[debug] "
=== Registering all domains ==="
[debug] "abc.init-1000"
[debug] "def.init-1000"
[debug] "ghi.init-1000"
[ PASS    ] [redacted]::usernames::my_poc_just_register

The three debug lines show the identifiers now contain a hyphen, and the test is marked PASS. The debug lines show the identifiers now contain a hyphen, and the test is marked PASS.

Root cause

The usernames module builds the NFT token ID as domain:timestamp, but the underlying nft.move module rejects any token ID containing a colon. The usernames module builds the token ID with a colon, which nft.move rejects. To validate means to check an input against the rules before using it. The failure is deterministic: every registration produces a token ID with a colon, so every mint aborts and every registration reverts. Deterministic means it happens every single time, with no randomness or special conditions.

The original unit tests fail for this reason.

Impact

No NFTs can be minted, so no domains can be claimed. The researcher describes this as equivalent to a permanent denial of service: the protocol cannot be used in its current state.

Fix

The recommended mitigation is to change the colon : to another separator. A separator is the character placed between two pieces of text to keep them apart. Changing line 359 to a hyphen makes the test pass. andrew (Initia) confirmed the issue and commented that it was fixed in a commit.

Variants to test

These are ideas for finding similar bugs elsewhere, useful if you want to look for the same pattern in other code.

  1. Check other modules that construct token IDs or object IDs from user input plus a separator, and compare the constructed format against the NFT module's assert_token_id rules. A positive result is a mint that aborts with EINVALID_TOKEN_ID.
  2. Look for other reserved or forbidden characters enforced by shared stdlib assertions (length limits, character restrictions) and check whether callers validate against them before calling into the stdlib. A positive result is a caller that can produce an input the stdlib rejects.
  3. Run the project's own unit tests with tracing enabled and a debug print of the constructed identifier. A positive result is a test that fails on an assertion in a dependency module rather than in the module under test.

Hunting notes

This kind of bug tends to hide at the boundary between an application module and a shared library that enforces format rules on identifiers. A boundary here means the point where one piece of code hands data to another. During recon (the early phase of exploring a codebase to decide where to look), the signals are failing or skipped unit tests, identifiers assembled by string concatenation with a separator, and calls into mint or create functions whose arguments are built from user input without validation. String concatenation is simply joining pieces of text end to end.

The report traces the abort from register_domain to the assertion in nft.move, reproduces it with a test that registers three domains, and shows that changing the separator makes the same test pass. The report shows the failure occurs and that changing the separator makes the test pass.

Glossary

  • NFT (non-fungible token): a unique digital item recorded on a blockchain, used here as proof of ownership of a domain.
  • Token ID: the unique identifier given to an NFT, like a serial number.
  • Domain: a short, friendly name registered in a name service, such as abc.
  • Name service: a system that maps friendly names to addresses, like a phone book.
  • Module: a self-contained unit of code in Move, similar to a file or library.
  • Function: a named block of code that performs a task and can be called by other code.
  • register_domain: the function that handles registering a domain and minting the NFT.
  • Mint: to create a new NFT on the blockchain.
  • Revert: to undo everything a function did and stop, as if it had never run.
  • Abort: how a Move program stops itself when a check fails, identified by a numeric code.
  • Assertion: a statement that something must be true, otherwise the program stops.
  • String: a piece of text.
  • Append: to add text to the end of existing text.
  • Concatenation: joining pieces of text end to end.
  • Separator: a character placed between two pieces of text to keep them apart.
  • Colon (:): the character the name service used as a separator and the NFT module forbids.
  • Hyphen (-): the character used in the demonstrated fix.
  • Timestamp: a recorded point in time, here appended to the domain name.
  • index_of: a function that returns the position of a piece of text inside another, or the total length if it is not found.
  • assert_token_id: the NFT module's function that checks whether a token ID is acceptable.
  • EINVALID_TOKEN_ID: the error code raised when a token ID breaks the rules.
  • mint_nft_object: the function that creates an NFT, taking the token ID as its fourth argument.
  • Signer: a Move value that proves an account authorised an action, like a signed permission slip.
  • Address: an account number on the blockchain, written like 0x1.
  • Block: a group of transactions recorded together on a blockchain, with a timestamp.
  • Block time: the simulated time used during a test so results are predictable.
  • Unit test: a small automated check that verifies a piece of code behaves as expected.
  • End-to-end test: a test that exercises a whole flow from start to finish.
  • Test runner: a program that runs automated tests and reports pass or fail.
  • initiad: the command-line tool used to run the Move tests here.
  • Move: the programming language used for this project.
  • Move VM: the virtual machine that executes Move code; its repository holds the shared library.
  • Standard library (stdlib): shared code that many modules rely on.
  • Precompile module: code built into the system rather than written by the application developer.
  • Commit: a saved snapshot of a code repository.
  • Repository: a storage location for code, with its history.
  • Code4rena: a platform where security researchers review code and submit findings.
  • Audit: a structured review of code for security problems.
  • Proof of concept (PoC): a small demonstration that a bug is real.
  • Stack trace: the list of function calls that led to a failure, from outermost to innermost.
  • Debug print: a line of code that prints a value to the output so a human can inspect it.
  • Tracing / log level: extra detail printed by a program while it runs, controlled by a setting.
  • Validation: checking an input against rules before using it.
  • Deterministic: happening the same way every time, with no randomness.
  • Denial of service (DoS): making a service unusable for legitimate users.
  • Permanent denial of service: a denial of service with no way around it from the outside.
  • Impact: the real-world consequence of a bug.
  • Root cause: the underlying reason a bug exists.
  • Mitigation / fix: a change that removes or reduces the problem.
  • Recon: the early phase of exploring a codebase to decide where to look.
  • Boundary: the point where one piece of code hands data to another.
  • Decentralised exchange (DEX): a system for trading tokens without a central operator, set up here as part of the test environment.

More by 0xluk3

View all

1 more disclosed report, best first.

More from Initia Move

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.