Ref lifecycle

From PlamenTSV/plamen · View interactive version

Ref lifecycle is an AI agent skill from the GitHub repository PlamenTSV/plamen. Type Thought-template (instantiate before use) - Trigger Pattern Always (Aptos Move) -- ConstructorRef/TransferRef/MintRef/BurnRef lifecycle

How to use this skill

Skill file

Skill: Reference Lifecycle Analysis

Type: Thought-template (instantiate before use)

Trigger Pattern: Always (Aptos Move) -- ConstructorRef/TransferRef/MintRef/BurnRef lifecycle

Inject Into: Breadth agents, depth-state-trace, depth-token-flow

Research basis: Aptos Object model capability-based access control, permanent reference semantics

Background

In Aptos Move, object capabilities (Refs) are unforgeable tokens that grant specific permissions over objects. Unlike role-based access control in EVM, Refs are permanent once created -- they CANNOT be revoked. A leaked or improperly stored Ref grants permanent capability to its holder.

Key Ref types:

Trigger Patterns

ConstructorRef|TransferRef|MintRef|BurnRef|DeleteRef|ExtendRef|
object::create_named_object|object::create_sticky_object|object::create_object|
fungible_asset::generate_mint_ref|fungible_asset::generate_burn_ref|
fungible_asset::generate_transfer_ref|object::generate_delete_ref|
object::generate_extend_ref|object::generate_transfer_ref

Reasoning Template

Step 1: Reference Inventory

Enumerate ALL Ref types found in the codebase. For each:

| Ref Type | Created In (module::function) | Stored Location | Access Control | Capability Granted |

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

| ConstructorRef | {module}::{init_fn} | {consumed / stored in resource} | {who can access} | Generate all other Refs |

| MintRef | {module}::{init_fn} | {global resource at @addr} | {who can access} | Unlimited minting of {asset} |

| BurnRef | {module}::{init_fn} | {global resource at @addr} | {who can access} | Burn {asset} from any store |

| TransferRef | {module}::{init_fn} | {global resource at @addr} | {who can access} | Transfer {asset} bypassing freeze |

| DeleteRef | {module}::{init_fn} | {global resource at @addr} | {who can access} | Delete {object} |

| ExtendRef | {module}::{init_fn} | {global resource at @addr} | {who can access} | Generate signer for {object} |

Completeness check: Search for ALL generate_*_ref calls and object::create_* calls. Every Ref created MUST appear in the table.

Step 2: ConstructorRef Analysis

The ConstructorRef is the root capability. It exists only during the init_module or object creation call.

Check 2a: Is ConstructorRef stored?

Check 2b: What Refs are generated from it?

Check 2c: ExtendRef derived signer

Step 3: MintRef / BurnRef Analysis

Check 3a: Storage access control

Check 3b: Mint amount validation

Check 3c: BurnRef scope

Check 3d: Mint/Burn symmetry

Step 4: TransferRef Analysis

Check 4a: Freeze bypass

Check 4b: Transfer direction

Check 4c: Who holds TransferRef?

Step 5: DeleteRef Analysis

Check 5a: Resource cleanup before deletion

Check 5b: Deletion authorization

Step 6: Ref Leakage Path Analysis

Check 6a: Public function returns

Check 6b: Friend module exposure

Check 6c: Store ability check

Step 7: Ref Revocation Assessment

Critical fact: Aptos Refs CANNOT be revoked once created. There is no revoke_mint_ref function in the framework.

Check 7a: Maximum blast radius

Check 7b: Compensating controls

Check 7c: Module upgrade path

Step 8: Cross-Ref Interaction

Check 8a: Ref combination attacks

Check 8b: Ref holder alignment


Finding Template

## Finding [{PREFIX}-N]: {Title}

**Verdict**: CONFIRMED / PARTIAL / REFUTED / CONTESTED
**Step Execution**: {see checklist below}
**Ref Type**: {ConstructorRef / MintRef / BurnRef / TransferRef / DeleteRef / ExtendRef}
**Severity**: {Critical/High/Medium/Low/Info}
**Location**: {SourceFile:LineN}
**Description**: {What capability is exposed and how}
**Impact**: {What an attacker/compromised entity can do with the Ref}
**Evidence**: {Code showing Ref creation, storage, and access path}

### Blast Radius
- **If compromised**: {Maximum damage description}
- **Revocable**: NO (Aptos Refs are permanent)
- **Compensating controls**: {pause/multisig/rate-limit or NONE}

Step Execution Checklist (MANDATORY)

| Step | Required | Completed? | Notes |

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

| 1. Reference Inventory | YES | Y/N/? | Must enumerate ALL Refs |

| 2. ConstructorRef Analysis | YES | Y/N/? | |

| 3. MintRef/BurnRef Analysis | IF present | Y/N(none)/? | |

| 4. TransferRef Analysis | IF present | Y/N(none)/? | |

| 5. DeleteRef Analysis | IF present | Y/N(none)/? | |

| 6. Ref Leakage Path Analysis | YES | Y/N/? | Check public returns + friends |

| 7. Ref Revocation Assessment | YES | Y/N/? | Always: Refs are permanent |

| 8. Cross-Ref Interaction | IF 2+ Ref types | Y/N(single)/? | |

Output Format for Step Execution

**Step Execution**: check1,2,3,4,6,7,8 | x5(no DeleteRef)

OR if incomplete:

**Step Execution**: check1,2,3 | ?4,6,7(TransferRef not fully traced)
**FLAG**: Incomplete analysis -- requires depth review (leakage paths not exhausted)

Instantiation Parameters

{CONTRACTS}           -- Move modules to analyze
{ASSET_NAME}          -- Primary fungible asset name
{REF_STORAGE}         -- Where Refs are stored (resource name and address)
{ACCESS_CONTROL}      -- Who can access stored Refs (signer requirements)
{FRIEND_MODULES}      -- Modules declared as friends
{FREEZE_USED}         -- Whether protocol uses freeze functionality (YES/NO)
{UPGRADE_POLICY}      -- Module upgrade policy (compatible/immutable)

Output Schema

| Field | Required | Description |

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

| ref_inventory | yes | Complete table of all Refs in codebase |

| constructor_ref_analysis | yes | ConstructorRef lifecycle and consumption |

| mint_burn_analysis | if present | MintRef/BurnRef storage and access control |

| transfer_ref_analysis | if present | TransferRef and freeze bypass potential |

| delete_ref_analysis | if present | DeleteRef and resource cleanup |

| leakage_paths | yes | Public/friend exposure of Refs |

| revocation_assessment | yes | Blast radius and compensating controls |

| cross_ref_interactions | if 2+ types | Combined Ref attack scenarios |

| finding | yes | CONFIRMED / REFUTED / CONTESTED / NEEDS_DEPTH |

| evidence | yes | Code locations with line numbers |

| step_execution | yes | Status for each step |

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.