Vault721.tokenURI does not comply with ERC721 - Metadata specification
The Vault721 contract's tokenURI function does not revert for non-existent token IDs, violating the ERC721 metadata specification. An attacker could call tokenURI with an invalid ID and receive a URI instead of an error, potentially causing confusion or integration issues.
Submitted by Haipls, also found by kutugu and twcctop
According to the standard, the tokenURI method must be reverted if a non-existent tokenId is passed. In the Vault721 contract, this point was ignored. What leads to a [violation of the EIP721 spec](https://eips.ethereum.org/EIPS/eip-721#:~:text=function%20tokenURI(uint256%20_tokenId%29%20external%20view%20returns%20(string%29%3B).
Proof of Concept
File: contracts/proxies/Vault721.sol
/**
* @dev generate URI with updated vault information
*/
function tokenURI(uint256 _safeId) public view override returns (string memory uri) {
// @audit should throw if safeId does not exist according to the ERC721-Metadata specification
uri = nftRenderer.render(_safeId);
}
The responsibility for checking whether a token exists may be put on the nftRenderer depending on the implementation, and may also be missing, changed or added in the future. But the underlying Vault721 contract that is supposed to comply with the standard does not follow the specification.
Similar problem with violation of ERC721 specification: https://github.com/code-423n4/2023-04-caviar-findings/issues/44
Tools Used
https://eips.ethereum.org/EIPS/eip-721#specification
Recommended Mitigation Steps
Add a token existence check at the Vault721 level, example:
/**
* @dev generate URI with updated vault information
*/
function tokenURI(uint256 _safeId) public view override returns (string memory uri) {
+++ _requireMinted(_safeId);
uri = nftRenderer.render(_safeId);
}
Although the impact is extremely limited, the function does violate the ERC-721 spec as shown [here](https://eips.ethereum.org/EIPS/eip-721#:~:text=function%20tokenURI(uint256%20_tokenId%29%20external%20view%20returns%20(string%29%3B). As such, I agree with Medium Severity.
pi0neerpat (OpenDollar) commented:
This is a valid finding and recommendation is accurate.
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 function lacks a check to ensure the token ID has been minted before returning a URI.
Impact
The impact is extremely limited, but the function violates the ERC-721 specification, which could lead to integration issues with other contracts or platforms that expect standard-compliant behaviour.
What the attacker needed
None
The fix
Add a token existence check (e.g., using _requireMinted) at the Vault721 level before calling nftRenderer.render.
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.
ERC721 is a standard for non-fungible tokens (NFTs) on Ethereum. The standard says that if you ask for the token URI (a link to metadata) of a token that doesn't exist, the contract should return an error. Here, the contract returns a URI anyway, which breaks the standard and could confuse other contracts or apps that rely on this behaviour.
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.