entry-point-analyzer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEntry 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:
| Language | Excluded Patterns |
|---|---|
| Solidity | |
| Vyper | |
| Solana | Functions without |
| Move | Non-entry |
| TON | |
| CosmWasm | |
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 | |
| Vyper | |
| Solana | 无 |
| Move | 非入口 |
| TON | |
| CosmWasm | |
为何排除只读函数? 它们无法直接导致资金损失或状态损坏。虽然可能存在信息泄露风险,但审计的核心重点是可改变状态的函数。
Workflow
工作流程
- Detect Language - Identify contract language(s) from file extensions and syntax
- Use Tooling (if available) - For Solidity, check if Slither is available and use it
- Locate Contracts - Find all contract/module files (apply directory filter if specified)
- Extract Entry Points - Parse each file for externally callable, state-changing functions
- Classify Access - Categorize each function by access level
- Generate Report - Output structured markdown report
- 检测语言 - 通过文件扩展名和语法识别合约语言
- 使用工具(如有) - 针对Solidity,检查是否有Slither可用并使用它
- 定位合约 - 查找所有合约/模块文件(如有指定则应用目录过滤)
- 提取入口点 - 解析每个文件,提取可外部调用的状态变更函数
- 分类访问权限 - 按访问级别对每个函数进行分类
- 生成报告 - 输出结构化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 slitherbash
which slither2. If Slither is Detected, Run Entry Points Printer
2. 若检测到Slither,运行入口点打印工具
bash
slither . --print entry-pointsThis 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 returns nothing, proceed with manual analysis using the language-specific reference files.
which slither若无返回结果,则使用特定语言的参考文件进行手动分析。
which slitherLanguage Detection
语言检测
| Extension | Language | Reference |
|---|---|---|
| Solidity | {baseDir}/references/solidity.md |
| Vyper | {baseDir}/references/vyper.md |
| Solana (Rust) | {baseDir}/references/solana.md |
| {baseDir}/references/move-sui.md | |
| {baseDir}/references/move-aptos.md | |
| TON (FunC/Tact) | {baseDir}/references/ton.md |
| CosmWasm | {baseDir}/references/cosmwasm.md |
Load the appropriate reference file(s) based on detected language before analysis.
| 扩展名 | 语言 | 参考文档 |
|---|---|---|
| Solidity | {baseDir}/references/solidity.md |
| Vyper | {baseDir}/references/vyper.md |
| Solana (Rust) | {baseDir}/references/solana.md |
| {baseDir}/references/move-sui.md | |
| {baseDir}/references/move-aptos.md | |
| TON (FunC/Tact) | {baseDir}/references/ton.md |
| 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,lenderborrower - 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、lenderborrower - 角色检查模式:、
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,uniswapV3SwapCallbackflashLoanCallback - Interface implementations with contract-caller checks
- Functions that revert if
tx.origin == msg.sender - Cross-contract hooks
仅可由其他合约调用、不可由外部账户(EOA)调用的函数。识别指标:
- 回调函数:、
onERC721Received、uniswapV3SwapCallbackflashLoanCallback - 带有合约调用者检查的接口实现
- 若则回滚的函数
tx.origin == msg.sender - 跨合约钩子
Output Format
输出格式
Generate a markdown report with this structure:
markdown
undefined生成具有以下结构的markdown报告:
markdown
undefinedEntry 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
摘要
| Category | Count |
|---|---|
| Public (Unrestricted) | X |
| Role-Restricted | X |
| Restricted (Review Required) | X |
| Contract-Only | X |
| Total | X |
| 类别 | 数量 |
|---|---|
| 公共(无限制) | X |
| 角色限制 | X |
| 受限(需审查) | X |
| 仅合约可调用 | X |
| 总计 | X |
Public Entry Points (Unrestricted)
公共入口点(无限制)
State-changing functions callable by anyone—prioritize for attack surface analysis.
| Function | File | Notes |
|---|---|---|
| | Brief note if relevant |
任何人可调用的状态变更函数——优先用于攻击面分析。
| 函数 | 文件 | 备注 |
|---|---|---|
| | 相关的简要说明(如有) |
Role-Restricted Entry Points
角色限制入口点
Admin / Owner
管理员 / 所有者
| Function | File | Restriction |
|---|---|---|
| | |
| 函数 | 文件 | 限制条件 |
|---|---|---|
| | |
Governance
治理
| Function | File | Restriction |
|---|
| 函数 | 文件 | 限制条件 |
|---|
Guardian / Pauser
守护者 / 暂停器
| Function | File | Restriction |
|---|
| 函数 | 文件 | 限制条件 |
|---|
Other Roles
其他角色
| Function | File | Restriction | Role |
|---|
| 函数 | 文件 | 限制条件 | 角色 |
|---|
Restricted (Review Required)
受限(需审查)
Functions with access control patterns that need manual verification.
| Function | File | Pattern | Why Review |
|---|---|---|---|
| | | Dynamic trust list |
具有访问控制模式但需手动验证的函数。
| 函数 | 文件 | 模式 | 审查原因 |
|---|---|---|---|
| | | 动态信任列表 |
Contract-Only (Internal Integration Points)
仅合约可调用(内部集成点)
Functions only callable by other contracts—useful for understanding trust boundaries.
| Function | File | Expected Caller |
|---|---|---|
| | Flash loan provider |
仅可由其他合约调用的函数——有助于理解信任边界。
| 函数 | 文件 | 预期调用方 |
|---|---|---|
| | 闪电贷提供商 |
Files Analyzed
已分析文件
- (X state-changing entry points)
path/to/file1.sol - (X state-changing entry points)
path/to/file2.sol
undefined- (X个状态变更入口点)
path/to/file1.sol - (X个状态变更入口点)
path/to/file2.sol
undefinedFiltering
过滤规则
When user specifies a directory filter:
- Only analyze files within that path
- Note the filter in the report header
- Example: "Analyze only " → scope =
src/core/src/core/
当用户指定目录过滤时:
- 仅分析该路径下的文件
- 在报告标题中注明过滤条件
- 示例:“仅分析” → 范围 =
src/core/src/core/
Analysis Guidelines
分析指南
- Be thorough: Don't skip files. Every state-changing externally callable function matters.
- Be conservative: When uncertain about access level, flag for review rather than miscategorize.
- Skip read-only: Exclude ,
view, and equivalent read-only functions.pure - Note inheritance: If a function's access control comes from a parent contract, note this.
- Track modifiers: List all access-related modifiers/decorators applied to each function.
- 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)
- 全面性:不要遗漏任何文件。每个可外部调用的状态变更函数都至关重要。
- 谨慎性:当对访问级别不确定时,标记为需审查而非错误分类。
- 跳过只读函数:排除、
view及等效的只读函数。pure - 注意继承:若函数的访问控制来自父合约,请注明这一点。
- 跟踪修饰器:列出应用于每个函数的所有访问相关修饰器/装饰器。
- 识别模式:留意常见模式,例如:
- 初始化函数(首次调用通常无限制)
- 升级函数(高权限)
- 紧急/暂停函数(守护者级别)
- 费用/参数设置函数(管理员级别)
- 代币转账和授权(通常为公共)
Common Role Patterns by Protocol Type
按协议类型划分的常见角色模式
| Protocol Type | Common Roles |
|---|---|
| DEX | |
| Lending | |
| Governance | |
| NFT | |
| Bridge | |
| Vault/Yield | |
| 协议类型 | 常见角色 |
|---|---|
| 去中心化交易所(DEX) | |
| 借贷协议 | |
| 治理协议 | |
| NFT | |
| 跨链桥 | |
| 金库/收益协议 | |
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:
- Note it in the report under "Analysis Warnings"
- Continue with remaining files
- Suggest manual review for unparsable files
若无法解析某个文件:
- 在报告的“分析警告”部分注明
- 继续分析剩余文件
- 建议对无法解析的文件进行手动审查