Security Audit Skill 是一个全面的安全审计工具,覆盖代码静态分析(SAST)、动态测试(DAST)、依赖检查(SCA)和服务器配置审计。
用途
该技能用于对项目进行安全审计,适用于代码漏洞扫描、依赖安全检查以及服务器安全配置审计等场景。
工作流程
安全审计遵循以下步骤:
- 环境检测:识别项目类型和技术栈
- 依赖检查:扫描第三方库漏洞(优先级最高)
- 静态代码分析:SAST 扫描源代码漏洞
- 敏感信息检测:扫描硬编码的密钥和凭证
- 配置审计:检查安全相关配置
- 生成报告:汇总发现并提供修复建议
快速开始
依赖安装
安装核心 Python 扫描工具:
pip install safety bandit semgrep pip-audit --break-system-packages
安装 Node.js 安全工具(如需要):
npm install -g npm-audit-html retire
一键全面扫描
运行综合扫描脚本:
python3 /path/to/skill/scripts/full_scan.py /path/to/project
检测能力
高危漏洞(Critical)
| 漏洞类型 | CVE 示例 | 检测方式 |
|---|---|---|
| React2Shell RCE | CVE-2025-55182 | 依赖版本检查 |
| Next.js RCE | CVE-2025-66478 | 依赖版本检查 |
| Log4Shell | CVE-2021-44228 | 依赖版本检查 |
| SQL 注入 | CWE-89 | SAST + 模式匹配 |
| 命令注入 | CWE-78 | SAST + 模式匹配 |
OWASP Top 10 2024
- A01: Broken Access Control - 访问控制缺陷
- A02: Cryptographic Failures - 加密失败
- A03: Injection - 注入攻击(SQL/XSS/Command)
- A04: Insecure Design - 不安全设计
- A05: Security Misconfiguration - 安全配置错误
- A06: Vulnerable Components - 易受攻击的组件
- A07: Authentication Failures - 身份认证失败
- A08: Software Integrity Failures - 软件完整性失败
- A09: Logging Failures - 日志记录失败
- A10: SSRF - 服务端请求伪造
扫描工具使用
Python 项目
Bandit - Python SAST:
bandit -r ./src -f json -o bandit_report.json
Safety - 依赖漏洞检查:
safety check --json > safety_report.json
pip-audit - 依赖审计:
pip-audit --format json > pip_audit.json
JavaScript/Node.js 项目
npm audit - 依赖漏洞:
npm audit --json > npm_audit.json
Retire.js - 检测过时库:
retire --js --outputformat json > retire_report.json
React/Next.js 特别检查(CVE-2025-55182):
npx fix-react2shell-next --check-only
通用检测
Semgrep - 多语言 SAST:
semgrep scan --config=auto --json > semgrep_report.json
Gitleaks - 密钥泄露检测:
gitleaks detect --source . --report-format json --report-path gitleaks.json
Trivy - 容器/依赖扫描:
trivy fs --format json --output trivy.json .
服务器安全检查
SSH 配置审计
grep -E "^(PermitRootLogin|PasswordAuthentication|PubkeyAuthentication)" /etc/ssh/sshd_config
防火墙状态
UFW 状态:
sudo ufw status verbose
iptables 规则:
sudo iptables -L -n -v
权限检查
查找 SUID 文件:
find / -perm -4000 -type f 2>/dev/null
检查 world-writable 文件:
find / -perm -002 -type f 2>/dev/null
修复建议
React2Shell 漏洞修复(CVE-2025-55182)
受影响版本:
- React 19.0, 19.1.0, 19.1.1, 19.2.0
- Next.js ≥14.3.0-canary.77, ≥15, ≥16
修复步骤:
使用官方修复工具:
npx fix-react2shell-next
或手动升级:
- Next.js 15.x -> 升级到 15.1.4+
- Next.js 14.x -> 降级到稳定 14.x 版本
修复后必做:
- 轮换所有应用密钥(特别是 2024 年 12 月 4 日后暴露的)
- 检查是否有异常进程或网络连接
常见漏洞修复参考详见 references/remediation_guide.md。
报告格式
扫描完成后生成的报告包含:
security_report/
├── summary.md # 执行摘要
├── critical.json # 高危漏洞
├── dependencies.json # 依赖漏洞
├── code_issues.json # 代码问题
├── secrets.json # 泄露的密钥
└── recommendations.md # 修复建议
最佳实践
- 每次提交前运行快速扫描
- 每日运行依赖漏洞检查
- 每周运行完整安全审计
- 将扫描集成到 CI/CD 流水线
- 订阅安全公告(如 CVE、NVD)
- 定期更新扫描工具和规则库
参考资料
- 详细漏洞检测规则:references/detection_rules.md
- 修复指南:references/remediation_guide.md
- 服务器加固:references/server_hardening.md