Ability analysis

From PlamenTSV/plamen · View interactive version

Ability analysis is an AI agent skill from the GitHub repository PlamenTSV/plamen. Trigger Pattern Always (Sui Move) -- foundational security check - Inject Into Breadth agents, depth agents

How to use this skill

Skill file

ABILITY_ANALYSIS Skill

Trigger Pattern: Always (Sui Move) -- foundational security check

Inject Into: Breadth agents, depth agents

For every struct defined in the protocol:

STEP PRIORITY: Steps 5 (Hot Potato Enforcement) and 7 (Dynamic Field Ability Propagation) are where HIGH/CRITICAL severity findings most commonly hide. Do NOT rush these steps. If constrained, skip conditional sections before skipping 5 or 7.

1. Struct Ability Inventory

Enumerate ALL structs across all modules:

| Module | Struct | Abilities | Has id: UID? | Is Object? | Transferable? | Notes |

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

| {mod} | {name} | {key, store, drop, copy} | YES/NO | YES/NO | YES/NO | {context} |

Sui ability semantics:

Consistency check: For each struct with key:

2. Object Model Classification

Classify each object (key ability) by ownership model:

| Object | Ownership | Created Via | Transfer Restricted? | Freeze Possible? |

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

| {name} | Owned / Shared / Frozen / Wrapped | {function} | YES (no store) / NO (store) | YES/NO |

Security checks per ownership type:

2a. Owned Objects

2b. Shared Objects

2c. Frozen Objects (Immutable)

2d. Wrapped Objects

3. Ability Mismatch Analysis

For each struct, verify ability assignments match intended behavior:

3a. Missing `drop` -- Intentional?

| Struct | Has drop? | Explicit Destroy Function? | Can Leak? |

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

| {name} | NO | YES: destroy_{name}() / NO | YES/NO |

Rule: A struct without drop that has no explicit destroy/consume path creates a resource leak. The transaction will abort if the value is not consumed. This is sometimes intentional (hot potato) but often a bug when the struct is created in error paths.

3b. Unnecessary `store` -- Over-Permissive?

| Struct | Has store? | Stored in Dynamic Fields? | Freely Transferable? | Should Be Restricted? |

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

| {name} | YES | YES/NO | YES | {analysis} |

Check: If a struct has store but the protocol intends restricted transfers (e.g., non-transferable receipts, bound tickets), the store ability enables bypass via public_transfer. Does any security invariant depend on transfer restriction?

3c. `copy` Abuse Potential

| Struct | Has copy? | Contains Balances/IDs? | Duplication Dangerous? |

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

| {name} | YES/NO | YES/NO | YES/NO |

Rule: copy on a struct containing Balance<T>, capability tokens, or unique identifiers is almost always a bug -- it enables double-spending or capability duplication. copy + key is impossible (enforced by Sui), but copy + store on inner structs is allowed and dangerous if they hold value.

4. Capability Pattern Audit

Identify all capability/admin structs:

| Capability | Abilities | Created In | Transferred To | Can Be Duplicated? | Revocable? |

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

| {name} | {abilities} | init() | {recipient} | YES (copy) / NO | YES/NO |

Checks:

5. Hot Potato Enforcement

Identify all structs with NO abilities:

| Struct | Module | Created By | Must Be Consumed By | Enforced? |

|--------|--------|------------|--------------------|---------:|

| {name} | {mod} | {function} | {function} | YES/NO |

Hot potato security checks:

Pattern validation: Trace every hot potato from creation to consumption. Document the full lifecycle:

create: module::start_action() -> HotPotato
  ... intervening calls that rely on HotPotato's existence ...
consume: module::finish_action(potato: HotPotato)

If any code path creates a hot potato without a guaranteed consumption path -> FINDING (transaction will always abort on that path).

If a receipt enforces consumption but is not bound to the source object it came from -> FINDING (the receipt can settle the wrong order/pool/position).

6. Transfer Restriction Analysis

For objects with key but NOT store:

| Object | Module Transfer Function | Custom Rules | Bypass Possible? |

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

| {name} | {function or NONE} | {description} | YES/NO |

Sui transfer rules:

Check each restricted object:

  1. Does any public function accept this object type and wrap it?
  2. Does any public function accept this object type and place it in a dynamic field of a freely transferable object?
  3. If yes to either -> the transfer restriction is bypassable -> FINDING.

7. Dynamic Field Ability Propagation

For every use of dynamic_field::add or dynamic_object_field::add:

| Parent Object | Field Key Type | Field Value Type | Value Has store? | Parent Has store? |

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

| {parent} | {key_type} | {value_type} | YES/NO | YES/NO |

Rules:

8. Module Initializer Audit

For each module with an init function:

| Module | init Parameters | Objects Created | Capabilities Issued | OTW Consumed? |

|--------|------------------|-----------------|--------------------|--------------:|

| {mod} | {params} | {list} | {list} | YES/NO/N/A |

Checks:

Finding Template

**ID**: [AB-N]
**Severity**: [based on ability misuse impact]
**Step Execution**: check1,2,3,4,5,6,7,8 | X(reasons) | ?(uncertain)
**Rules Applied**: [R4:Y, R5:Y, R10:Y, ...]
**Location**: module::struct_name
**Title**: [Ability issue type] in [struct] enables [attack/bypass]
**Description**: [Specific ability misconfiguration with type-level trace]
**Impact**: [What breaks: transfer restriction bypass, capability duplication, resource leak, hot potato griefing]

Step Execution Checklist (MANDATORY)

CRITICAL: You MUST report completion status for ALL sections. Findings with incomplete sections will be flagged for depth review.

| Section | Required | Completed? | Notes |

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

| 1. Struct Ability Inventory | YES | Y/X/? | |

| 2. Object Model Classification | YES | Y/X/? | |

| 2b. Shared Object Analysis | IF shared objects | Y/X(N/A)/? | |

| 3. Ability Mismatch Analysis | YES | Y/X/? | |

| 3b. Unnecessary store Check | YES | Y/X/? | |

| 3c. copy Abuse Check | YES | Y/X/? | |

| 4. Capability Pattern Audit | YES | Y/X/? | |

| 5. Hot Potato Enforcement | IF hot potatoes exist | Y/X(N/A)/? | HIGH PRIORITY |

| 6. Transfer Restriction Analysis | IF key-only objects | Y/X(N/A)/? | |

| 7. Dynamic Field Ability Propagation | IF dynamic fields used | Y/X(N/A)/? | HIGH PRIORITY |

| 8. Module Initializer Audit | YES | Y/X/? | |

Cross-Reference Markers

After Section 4 (Capability Pattern Audit):

After Section 5 (Hot Potato Enforcement):

After Section 7 (Dynamic Field Ability Propagation):

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.