AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

entry-point-analyzer

Analyzes smart contract codebases to identify state-changing entry points for security auditing. Detects externally callable functions that modify state, categorizes them by access level (public, admin, role-restricted, contract-only), and generates structured audit reports. Excludes view/pure/read-only functions. Use when auditing smart contracts (Solidity, Vyper, Solana/Rust, Move, TON, CosmWasm) or when asked to find entry points, audit flows, external functions, access control patterns, or privileged operations.

Original source
trailofbits
License
CC-BY-SA-4.0
Pinned revision
2be6433b39e009cd2b6fd3be1895f6b1faa5af9a

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read trailofbits--entry-point-analyzer at revision 2be6433b39e009cd2b6fd3be1895f6b1faa5af9a, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 8

references/cosmwasm.md

CosmWasm Entry Point Detection

Entry Point Identification (State-Changing Only)

Include: State-Changing Entry Points

// Instantiate - called once on deployment
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    msg: InstantiateMsg,
) -> Result<Response, ContractError> { }

// Execute - main entry point for state changes
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    msg: ExecuteMsg,
) -> Result<Response, ContractError> { }

// Query - read-only entry point
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(
    deps: Deps,
    env: Env,
    msg: QueryMsg,
) -> StdResult<Binary> { }

// Migrate - called on contract migration
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(
    deps: DepsMut,
    env: Env,
    msg: MigrateMsg,
) -> Result<Response, ContractError> { }

// Reply - handles submessage responses
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn reply(
    deps: DepsMut,
    env: Env,
    msg: Reply,
) -> Result<Response, ContractError> { }

// Sudo - privileged operations (governance)
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn sudo(
    deps: DepsMut,
    env: Env,
    msg: SudoMsg,
) -> Result<Response, ContractError> { }

Entry Point Types

| Entry Point | Include? | Classification | Notes | |-------------|----------|----------------|-------| | instantiate | Yes | One-time setup | Sets initial state | | execute | Yes | Main dispatcher | Contains multiple operations | | query | No | Read-only | EXCLUDE - no state changes | | migrate | Yes | Admin/Governance | Requires migration permission | | reply | Yes | Contract-Only | Submessage callback | | sudo | Yes | Governance | Chain-level privileged |

ExecuteMsg Variants (Primary Focus)

#[cw_serde]
pub enum ExecuteMsg {
    Transfer { recipient: String, amount: Uint128 },     // Usually public
    UpdateConfig { admin: Option<String> },              // Admin only
    Pause {},                                            // Guardian
    Withdraw { amount: Uint128 },                        // Public or restricted
}

Access Control Patterns

Cw-Ownable Pattern

use cw_ownable::{assert_owner, initialize_owner};

pub fn execute_admin_action(deps: DepsMut, info: MessageInfo) -> Result<...> {
    assert_owner(deps.storage, &info.sender)?;
    // ...
}

Manual Owner Check

pub fn execute_update_config(deps: DepsMut, info: MessageInfo) -> Result<...> {
    let config = CONFIG.load(deps.storage)?;
    if info.sender != config.owner {
        return Err(ContractError::Unauthorized {});
    }
    // ...
}

Role-Based Access

// Common patterns
if info.sender != state.admin { return Err(Unauthorized); }
if info.sender != state.governance { return Err(Unauthorized); }
if !state.operators.contains(&info.sender) { return Err(Unauthorized); }

// Using cw-controllers
use cw_controllers::Admin;
ADMIN.assert_admin(deps.as_ref(), &info.sender)?;

Access Control Classification

| Pattern | Classification | |---------|----------------| | assert_owner(storage, &sender) | Owner | | ADMIN.assert_admin(deps, &sender) | Admin | | info.sender != config.owner | Owner | | info.sender != config.admin | Admin | | info.sender != config.governance | Governance | | !operators.contains(&sender) | Operator | | !guardians.contains(&sender) | Guardian | | No sender check | Public (Unrestricted) |

Contract-Only Detection

Reply Handler

#[entry_point]
pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractError> {
    match msg.id {
        INSTANTIATE_REPLY_ID => handle_instantiate_reply(deps, msg),
        _ => Err(ContractError::UnknownReplyId { id: msg.id }),
    }
}

Callback Messages

// Messages expected from other contracts
ExecuteMsg::Callback { ... } => {
    // Should verify sender is expected contract
    if info.sender != expected_contract {
        return Err(ContractError::Unauthorized {});
    }
}

Extraction Strategy

  1. Find Message Enums:

    • ExecuteMsg - main operations (INCLUDE)
    • QueryMsg - read operations (EXCLUDE)
    • SudoMsg - governance operations (INCLUDE)
  2. For Each ExecuteMsg Variant:

    • Find handler function (usually execute_<variant_name>)
    • Check for access control at start of function
    • Classify by access pattern
  3. Map Entry Points:

    • execute dispatcher → enumerate variants (state-changing)
    • query → SKIP (read-only, no state changes)
    • sudo → all variants are governance-level
    • reply → contract-only callbacks

CosmWasm-Specific Considerations

  1. Message Info: info.sender is the caller address
  2. Query Has No Sender: Queries are stateless, no access control
  3. Sudo Is Privileged: Only callable by chain governance
  4. Submessages: reply handles responses from submessages
  5. IBC: IBC entry points for cross-chain messages

Common Gotchas

  1. Instantiate Race: First caller sets owner if not careful
  2. Migration Admin: Separate from contract admin
  3. Cw20 Callbacks: Cw20ReceiveMsg is a callback pattern
  4. IBC Callbacks: ibc_packet_receive etc. are entry points
  5. Admin vs Owner: May be different addresses