← 返回
安全合规 中文

Node.js Security Audit

Audit Node.js HTTP servers and web apps for security vulnerabilities. Checks OWASP Top 10, CORS, auth bypass, XSS, path traversal, hardcoded secrets, missing...
审计 Node.js HTTP 服务器和 Web 应用安全漏洞,检查 OWASP Top 10、CORS、身份验证绕过、XSS、路径遍历、硬编码密钥、缺失...
npfaerber
安全合规 clawhub v1.0.0 1 版本 99912.7 Key: 无需
★ 0
Stars
📥 1,144
下载
💾 334
安装
1
版本
#audit#latest#nodejs#owasp#security

概述

Node.js Security Audit

Structured security audit for Node.js HTTP servers and web applications.

Audit Checklist

Critical (Must Fix Before Deploy)

Hardcoded Secrets

  • Search for: API keys, passwords, tokens in source code
  • Pattern: grep -rn "password\|secret\|token\|apikey\|api_key" --include=".js" --include=".ts" | grep -v node_modules | grep -v "process.env\|\.env"
  • Fix: Move to env vars, fail if missing: if (!process.env.SECRET) process.exit(1);

XSS in Dynamic Content

  • Search for: innerHTML, template literals injected into DOM, unsanitized user input in responses
  • Fix: Use textContent, or escape: str.replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":"'"}[c]))

SQL/NoSQL Injection

  • Search for: String concatenation in queries, eval(), Function() with user input
  • Fix: Parameterized queries, input validation

High (Should Fix)

CORS Misconfiguration

  • Search for: Access-Control-Allow-Origin: *
  • Fix: Allowlist specific origins: const origin = ALLOWED.has(req.headers.origin) ? req.headers.origin : ALLOWED.values().next().value

Auth Bypass

  • Check: Every route that should require auth actually checks it
  • Common miss: Static file routes, agent/webhook endpoints, health checks that expose data

Path Traversal

  • Check: path.normalize() + startsWith(allowedDir) on all file-serving routes
  • Extra: Resolve symlinks with fs.realpathSync() and re-check

Medium (Recommended)

Security Headers

const HEADERS = {
  'X-Frame-Options': 'SAMEORIGIN',
  'X-Content-Type-Options': 'nosniff',
  'Referrer-Policy': 'strict-origin-when-cross-origin',
  'Permissions-Policy': 'camera=(), microphone=(), geolocation=()',
};
// Apply to all responses

Rate Limiting

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;
}

Input Validation

  • Body size limits: if (bodySize > 1048576) { req.destroy(); return; }
  • JSON parse in try/catch
  • Type checking on expected fields

Low (Consider)

Dependency Audit: npm audit

Error Leakage: Don't send stack traces to clients in production

Cookie Security: HttpOnly; Secure; SameSite=Strict

Report Format

## Security Audit: [filename]

### Critical
1. **[Category]** Description — File:Line — Fix: ...

### High
...

### Medium
...

### Low
...

### Summary
X critical, X high, X medium, X low

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 17:51 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Token Cost Estimator

npfaerber
从 OpenClaw 会话记录估算 API token 费用。分析所有代理会话,计算按 token 计费与订阅方案的花费差异。
★ 2 📥 799
security-compliance

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,586
security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,698