Panoptic - satoshispeedrunner's results

Permissionless, perpetual options trading on any token, any strike, any size.

General Information

Platform: Code4rena

Start Date: 01/04/2024

Pot Size: $120,000 USDC

Total HM: 11

Participants: 55

Period: 21 days

Judge: Picodes

Total Solo HM: 6

Id: 354

League: ETH

Panoptic

Findings Distribution

Researcher Performance

Rank: 40/55

Findings: 1

Award: $32.96

🌟 Selected for report: 0

🚀 Solo Findings: 0

ERC1155Minimal.sol

  1. Balance Underflow Risk: The safeTransferFrom and safeBatchTransferFrom functions do not explicitly check for balance underflow, which could happen if someone tries to transfer more tokens than they have. Although Solidity 0.8.x and above include built-in underflow/overflow checks, it is good practice to ensure there's an appropriate balance before allowing the transfer.

  2. ERC1155Holder as a Type Cast for to: In both the safeTransferFrom and safeBatchTransferFrom functions, there is a potentially dangerous cast of the to address to ERC1155Holder, regardless of whether it is a valid contract that implements ERC1155Receiver. The right check would be to call the interface methods directly on to and ensure it implements onERC1155Received or onERC1155BatchReceived. The current implementation assumes that to is an ERC1155Holder contract or has the same interface, which may not be true. This could cause a revert or unexpected behavior if to does not implement the expected functions.

  3. Missing Interface Check for ERC1155Receiver: The supportsInterface function does not check for the ERC1155Receiver interface (0x4e2312e0), which it implicitly supports due to the implementation of the safeTransferFrom and safeBatchTransferFrom functions. When transferring tokens to a contract, that contract should support the ERC1155Receiver interface, and the supportsInterface function should return true for that interface ID.

  4. Unsafe External Calls without Reentrancy Protection: The calls to onERC1155Received and onERC1155BatchReceived could potentially lead to reentrancy attacks if the to contract is malicious. Consider using reentrancy guards like the OpenZeppelin's ReentrancyGuard to prevent such issues.

  5. Incorrect to.code.length Check: The checks for to.code.length != 0 are intended to determine if to is a contract. However, the correct way in Solidity to check if an address is a contract is to use to.code.length > 0 or to use Address.isContract(to) if you are using OpenZeppelin libraries.

  6. Event on Minting to Smart Contracts: The _mint function sends an event and then checks if to is a contract to call onERC1155Received. According to EIP-1155, external code should only be called after all internal state changes, including events, are completed. Thus, the event should be emitted after the call to the external contract.

  7. Lack of Input Validation: There are no checks that ensure the ids and amounts arrays provided to safeBatchTransferFrom have the same length, which is a requirement for batch transfers.

  8. Unchecked Length in balanceOfBatch: The balanceOfBatch function does not check if owners and ids are of equal length, which they should be according to the ERC1155 specification.

  9. Documentation/Comment Issues: There are minor issues with the documentation, such as missing @dev comments for balanceOf and isApprovedForAll. Consistent and thorough documentation helps with clarity and maintainability.

Please note that reviewing smart contract code requires more than analyzing the code manually. It generally involves running tests, static analysis tools, and possibly audits by professionals to identify potential security issues.

#0 - c4-judge

2024-04-26T17:16:53Z

Picodes marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter