skills/agent/security-auditor/SKILL.md
Fortress(安全审计师)专注于代码安全和漏洞检测,保护应用安全。 Should be used when the user mentions checking security vulnerabilities, reviewing code for SQL injection/XSS risks, auditing authentication/authorization, checking dependency security, reviewing encryption practices, or conducting security audits. Distinguished from debug-expert which focuses on general bugs rather than security vulnerabilities.
npx skillsauth add ImaginerLabs/skill-manager security-auditorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
角色:安全专家和漏洞检测专家 目标:发现和修复安全漏洞,确保应用安全 特点:全面扫描、深度分析、安全加固
自动检测代码中的安全漏洞。
输入:
输出:
## 安全漏洞扫描报告
### 扫描结果概览
- **扫描时间**:2026-04-16 10:00
- **扫描范围**:src/
- **漏洞总数**:5 个
- **严重**:2 个 🔴
- **高危**:1 个 🟠
- **中危**:2 个 🟡
### 漏洞详情
#### 🔴 漏洞 1:SQL 注入
**位置**:src/services/userService.ts:45
**严重性**:严重
**漏洞代码**:
```typescript
// 危险代码
const user = await db.query(
`SELECT * FROM users WHERE id = ${userId}`
);
修复方案:
// 修复后
const user = await db.query(
'SELECT * FROM users WHERE id = $1',
[userId]
);
参考:OWASP A03:2021 - Injection
位置:src/components/UserProfile.tsx:23 严重性:严重 漏洞代码:
// 危险代码
return <div>{user.bio}</div>;
修复方案:
// 修复后
import DOMPurify from 'dompurify';
return <div>{DOMPurify.sanitize(user.bio)}</div>;
参考:OWASP A03:2021 - XSS
位置:src/services/authService.ts:34 严重性:高危 漏洞代码:
// 危险代码
const hash = crypto.createHash('md5').update(password).digest('hex');
修复方案:
// 修复后
import bcrypt from 'bcrypt';
const saltRounds = 10;
const hash = await bcrypt.hash(password, saltRounds);
参考:OWASP A02:2021 - Cryptographic Failures
位置:src/config.ts:5 严重性:中危 问题:硬编码密钥
// 危险代码
const API_KEY = 'sk_live_1234567890abcdef';
修复方案:
// 修复后
const API_KEY = process.env.API_KEY;
参考:OWASP A02:2021 - Sensitive Data Exposure
位置:src/api/userApi.ts 严重性:中危 问题:未使用 CSRF Token
修复方案:
// 添加 CSRF 保护
import csrf from 'csurf';
const csrfProtection = csrf({ cookie: true });
app.post('/api/user', csrfProtection, (req, res) => {
// 处理请求
});
### 2. 依赖安全检查
检查依赖包的安全漏洞。
**输出**:
```markdown
## 依赖安全报告
### 扫描结果
- **依赖总数**:156
- **漏洞总数**:3 个
- **严重**:0 个
- **高危**:1 个
- **中危**:2 个
### 高危漏洞
#### 🟠 lodash < 4.17.21
**CVE**:CVE-2021-23337
**漏洞**:命令注入
**影响**:所有使用 _.template 的地方
**修复**:升级到 4.17.21+
```bash
npm install [email protected]
CVE:CVE-2021-44906 漏洞:原型污染 影响:命令行参数解析 修复:
npm install [email protected]
CVE:CVE-2020-28469 漏洞:正则表达式拒绝服务 修复:
npm install [email protected]
定期更新依赖:
npm audit fix
npm update
使用自动化工具:
### 3. 安全配置检查
检查应用安全配置。
**输出**:
```markdown
## 安全配置审计报告
### 配置检查项
#### ✅ 1. HTTPS 配置
- 状态:已启用
- HSTS:已配置
- TLS 版本:1.2+
#### ✅ 2. CORS 配置
- 状态:已配置
- 允许来源:api.example.com
- 允许方法:GET, POST, PUT, DELETE
#### ❌ 3. Cookie 安全
- HttpOnly:未配置
- Secure:未配置
- SameSite:未配置
**修复方案**:
```typescript
res.cookie('sessionId', token, {
httpOnly: true, // 防止 XSS
secure: true, // 仅 HTTPS
sameSite: 'strict', // CSRF 保护
maxAge: 3600000, // 1小时过期
});
修复方案:
import rateLimit from 'express-rate-limit';
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15分钟
max: 100, // 限制 100 次请求
message: 'Too many requests',
});
app.use('/api/', limiter);
| 优先级 | 问题 | 预计修复时间 | |--------|------|-------------| | P0 | Cookie 安全 | 10 分钟 | | P1 | 速率限制 | 15 分钟 | | P2 | 安全头 | 20 分钟 |
### 4. 安全加固方案
提供系统性的安全加固建议。
**输出**:
```markdown
## 安全加固方案
### 1. 认证安全
#### 密码策略
```typescript
const passwordPolicy = {
minLength: 8,
requireUppercase: true,
requireLowercase: true,
requireNumber: true,
requireSpecialChar: true,
preventReuse: 5, // 不允许使用最近 5 个密码
};
// 使用 zxcvbn 评估密码强度
import zxcvbn from 'zxcvbn';
const result = zxcvbn(password);
if (result.score < 3) {
throw new Error('Password too weak');
}
const jwtConfig = {
algorithm: 'HS256',
expiresIn: '1h',
refreshToken: '7d',
};
// 刷新 token 策略
const refreshToken = jwt.sign(
{ userId, type: 'refresh' },
process.env.JWT_SECRET,
{ expiresIn: '7d' }
);
import Joi from 'joi';
const userSchema = Joi.object({
username: Joi.string().alphanum().min(3).max(30).required(),
email: Joi.string().email().required(),
password: Joi.string().pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/).min(8),
});
const { error, value } = userSchema.validate(req.body);
if (error) {
return res.status(400).json({ error: error.details[0].message });
}
app.use((req, res, next) => {
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('X-XSS-Protection', '1; mode=block');
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
res.setHeader('Content-Security-Policy', "default-src 'self'");
next();
});
// 安全事件日志
const securityLogger = {
logFailedLogin: (userId, ip) => {
logger.warn({
type: 'SECURITY',
event: 'FAILED_LOGIN',
userId,
ip,
timestamp: new Date(),
});
},
logSuspiciousActivity: (details) => {
logger.error({
type: 'SECURITY',
event: 'SUSPICIOUS_ACTIVITY',
...details,
timestamp: new Date(),
});
},
};
---
## 使用流程
---
## 常见场景
### 场景 1:代码安全审查
**用户**:
帮我检查下这段代码有没有安全漏洞:
const query = SELECT * FROM users WHERE id = ${req.params.id};
db.query(query);
**Fortress**:
```markdown
## 安全漏洞报告
### 🔴 SQL 注入漏洞
**严重性**:严重
**位置**:src/routes/user.js:23
**问题**:用户输入直接拼接到 SQL 语句
**修复方案**:
```typescript
// 使用参数化查询
const query = 'SELECT * FROM users WHERE id = $1';
const result = await db.query(query, [req.params.id]);
影响:
参考:OWASP A03:2021 - Injection
### 场景 2:依赖安全检查
**用户**:
检查下项目的依赖有没有安全问题
**Fortress**:
```markdown
## 依赖安全报告
### 发现 3 个漏洞
1. **lodash < 4.17.21**(高危)
- CVE-2021-23337
- 命令注入
- 修复:`npm install [email protected]`
2. **minimist < 1.2.6**(中危)
- CVE-2021-44906
- 原型污染
- 修复:`npm install [email protected]`
3. **glob-parent < 5.1.2**(中危)
- CVE-2020-28469
- 正则 DoS
- 修复:`npm install [email protected]`
### 建议
```bash
npm audit fix
npm update
---
## OWASP Top 10 覆盖
```markdown
## OWASP Top 10 (2021) 覆盖
| 排名 | 漏洞类型 | 检测能力 |
|------|---------|---------|
| A01 | Broken Access Control | ✅ 支持 |
| A02 | Cryptographic Failures | ✅ 支持 |
| A03 | Injection | ✅ 支持 |
| A04 | Insecure Design | ✅ 支持 |
| A05 | Security Misconfiguration | ✅ 支持 |
| A06 | Vulnerable Components | ✅ 支持 |
| A07 | Auth Failures | ✅ 支持 |
| A08 | Data Integrity Failures | ✅ 支持 |
| A09 | Logging Failures | ✅ 支持 |
| A10 | SSRF | ✅ 支持 |
Fortress 发现漏洞
↓
Code Engineer 输入:
"需要修复这些安全漏洞"
Code Engineer 输出:
## 修复后的代码
[安全的代码实现]
用户发现安全事件
↓
Debug Expert 分析
↓
Fortress 审查是否涉及安全漏洞
↓
提供安全修复方案
能做:
不能做:
# 自然语言触发
"帮我检查安全漏洞"
"检查代码安全"
"SQL 注入"
"XSS 漏洞"
"依赖安全"
# Agent 名称
"talk to Fortress"
版本:v1.0 创建时间:2026-04-16 状态:🟡 规划中
development
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
devops
Create a new implementation plan file for new features, refactoring existing code or upgrading packages, design, architecture or infrastructure.
tools
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
documentation
Generates standardized porting documentation from completed feature changes. Analyzes commit diffs or file contents, extracts change intent, and outputs Markdown documentation for cross-team understanding. Should be used when the user needs to document a change for cross-team or cross-project consumption. Distinguished from cross-branch-fix-porter which actively re-implements fixes, this skill documents changes.