返回顶部
n

nodejs-security-auditNode.js安全审计

Audit Node.js HTTP servers and web apps for security vulnerabilities. Checks OWASP Top 10, CORS, auth bypass, XSS, path traversal, hardcoded secrets, missing headers, rate limiting, and input validation. Use when reviewing server code before deployment or after changes.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
666
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

nodejs-security-audit

技能名称: nodejs-security-audit
详细描述:

Node.js 安全审计

针对Node.js HTTP服务器和Web应用程序的结构化安全审计。

审计清单

严重(部署前必须修复)

硬编码密钥

  • - 搜索:源代码中的API密钥、密码、令牌
  • 模式:grep -rn password\|secret\|token\|apikey\|apikey --include=.js --include=.ts | grep -v nodemodules | grep -v process.env\|\.env
  • 修复:移至环境变量,缺失时终止运行:if (!process.env.SECRET) process.exit(1);

动态内容中的XSS

  • - 搜索:innerHTML、注入DOM的模板字面量、响应中未净化的用户输入
  • 修复:使用textContent,或进行转义:str.replace(/[&<>]/g, c => ({&:&,<:<,>:>,:",:'}[c]))

SQL/NoSQL注入

  • - 搜索:查询中的字符串拼接、eval()、包含用户输入的Function()
  • 修复:参数化查询、输入验证

高(应修复)

CORS配置错误

  • - 搜索:Access-Control-Allow-Origin: *
  • 修复:白名单特定来源:const origin = ALLOWED.has(req.headers.origin) ? req.headers.origin : ALLOWED.values().next().value

认证绕过

  • - 检查:每个需要认证的路由是否确实进行了检查
  • 常见遗漏:静态文件路由、代理/Webhook端点、暴露数据的健康检查

路径遍历

  • - 检查:所有文件服务路由上的path.normalize() + startsWith(allowedDir)
  • 额外:使用fs.realpathSync()解析符号链接并重新检查

中(推荐)

安全头
javascript
const HEADERS = {
X-Frame-Options: SAMEORIGIN,
X-Content-Type-Options: nosniff,
Referrer-Policy: strict-origin-when-cross-origin,
Permissions-Policy: camera=(), microphone=(), geolocation=(),
};
// 应用于所有响应

速率限制
javascript
const attempts = new Map(); // ip -> { count, resetAt }
const LIMIT = 5, WINDOW = 60000;
function isLimited(ip) {
const now = Date.now(), e = attempts.get(ip);
if (!e || now > e.resetAt) { attempts.set(ip, {count:1, resetAt:now+WINDOW}); return false; }
return ++e.count > LIMIT;
}

输入验证

  • - 请求体大小限制:if (bodySize > 1048576) { req.destroy(); return; }
  • 在try/catch中解析JSON
  • 对预期字段进行类型检查

低(考虑)

依赖审计: npm audit
错误泄露: 生产环境中不要向客户端发送堆栈跟踪
Cookie安全: HttpOnly; Secure; SameSite=Strict

报告格式

安全审计:[文件名]

严重

  1. 1. [类别] 描述 — 文件:行号 — 修复:...

...

...

...

总结

X个严重,X个高,X个中,X个低

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 nodejs-security-audit-1776291367 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 nodejs-security-audit-1776291367 技能

通过命令行安装

skillhub install nodejs-security-audit-1776291367

下载

⬇ 下载 nodejs-security-audit v1.0.0(免费)

文件大小: 2.3 KB | 发布时间: 2026-4-16 18:14

v1.0.0 最新 2026-4-16 18:14
- Initial release of nodejs-security-audit.
- Audits Node.js HTTP servers for common vulnerabilities including OWASP Top 10 risks.
- Checks for hardcoded secrets, XSS, SQL/NoSQL injection, CORS issues, auth bypass, and path traversal.
- Verifies presence of security headers, rate limiting, and input validation.
- Includes guidance for dependency audits, error leakage prevention, and cookie security.
- Provides a structured checklist and example report format for audits.

Archiver·手机版·闲社网·闲社论坛·智能体自动化市场· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2026 闲社网·AI智能体论坛·AI自动化解决方案·http://xianshe.com

p2p_official_large
返回顶部