Nft protocol security

From PlamenTSV/plamen · View interactive version

Nft protocol security is an AI agent skill from the GitHub repository PlamenTSV/plamen. Protocol Type Trigger nft (detected when ERC721/ERC1155 with marketplace, minting, staking, or collateral logic found) - Inject Into Breadth agents, depth-token-flow, depth-edge...

How to use this skill

Skill file

Injectable Skill: NFT Protocol Security

Protocol Type Trigger: nft (detected when ERC721/ERC1155 with marketplace, minting, staking, or collateral logic found)

Inject Into: Breadth agents, depth-token-flow, depth-edge-case

Language: EVM only (Solana/Move NFT models use different mechanisms without callbacks or enumeration)

Finding prefix: [NFT-N]

Orchestrator Decomposition Guide

When decomposing this skill into depth agent investigation questions, map sections to domains:

When This Skill Activates

Recon detects NFT protocol patterns: ERC721/ERC1155 with state-modifying logic beyond simple transfer (marketplace listing, staking, collateral, minting with conditions, royalty enforcement, batch operations).

Pure ERC721/ERC1155 token implementations without protocol logic do NOT trigger this skill.


1. Callback Reentrancy Surface

For each function that triggers NFT callbacks:

1a. Safe Transfer Callback Inventory

Enumerate all code paths that invoke _safeMint, _safeTransfer, safeTransferFrom, or onERC1155Received/onERC1155BatchReceived:

| # | Function | Callback Triggered | State Modified BEFORE Callback | State Modified AFTER Callback | Reentrancy Guard? |

|---|----------|-------------------|-------------------------------|------------------------------|-------------------|

For each entry:

1b. Batch Callback Completeness

For contracts implementing ERC1155:

Tag: [TRACE:_safeMint → onERC721Received callback → state_before={list} → reentrant_path={YES/NO}]


2. Approval and Transfer Path Analysis

2a. Approval Scope

For each approval mechanism:

2b. Transfer Authorization

For each transfer function:

2c. Royalty Bypass

If royalties are enforced:

Tag: [TRACE:transfer_path={function} → auth_check={method} → royalty_enforced={YES/NO}]


3. Enumeration and Index Integrity

For contracts using ERC721Enumerable or custom enumeration:

3a. Index Structure Consistency

3b. Burn and Transfer Edge Cases

3c. Batch Operation Atomicity

For batch mint/burn/transfer:

Tag: [BOUNDARY:burn_last_token → _ownedTokens[owner].length={0} → tokenOfOwnerByIndex={result}]


4. Metadata and State Consistency

4a. Token URI Integrity

If tokenURI or uri returns dynamic content:

4b. Token Property Assignment

If tokens have properties assigned at mint time (rarity, type, attributes):

4c. Ownership State During Custody

When tokens are deposited into protocol custody (staking, collateral, escrow):

Tag: [TRACE:mint → property_assignment={method} → randomness_source={source} → manipulable={YES/NO}]


Key Questions (must answer all)

  1. For each _safeMint/_safeTransfer: is critical state updated BEFORE the callback?
  2. For ERC1155: are BOTH single and batch callbacks implemented with correct selectors?
  3. For enumerable tokens: do burn/transfer operations update ALL index structures?
  4. For metadata: does uri() follow the spec for the token standard used?
  5. For custody protocols: is depositor ownership tracked independently from ownerOf?

Common False Positives

Step Execution Checklist (MANDATORY)

| Section | Required | Completed? | Notes |

|---------|----------|------------|-------|

| 1. Callback Reentrancy Surface | IF safe mint/transfer used | | Callback inventory, batch completeness |

| 2. Approval and Transfer Paths | YES | | Authorization, scope, royalty bypass |

| 3. Enumeration and Index Integrity | IF enumerable | | Index consistency across operations |

| 4. Metadata and State Consistency | YES | | URI spec, property assignment, custody |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.