smart-contract-security by pluginagentmarketplace/custom-plugin-blockchain
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-blockchain --skill smart-contract-security掌握智能合约安全,包括漏洞检测、审计方法和事件响应流程。
# 调用此技能进行安全分析
Skill("smart-contract-security", topic="vulnerabilities", severity="high")
识别并防范:
系统化审查流程:
必备工具集:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
处理安全事件:
// VULNERABLE
function withdraw(uint256 amount) external {
(bool ok,) = msg.sender.call{value: amount}("");
require(ok);
balances[msg.sender] -= amount; // After call!
}
// FIXED: CEI Pattern
function withdraw(uint256 amount) external {
balances[msg.sender] -= amount; // Before call
(bool ok,) = msg.sender.call{value: amount}("");
require(ok);
}
// VULNERABLE
function setAdmin(address newAdmin) external {
admin = newAdmin; // Anyone can call!
}
// FIXED
function setAdmin(address newAdmin) external onlyOwner {
admin = newAdmin;
}
// VULNERABLE
IERC20(token).transfer(to, amount); // Ignored!
// FIXED: Use SafeERC20
using SafeERC20 for IERC20;
IERC20(token).safeTransfer(to, amount);
// VULNERABLE: Division before multiplication
uint256 fee = (amount / 1000) * rate;
// FIXED: Multiply first
uint256 fee = (amount * rate) / 1000;
# Slither - Fast vulnerability detection
slither . --exclude-dependencies
# Mythril - Symbolic execution
myth analyze src/Contract.sol
# Semgrep - Custom rules
semgrep --config "p/smart-contracts" .
// Foundry fuzz test
function testFuzz_Withdraw(uint256 amount) public {
amount = bound(amount, 1, type(uint128).max);
vm.deal(address(vault), amount);
vault.deposit{value: amount}();
uint256 before = address(this).balance;
vault.withdraw(amount);
assertEq(address(this).balance, before + amount);
}
function invariant_BalancesMatchTotalSupply() public {
uint256 sum = 0;
for (uint i = 0; i < actors.length; i++) {
sum += token.balanceOf(actors[i]);
}
assertEq(token.totalSupply(), sum);
}
| 严重性 | 影响 | 示例 |
|---|---|---|
| 严重 | 直接资金损失 | 重入攻击、未受保护的初始化 |
| 高危 | 重大损害 | 访问控制、预言机操纵 |
| 中危 | 有条件的影响 | 精度损失、时间问题 |
| 低危 | 轻微问题 | 缺少事件、命名问题 |
# Monitor for suspicious activity
cast logs --address $CONTRACT --from-block latest
// Emergency pause
function pause() external onlyOwner {
_pause();
}
| 陷阱 | 风险 | 预防措施 |
|---|---|---|
| 仅测试正常路径 | 遗漏边界情况 | 对边界进行模糊测试 |
| 忽略集成 | 外部调用风险 | 审查所有依赖项 |
| 信任 block.timestamp | 矿工操纵 | 仅用于长时间范围 |
06-smart-contract-securitysolidity-development, defi-protocols| 版本 | 日期 | 变更 |
|---|---|---|
| 2.0.0 | 2025-01 | 生产级,包含工具和方法论 |
| 1.0.0 | 2024-12 | 初始版本 |
每周安装量
162
代码仓库
GitHub 星标数
1
首次出现
2026年1月21日
安全审计
安装于
opencode116
codex109
gemini-cli107
github-copilot100
claude-code93
cursor91
Master smart contract security with vulnerability detection, auditing methodology, and incident response procedures.
# Invoke this skill for security analysis
Skill("smart-contract-security", topic="vulnerabilities", severity="high")
Recognize and prevent:
Systematic review process:
Essential tooling:
Handle security events:
// VULNERABLE
function withdraw(uint256 amount) external {
(bool ok,) = msg.sender.call{value: amount}("");
require(ok);
balances[msg.sender] -= amount; // After call!
}
// FIXED: CEI Pattern
function withdraw(uint256 amount) external {
balances[msg.sender] -= amount; // Before call
(bool ok,) = msg.sender.call{value: amount}("");
require(ok);
}
// VULNERABLE
function setAdmin(address newAdmin) external {
admin = newAdmin; // Anyone can call!
}
// FIXED
function setAdmin(address newAdmin) external onlyOwner {
admin = newAdmin;
}
// VULNERABLE
IERC20(token).transfer(to, amount); // Ignored!
// FIXED: Use SafeERC20
using SafeERC20 for IERC20;
IERC20(token).safeTransfer(to, amount);
// VULNERABLE: Division before multiplication
uint256 fee = (amount / 1000) * rate;
// FIXED: Multiply first
uint256 fee = (amount * rate) / 1000;
# Slither - Fast vulnerability detection
slither . --exclude-dependencies
# Mythril - Symbolic execution
myth analyze src/Contract.sol
# Semgrep - Custom rules
semgrep --config "p/smart-contracts" .
// Foundry fuzz test
function testFuzz_Withdraw(uint256 amount) public {
amount = bound(amount, 1, type(uint128).max);
vm.deal(address(vault), amount);
vault.deposit{value: amount}();
uint256 before = address(this).balance;
vault.withdraw(amount);
assertEq(address(this).balance, before + amount);
}
function invariant_BalancesMatchTotalSupply() public {
uint256 sum = 0;
for (uint i = 0; i < actors.length; i++) {
sum += token.balanceOf(actors[i]);
}
assertEq(token.totalSupply(), sum);
}
| Severity | Impact | Examples |
|---|---|---|
| Critical | Direct fund loss | Reentrancy, unprotected init |
| High | Significant damage | Access control, oracle manipulation |
| Medium | Conditional impact | Precision loss, timing issues |
| Low | Minor issues | Missing events, naming |
# Monitor for suspicious activity
cast logs --address $CONTRACT --from-block latest
// Emergency pause
function pause() external onlyOwner {
_pause();
}
| Pitfall | Risk | Prevention |
|---|---|---|
| Only testing happy path | Missing edge cases | Fuzz test boundaries |
| Ignoring integrations | External call risks | Review all dependencies |
| Trusting block.timestamp | Miner manipulation | Use for long timeframes only |
06-smart-contract-securitysolidity-development, defi-protocols| Version | Date | Changes |
|---|---|---|
| 2.0.0 | 2025-01 | Production-grade with tools, methodology |
| 1.0.0 | 2024-12 | Initial release |
Weekly Installs
162
Repository
GitHub Stars
1
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode116
codex109
gemini-cli107
github-copilot100
claude-code93
cursor91
Lark Mail CLI 使用指南:邮件管理、安全规则与自动化工作流
37,000 周安装
Vibe Coding 指南:用 AI 和自然语言构建软件原型与 MVP 的完整框架
1,200 周安装
腾讯云CloudBase开发指南:一站式云端应用开发与部署解决方案
1,300 周安装
Element Plus Vue3 使用指南:安装、配置、组件详解与问题排查
1,200 周安装
App Store Connect CLI 工作流自动化技能:asc-workflow 命令详解与CI/CD集成指南
1,200 周安装
App Store Connect 自动化创建应用指南:asc-app-create-ui 技能详解
1,200 周安装
内容营销实战指南:23位产品领导者框架,打造高效SEO与品牌内容策略
1,200 周安装