mcpField
F
frontend-security

frontend-security

github.com/schalkneethling安全7432 次安装27 周前更新
代码仓库

关于 frontend-security

frontend-security 用于审计前端代码库中的漏洞和缺失的防护措施,涵盖常见攻击模式、依赖风险检查、严重程度分类及修复建议。

主要功能

  1. 01搜索 XSS 模式
  2. 02检查 CSRF 防护
  3. 03检查 CSP 和输入验证
  4. 04检查依赖中的漏洞
  5. 05按严重程度分类发现
  6. 06提供修复建议

适用场景

  1. 01审计前端代码库
  2. 02检查 React 或 DOM 用法中的 XSS 风险
  3. 03检查表单和请求的 CSRF 风险
  4. 04评估 Node.js 和 npm 依赖

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/schalkneethling/webdev-agent-skills --skill frontend-security

安装后在 Claude Code 中输入/frontend-security确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
csp-configuration.md
csrf-protection.md
dom-security.md
file-upload-security.md
framework-patterns.md
input-validation.md
jwt-security.md
nodejs-npm-security.md
xss-prevention.md

详细介绍

前端安全审计技能

对前端代码库进行全面的安全审计,以识别漏洞、不良实践和缺失的防护措施。

审计流程

  1. 扫描危险模式 - 在代码库中搜索已知的漏洞迹象
  2. 审查框架特定风险 - 检查是否存在绕过框架安全机制的模式
  3. 验证防御措施 - 检查 CSP、CSRF 令牌和输入验证
  4. 检查依赖项 - 审查 npm/node 依赖项是否存在漏洞
  5. 报告发现 - 按严重程度分类,并提供修复建议

需要搜索的严重漏洞模式

XSS 指标(搜索优先级:高)
# React dangerous patterns
grep -rn "dangerouslySetInnerHTML" --include="*.jsx" --include="*.tsx" --include="*.js"

# Direct DOM manipulation
grep -rn "\.innerHTML\s*=" --include="*.js" --include="*.ts" --include="*.jsx" --include="*.tsx"
grep -rn "\.outerHTML\s*=" --include="*.js" --include="*.ts"
grep -rn "document\.write" --include="*.js" --include="*.ts"

# URL-based injection
grep -rn "location\.href\s*=" --include="*.js" --include="*.ts"
grep -rn "location\.replace" --include="*.js" --include="*.ts"
grep -rn "window\.open" --include="*.js" --include="*.ts"

# Eval and code execution
grep -rn "eval\s*(" --include="*.js" --include="*.ts"
grep -rn "new Function\s*(" --include="*.js" --include="*.ts"
grep -rn "setTimeout\s*(\s*['\"]" --include="*.js" --include="*.ts"
grep -rn "setInterval\s*(\s*['\"]" --include="*.js" --include="*.ts"

# Twig unescaped output
grep -rn "|raw" --include="*.twig" --include="*.html.twig"
grep -rn "{% autoescape false %}" --include="*.twig"
CSRF 指标
# Forms without CSRF tokens
grep -rn "<form" --include="*.html" --include="*.jsx" --include="*.tsx" --include="*.twig"

# State-changing requests without protection
grep -rn "fetch\s*(" --include="*.js" --include="*.ts" | grep -E "(POST|PUT|DELETE|PATCH)"
grep -rn "axios\.(post|put|delete|patch)" --include="*.js" --include="*.ts"
敏感数据泄露
# localStorage/sessionStorage with sensitive data
grep -rn "localStorage\." --include="*.js" --include="*.ts"
grep -rn "sessionStorage\." --include="*.js" --include="*.ts"

# Hardcoded secrets
grep -rn "api[_-]?key\s*[:=]" --include="*.js" --include="*.ts" --include="*.env"
grep -rn "secret\s*[:=]" --include="*.js" --include="*.ts"
grep -rn "password\s*[:=]" --include="*.js" --include="*.ts"

参考文档

根据发现的问题加载以下参考资料:

  • 发现 XSS 漏洞:参见 references/xss-prevention.md
  • CSRF 问题:参见 references/csrf-protection.md
  • DOM 操作问题:参见 references/dom-security.md
  • 需要审查 CSP:参见 references/csp-configuration.md
  • 输入处理问题:参见 references/input-validation.md
  • Node.js/NPM 审计:参见 references/nodejs-npm-security.md
  • 框架特定模式:参见 references/framework-patterns.md
  • 文件上传处理:参见 references/file-upload-security.md
  • JWT 实现:参见 references/jwt-security.md

严重程度分类

严重 - 可利用的 XSS、身份验证绕过、机密信息泄露 高 - 缺少 CSRF 防护、不安全的 DOM 操作、SQL 注入攻击向量 中 - CSP 薄弱、缺少安全标头、输入验证不当 低 - 信息泄露、已弃用的函数、欠佳的实践

报告格式

## Security Audit Report

### Summary
- Critical: X findings
- High: X findings
- Medium: X findings
- Low: X findings

### Critical Findings

#### [CRITICAL-001] Title
- **Location**: file:line
- **Pattern**: Code snippet
- **Risk**: Description of the vulnerability
- **Remediation**: How to fix
- **Reference**: OWASP link

### High Findings
[...]

OWASP 参考链接

如需全面的指导,请直接参考以下 OWASP 备忘单:

评论

支持 Markdown