CertiK reviewed CAPTAIN TSUBASA -RIVALS- (Captain Tsubasa -RIVALS- - Audit) on 9 Mar 2023: 5 findings, 0 critical; 1 marked fixed, 2 acknowledged, 2 open.
Report hosted on skynet.certik.com.
Trustblock does not review code.
Statuses are the security firm’s own, from its report.
| Severity | Open | Acknowledged | Fixed |
|---|---|---|---|
| Critical | 0 | 0 | 0 |
| High | 2 | 0 | 0 |
| Medium | 0 | 0 | 1 |
| Low | 0 | 2 | 0 |
In the contract `NFT.sol`, the function `tokenIdsOfOwner()` is designed to return the chosen NFT ids by providing the start index and the amount/size of tokens that wants to query. However, there is a corner case that might lead to a potential revert on the function call with specific `startIdx` and `size`. The issue lies in the `else` branch, where in the case that `startIdx + size - 1 == length`, the `last` parameter will be updated to `startIdx + size`, which equals `length + 1`. Therefore, the calculation of the `remain` value will fail due to an underflow. ```solidity=72 } else { if (startIdx + size - 1 > length) { size = length - startIdx; } last = startIdx + size; remain = length - last; } ``` ### Proof of Concept The following PoC first mint 6 tokens and call `tokenIdsOfOwner` to find tokens from starting from index 1. ```solidity pragma solidity ^0.8.0; import { Test } from "forge-std/Test.sol"; import {NFT} from "../src/NFT.sol"; contract NFTTest is Test { function mkaddr(string memory name) public returns (address) { address addr = address(uint160(uint256(keccak256(abi.encodePacked(name))))); vm.label(addr, name); return addr; } address public admin; function testRevert() public { NFT nft = new NFT("nft", "nft", "nft"); admin = mkaddr("admin"); for (uint i = 0; i < 6; i = i + 1 ) { nft.safeMint(address(admin), i); } nft.tokenIdsOfOwner(address(admin), 1, 6); } } ``` **Result** As the result below, the test reverts caused by the underflow on `remain = length - last;`. ```solidity Test result: FAILED. 0 passed; 1 failed; finished in 2.94ms Failing tests: Encountered 1 failing test in test/NFTTest.sol:NFTTest [FAIL. Reason: Arithmetic over/underflow] testRevert() (gas: 2792157) ```
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (3)
1,044 projects reviewed · 1,375 reports · latest May 2025
See CertiK’s auditsSomething wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.
Tell us