Skip to content
Smart contracts Audit finding Beginner

Transmuter tokenURI() is not EIP-721 compliance

The Transmuter contract's tokenURI() function returns a non-empty SVG string for token IDs that do not exist, instead of reverting as the EIP-721 standard requires. This could confuse clients and applications that rely on the revert to tell whether a token is valid.

lirezarazavi Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

56730 sc insight transmuter tokenuri is not eip 721 compliance

Submitted on Oct 19th 2025 at 23:38:25 UTC by @lirezarazavi for Audit Comp | Alchemix V3

Description

Brief/Intro

tokenURI() is violating EIP-721 by not reverting for non-existent token id's.

Vulnerability Details

According to the EIP-721 specification, the function should throw an error if the provided _tokenId does not correspond to a valid NFT. However, the current implementation returns a non-empty SVG/String for non-existent tokenId values.

Impact Details

  • Violation of EIP-721
  • This behavior can lead to confusion and makes it difficult for clients and applications to determine the validity of a token.

References

Proof of Concept

Proof of Concept

  1. Add (copy and paste) the following function to src/test/Transmuter.t.sol:
Solidity
function testTokenURI_PoC() public {
        vm.prank(address(0xbeef));

        // No NFT is minted and thus totalSupply is Zero
        uint256 totalNFTMinted = transmuter.totalSupply();
        assertEq(totalNFTMinted, 0);

        // tokenURI doesn't revert for non-existent tokenId's 
        bytes memory uri_str;

        uri_str = bytes(transmuter.tokenURI(1)); // tokenId = 1
        console.log(string(uri_str)); 
        assertNotEq(uri_str.length, 0);   // tokenURI returned a SVG/string instead of reverting

        uri_str = bytes(transmuter.tokenURI(2)); 
        console.log(string(uri_str)); 
        assertNotEq(uri_str.length, 0);
    }
  1. Run: forge test --match-test testTokenURI_PoC.

The original report as published on Immunefi, by lirezarazavi. 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 tokenURI() implementation builds and returns a data URI without first checking that the token ID has actually been minted.

Impact

The contract does not follow EIP-721, which could confuse clients and applications trying to determine whether a token is valid; no loss of funds is claimed.

What the attacker needed

None

The fix

tokenURI() should revert when the given token ID does not correspond to a minted NFT.

How it was found

  1. Add the provided test function to the Transmuter test file.
  2. Run the test with forge using the matching test name.
  3. Observe that tokenURI returns a non-empty string for unminted token IDs instead of reverting.

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.

NFT contracts follow a standard called EIP-721, which says a function that returns a token's picture or metadata must raise an error when asked about a token that does not exist. Here the contract instead hands back a picture anyway, so software cannot tell real tokens from fake ones by asking.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More from Alchemix V3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.