entry-point-analyzer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Entry Point Analyzer

入口点分析器

Systematically identify all state-changing entry points in a smart contract codebase to guide security audits.
系统性识别智能合约代码库中所有状态变更入口点,为安全审计提供指引。

When to Use

适用场景

Use this skill when:
  • Starting a smart contract security audit to map the attack surface
  • Asked to find entry points, external functions, or audit flows
  • Analyzing access control patterns across a codebase
  • Identifying privileged operations and role-restricted functions
  • Building an understanding of which functions can modify contract state
在以下场景中使用本技能:
  • 启动智能合约安全审计以梳理攻击面时
  • 需要查找入口点、外部函数或审计流程时
  • 分析代码库中的访问控制模式时
  • 识别特权操作和角色限制函数时
  • 需了解哪些函数可修改合约状态时

When NOT to Use

不适用场景

Do NOT use this skill for:
  • Vulnerability detection (use audit-context-building or domain-specific-audits)
  • Writing exploit POCs (use solidity-poc-builder)
  • Code quality or gas optimization analysis
  • Non-smart-contract codebases
  • Analyzing read-only functions (this skill excludes them)
请勿在以下场景使用本技能:
  • 漏洞检测(使用审计上下文构建或领域特定审计技能)
  • 编写漏洞利用POC(使用Solidity POC构建器)
  • 代码质量或gas优化分析
  • 非智能合约代码库
  • 分析只读函数(本技能会排除此类函数)

Scope: State-Changing Functions Only

范围:仅针对状态变更函数

This skill focuses exclusively on functions that can modify state. Excluded:
LanguageExcluded Patterns
Solidity
view
,
pure
functions
Vyper
@view
,
@pure
functions
SolanaFunctions without
mut
account references
MoveNon-entry
public fun
(module-callable only)
TON
get
methods (FunC), read-only receivers (Tact)
CosmWasm
query
entry point and its handlers
Why exclude read-only functions? They cannot directly cause loss of funds or state corruption. While they may leak information, the primary audit focus is on functions that can change state.
本技能仅关注可修改状态的函数。排除以下类型:
语言排除模式
Solidity
view
pure
函数
Vyper
@view
@pure
函数
Solana
mut
账户引用的函数
Move非入口
public fun
(仅模块可调用)
TON
get
方法(FunC)、只读接收器(Tact)
CosmWasm
query
入口点及其处理函数
为何排除只读函数? 它们无法直接导致资金损失或状态损坏。虽然可能存在信息泄露风险,但审计的核心重点是可改变状态的函数。

Workflow

工作流程

  1. Detect Language - Identify contract language(s) from file extensions and syntax
  2. Use Tooling (if available) - For Solidity, check if Slither is available and use it
  3. Locate Contracts - Find all contract/module files (apply directory filter if specified)
  4. Extract Entry Points - Parse each file for externally callable, state-changing functions
  5. Classify Access - Categorize each function by access level
  6. Generate Report - Output structured markdown report
  1. 检测语言 - 通过文件扩展名和语法识别合约语言
  2. 使用工具(如有) - 针对Solidity,检查是否有Slither可用并使用它
  3. 定位合约 - 查找所有合约/模块文件(如有指定则应用目录过滤)
  4. 提取入口点 - 解析每个文件,提取可外部调用的状态变更函数
  5. 分类访问权限 - 按访问级别对每个函数进行分类
  6. 生成报告 - 输出结构化markdown报告

Slither Integration (Solidity)

Slither集成(Solidity)

For Solidity codebases, Slither can automatically extract entry points. Before manual analysis:
针对Solidity代码库,Slither可自动提取入口点。在手动分析前:

1. Check if Slither is Available

1. 检查Slither是否可用

bash
which slither
bash
which slither

2. If Slither is Detected, Run Entry Points Printer

2. 若检测到Slither,运行入口点打印工具

bash
slither . --print entry-points
This outputs a table of all state-changing entry points with:
  • Contract name
  • Function name
  • Visibility
  • Modifiers applied
bash
slither . --print entry-points
该命令会输出包含以下信息的所有状态变更入口点表格:
  • 合约名称
  • 函数名称
  • 可见性
  • 应用的修饰器

3. Use Slither Output as Foundation

3. 以Slither输出为基础进行分析

  • Parse the Slither output table to populate your analysis
  • Cross-reference with manual inspection for access control classification
  • Slither may miss some patterns (callbacks, dynamic access control)—supplement with manual review
  • If Slither fails (compilation errors, unsupported features), fall back to manual analysis
  • 解析Slither输出表格以填充分析内容
  • 结合手动检查进行访问控制分类交叉验证
  • Slither可能会遗漏某些模式(回调、动态访问控制)——需通过手动审查补充
  • 若Slither运行失败(编译错误、不支持的特性),则回退到手动分析

4. When Slither is NOT Available

4. 当Slither不可用时

If
which slither
returns nothing, proceed with manual analysis using the language-specific reference files.
which slither
无返回结果,则使用特定语言的参考文件进行手动分析。

Language Detection

语言检测

ExtensionLanguageReference
.sol
Solidity{baseDir}/references/solidity.md
.vy
Vyper{baseDir}/references/vyper.md
.rs
+
Cargo.toml
with
solana-program
Solana (Rust){baseDir}/references/solana.md
.move
+
Move.toml
with
edition
{baseDir}/references/move-sui.md
.move
+
Move.toml
with
Aptos
{baseDir}/references/move-aptos.md
.fc
,
.func
,
.tact
TON (FunC/Tact){baseDir}/references/ton.md
.rs
+
Cargo.toml
with
cosmwasm-std
CosmWasm{baseDir}/references/cosmwasm.md
Load the appropriate reference file(s) based on detected language before analysis.
扩展名语言参考文档
.sol
Solidity{baseDir}/references/solidity.md
.vy
Vyper{baseDir}/references/vyper.md
.rs
+ 含
solana-program
Cargo.toml
Solana (Rust){baseDir}/references/solana.md
.move
+ 含
edition
Move.toml
{baseDir}/references/move-sui.md
.move
+ 含
Aptos
Move.toml
{baseDir}/references/move-aptos.md
.fc
.func
.tact
TON (FunC/Tact){baseDir}/references/ton.md
.rs
+ 含
cosmwasm-std
Cargo.toml
CosmWasm{baseDir}/references/cosmwasm.md
分析前根据检测到的语言加载对应的参考文件。

Access Classification

访问权限分类

Classify each state-changing entry point into one of these categories:
将每个状态变更入口点归类为以下类别之一:

1. Public (Unrestricted)

1. 公共(无限制)

Functions callable by anyone without restrictions.
任何人无需限制即可调用的函数。

2. Role-Restricted

2. 角色限制

Functions limited to specific roles. Common patterns to detect:
  • Explicit role names:
    admin
    ,
    owner
    ,
    governance
    ,
    guardian
    ,
    operator
    ,
    manager
    ,
    minter
    ,
    pauser
    ,
    keeper
    ,
    relayer
    ,
    lender
    ,
    borrower
  • Role-checking patterns:
    onlyRole
    ,
    hasRole
    ,
    require(msg.sender == X)
    ,
    assert_owner
    ,
    #[access_control]
  • When role is ambiguous, flag as "Restricted (review required)" with the restriction pattern noted
仅限特定角色调用的函数。需检测的常见模式:
  • 明确的角色名称:
    admin
    owner
    governance
    guardian
    operator
    manager
    minter
    pauser
    keeper
    relayer
    lender
    borrower
  • 角色检查模式:
    onlyRole
    hasRole
    require(msg.sender == X)
    assert_owner
    #[access_control]
  • 当角色不明确时,标记为**“受限(需审查)”**并注明限制模式

3. Contract-Only (Internal Integration Points)

3. 仅合约可调用(内部集成点)

Functions callable only by other contracts, not by EOAs. Indicators:
  • Callbacks:
    onERC721Received
    ,
    uniswapV3SwapCallback
    ,
    flashLoanCallback
  • Interface implementations with contract-caller checks
  • Functions that revert if
    tx.origin == msg.sender
  • Cross-contract hooks
仅可由其他合约调用、不可由外部账户(EOA)调用的函数。识别指标:
  • 回调函数:
    onERC721Received
    uniswapV3SwapCallback
    flashLoanCallback
  • 带有合约调用者检查的接口实现
  • tx.origin == msg.sender
    则回滚的函数
  • 跨合约钩子

Output Format

输出格式

Generate a markdown report with this structure:
markdown
undefined
生成具有以下结构的markdown报告:
markdown
undefined

Entry Point Analysis: [Project Name]

入口点分析:[项目名称]

Analyzed: [timestamp] Scope: [directories analyzed or "full codebase"] Languages: [detected languages] Focus: State-changing functions only (view/pure excluded)
分析时间:[时间戳] 范围:[分析的目录或“完整代码库”] 语言:[检测到的语言] 重点:仅针对状态变更函数(排除view/pure函数)

Summary

摘要

CategoryCount
Public (Unrestricted)X
Role-RestrictedX
Restricted (Review Required)X
Contract-OnlyX
TotalX

类别数量
公共(无限制)X
角色限制X
受限(需审查)X
仅合约可调用X
总计X

Public Entry Points (Unrestricted)

公共入口点(无限制)

State-changing functions callable by anyone—prioritize for attack surface analysis.
FunctionFileNotes
functionName(params)
path/to/file.sol:L42
Brief note if relevant

任何人可调用的状态变更函数——优先用于攻击面分析。
函数文件备注
functionName(params)
path/to/file.sol:L42
相关的简要说明(如有)

Role-Restricted Entry Points

角色限制入口点

Admin / Owner

管理员 / 所有者

FunctionFileRestriction
setFee(uint256)
Config.sol:L15
onlyOwner
函数文件限制条件
setFee(uint256)
Config.sol:L15
onlyOwner

Governance

治理

FunctionFileRestriction
函数文件限制条件

Guardian / Pauser

守护者 / 暂停器

FunctionFileRestriction
函数文件限制条件

Other Roles

其他角色

FunctionFileRestrictionRole

函数文件限制条件角色

Restricted (Review Required)

受限(需审查)

Functions with access control patterns that need manual verification.
FunctionFilePatternWhy Review
execute(bytes)
Executor.sol:L88
require(trusted[msg.sender])
Dynamic trust list

具有访问控制模式但需手动验证的函数。
函数文件模式审查原因
execute(bytes)
Executor.sol:L88
require(trusted[msg.sender])
动态信任列表

Contract-Only (Internal Integration Points)

仅合约可调用(内部集成点)

Functions only callable by other contracts—useful for understanding trust boundaries.
FunctionFileExpected Caller
onFlashLoan(...)
Vault.sol:L200
Flash loan provider

仅可由其他合约调用的函数——有助于理解信任边界。
函数文件预期调用方
onFlashLoan(...)
Vault.sol:L200
闪电贷提供商

Files Analyzed

已分析文件

  • path/to/file1.sol
    (X state-changing entry points)
  • path/to/file2.sol
    (X state-changing entry points)
undefined
  • path/to/file1.sol
    (X个状态变更入口点)
  • path/to/file2.sol
    (X个状态变更入口点)
undefined

Filtering

过滤规则

When user specifies a directory filter:
  • Only analyze files within that path
  • Note the filter in the report header
  • Example: "Analyze only
    src/core/
    " → scope =
    src/core/
当用户指定目录过滤时:
  • 仅分析该路径下的文件
  • 在报告标题中注明过滤条件
  • 示例:“仅分析
    src/core/
    ” → 范围 =
    src/core/

Analysis Guidelines

分析指南

  1. Be thorough: Don't skip files. Every state-changing externally callable function matters.
  2. Be conservative: When uncertain about access level, flag for review rather than miscategorize.
  3. Skip read-only: Exclude
    view
    ,
    pure
    , and equivalent read-only functions.
  4. Note inheritance: If a function's access control comes from a parent contract, note this.
  5. Track modifiers: List all access-related modifiers/decorators applied to each function.
  6. Identify patterns: Look for common patterns like:
    • Initializer functions (often unrestricted on first call)
    • Upgrade functions (high-privilege)
    • Emergency/pause functions (guardian-level)
    • Fee/parameter setters (admin-level)
    • Token transfers and approvals (often public)
  1. 全面性:不要遗漏任何文件。每个可外部调用的状态变更函数都至关重要。
  2. 谨慎性:当对访问级别不确定时,标记为需审查而非错误分类。
  3. 跳过只读函数:排除
    view
    pure
    及等效的只读函数。
  4. 注意继承:若函数的访问控制来自父合约,请注明这一点。
  5. 跟踪修饰器:列出应用于每个函数的所有访问相关修饰器/装饰器。
  6. 识别模式:留意常见模式,例如:
    • 初始化函数(首次调用通常无限制)
    • 升级函数(高权限)
    • 紧急/暂停函数(守护者级别)
    • 费用/参数设置函数(管理员级别)
    • 代币转账和授权(通常为公共)

Common Role Patterns by Protocol Type

按协议类型划分的常见角色模式

Protocol TypeCommon Roles
DEX
owner
,
feeManager
,
pairCreator
Lending
admin
,
guardian
,
liquidator
,
oracle
Governance
proposer
,
executor
,
canceller
,
timelock
NFT
minter
,
admin
,
royaltyReceiver
Bridge
relayer
,
guardian
,
validator
,
operator
Vault/Yield
strategist
,
keeper
,
harvester
,
manager
协议类型常见角色
去中心化交易所(DEX)
owner
feeManager
pairCreator
借贷协议
admin
guardian
liquidator
oracle
治理协议
proposer
executor
canceller
timelock
NFT
minter
admin
royaltyReceiver
跨链桥
relayer
guardian
validator
operator
金库/收益协议
strategist
keeper
harvester
manager

Rationalizations to Reject

需避免的主观判断

When analyzing entry points, reject these shortcuts:
  • "This function looks standard" → Still classify it; standard functions can have non-standard access control
  • "The modifier name is clear" → Verify the modifier's actual implementation
  • "This is obviously admin-only" → Trace the actual restriction; "obvious" assumptions miss subtle bypasses
  • "I'll skip the callbacks" → Callbacks define trust boundaries; always include them
  • "It doesn't modify much state" → Any state change can be exploited; include all non-view functions
分析入口点时,需避免以下捷径:
  • “这个函数看起来是标准的” → 仍需分类;标准函数可能存在非标准访问控制
  • “修饰器名称很明确” → 验证修饰器的实际实现
  • “这显然是仅管理员可调用的” → 追踪实际的限制条件;“显而易见”的假设会忽略微妙的绕过方式
  • “我会跳过回调函数” → 回调函数定义了信任边界;务必包含它们
  • “它修改的状态很少” → 任何状态变更都可能被利用;包含所有非view函数

Error Handling

错误处理

If a file cannot be parsed:
  1. Note it in the report under "Analysis Warnings"
  2. Continue with remaining files
  3. Suggest manual review for unparsable files
若无法解析某个文件:
  1. 在报告的“分析警告”部分注明
  2. 继续分析剩余文件
  3. 建议对无法解析的文件进行手动审查