Skip to content
Business logic Audit finding Beginner

ERC-721 Enumerable Spec mismatch for index of tokenByIndex() function

The tokenByIndex function rejects index 0 because its bounds check requires the index to be greater than zero, while the ERC-721 Enumerable specification expects indexing to start at 0. This prevents querying the token at index 0 and breaks compatibility with platforms that expect full conformity with the specification.

Larva Labs Meebits

Originally disclosed on Code4rena

Index starts at 0 for token array, but the implementation here requires index to be greater than 0. This will prevent querying of tokens at index 0.

See reference implementation.

This will impact compatibility with NFT platforms that expect full conformity with ERC-721 specification.

Recommend accepting 0 index by changing to require(index >= 0 && index < TOKEN_LIMIT);.

dangerousfood (Meebits) commented:

Beebots indexes by 1 for whatever reason

The original report as published on Code4rena. 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 an off-by-one bounds check that requires the index to be strictly greater than zero instead of allowing zero as the first valid position.

Impact

The first token cannot be retrieved through this function, which could break compatibility with NFT platforms that expect full conformity with the ERC-721 specification.

What the attacker needed

None

The fix

The check should be changed to accept an index of zero as long as it is below the token limit.

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 contract can list its tokens in order, and the first item in that list sits at position 0. This contract's lookup function refuses position 0, so anyone asking for the first token gets an error instead of an answer. That makes the contract behave differently from the standard other platforms rely on.

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 from Larva Labs Meebits

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.