Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

move-security

БесплатноБез исполняемых скриптовНе проверен

Audits and hardens Move smart contracts on Sui: access control, capability objects, randomness, upgrade governance, emergency controls, and key custody. Use…

MystenLabsот MystenLabs★ 25 звёзд на GitHub

Об этом скилле

Move Smart Contract Security

Source of truth: docs.sui.io/develop/security/best-practices only. If the Sui docs MCP server (https://sui.mcp.kapa.ai) is available, use it to verify details.

Quick start

  • Authorizing a privileged function? Take a capability object as the second parameter. Never rely on tx_context::sender() alone.
  • Consuming randomness? The function must be private entry, and RandomGenerator must be created inside it, never passed in.
  • Holding an admin capability? Multisig or dedicated custody, plus a revocation mechanism designed before publishing.

Reference files: access-control.md (capabilities, allowlists, revocation, shared object authorization) and best-practices.md (package auditing, upgrades, dependencies, invariants, events, randomness, oracles, emergency controls, frontend signing, key management). Load one when you need detail beyond the sections below.


Task: review a Move module for security issues

Walk this checklist, then report findings in severity order with the fix for each.

  1. Authorization mechanism. Does each privileged function take a capability, or does it compare ctx.sender() to a stored address? Sender-only checks tie the function to a single signer and break composability — another contract cannot call it on behalf of a user. Recommend a capability object.
  2. Shared state. Anyone can submit a transaction referencing a shared object, so access is never restricted by sharing alone; every function touching shared state must check authorization internally.
  3. Capability–object relationship. Assert the capability belongs to the object being modified (store and compare the object ID).
  4. Events. Every privileged action — admin change, allowlist update, mint/burn, denylist, config change, oracle update, pause — must emit an event so offchain monitoring can detect misuse.
  5. Revocation. Is there a way to invalidate a leaked capability? Packages are immutable, so this must exist before publishing.
  6. Randomness. See the randomness section below.
  7. Invariants and external data. Assert invariants after state changes; validate oracle/offchain data for staleness, bounds, and source.
  8. Emergency controls. Value-moving paths should have a pause or rate limit.
  9. Package identity. Move.toml names are arbitrary strings, not unique. Verify the onchain package ID; an upgrade publishes a new package at a new address.

Example finding and fix

A shared Vault storing admin: address and checking ctx.sender() == vault.admin:

High — sender-only authorization. withdraw and change_admin authorize by comparing ctx.sender() to a stored address. This binds the function to a single signer and breaks composability; no other contract can act for the admin. The Vault is shared, so anyone can reference it — the internal check is the only barrier. Medium — no events. Neither withdraw nor change_admin emits an event, leaving privileged actions invisible to offchain monitoring. Medium — no revocation path. If the admin key is compromised, nothing invalidates it for the life of the immutable package.

Fix:

public struct AdminCap has key, store { id: UID, vault_id: ID }

public struct Withdrawn has copy, drop { vault: ID, amount: u64 }

public fun withdraw(
    vault: &mut Vault,          // object first
    cap: &AdminCap,             // capability second: keeps method associativity
    amount: u64,
    ctx: &mut TxContext,
): Coin<SUI> {
    assert!(cap.vault_id == object::id(vault), ENotAuthorized);
    event::emit(Withdrawn { vault: object::id(vault), amount });
    coin::take(&mut vault.balance, amount, ctx)
}

Task: capability object vs address allowlist

Default: the capability object. Capabilities compose — another protocol can hold a MinterCap on behalf of a user, which an allowlist keyed on tx_context::sender() cannot support. Require the capability as a parameter, placed second (after the object acted on) so method associativity still works.

Escape hatch — allowlist: if the authorized set must be mutable from a single admin action, store it in a well-defined object, restrict who may update it, and emit an event on every change. Even then, authorization still needs an explicit check inside each function, because the holding object is shared.

Design the revocation mechanism before publishing either way (next section).


Task: protect, revoke, and rotate an admin capability

Custody. Hold AdminCap/UpgradeCap in a multisig address, hardware wallet, or dedicated custody — never a single hot wallet. Treat UpgradeCap as seriously as an admin capability: its holder can change package behavior. Each transfer grants full privileges, so do not transfer casually. Separate deploy, admin, and operations keys.

**If a capability leaks and no revocation exists, it remains valid

Полный SKILL.md на GitHub

Установить move-security в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

access-control.mdbest-practices.mdevals/evals.json

FAQ

Что делает скилл move-security?

Audits and hardens Move smart contracts on Sui: access control, capability objects, randomness, upgrade governance, emergency controls, and key custody. Use when the user asks to review or audit Move code for security issues or vulnerabilities, mentions AdminCap, MinterCap, UpgradeCap, capability revocation or rotation, tx_context::sender authorization, shared object access, onchain randomness or RandomGenerator, oracle or offchain data validation, emergency pause or rate limiting, multisig and private key custody, or frontend transaction signing safety. Related skills: `sui-move` (language), `object-model` (ownership), `sui-publish` (upgrades).

Как установить скилл move-security?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл move-security запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить move-security с