move-security
БесплатноБез исполняемых скриптовНе проверенAudits and hardens Move smart contracts on Sui: access control, capability objects, randomness, upgrade governance, emergency controls, and key custody. Use…
от 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, andRandomGeneratormust 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.
- 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. - 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.
- Capability–object relationship. Assert the capability belongs to the object being modified (store and compare the object ID).
- 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.
- Revocation. Is there a way to invalidate a leaked capability? Packages are immutable, so this must exist before publishing.
- Randomness. See the randomness section below.
- Invariants and external data. Assert invariants after state changes; validate oracle/offchain data for staleness, bounds, and source.
- Emergency controls. Value-moving paths should have a pause or rate limit.
- Package identity.
Move.tomlnames 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.
withdrawandchange_adminauthorize by comparingctx.sender()to a stored address. This binds the function to a single signer and breaks composability; no other contract can act for the admin. TheVaultis shared, so anyone can reference it — the internal check is the only barrier. Medium — no events. Neitherwithdrawnorchange_adminemits 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
Установить move-security в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
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), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic