跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
安全

security-engineer

Security-first auditing of AI-generated code — Level 1 quick checks during /toh-dev and /toh-test (hardcoded secrets, dangerous code execution, obvious injection vectors) and Level 2 full audits for /toh-protect (SQL/XSS/command injection, auth and authorization flaws, configuration and dependency risks) with human-readable, actionable fix reports. Use for any security review or before shipping.

wasintoh · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add wasintoh/toh-framework --skill security-engineer

技能说明


name: security-engineer description: > Security-first auditing of AI-generated code — Level 1 quick checks during /toh-dev and /toh-test (hardcoded secrets, dangerous code execution, obvious injection vectors) and Level 2 full audits for /toh-protect (SQL/XSS/command injection, auth and authorization flaws, configuration and dependency risks) with human-readable, actionable fix reports. Use for any security review or before shipping. user-invocable: false # internal — model-invoked via toh-* commands, not a user /command

Security Engineer Skill

Overview

Security-first approach for AI-generated code auditing. Provides both quick checks (during dev/test) and comprehensive audits (full protection).

Core Philosophy

"Trust, but verify - especially AI-generated code"

  1. Proactive Detection - Catch issues before they become vulnerabilities
  2. Layer Defense - Quick checks + Full audits = Maximum coverage
  3. Zero False Sense - Don't trust code just because it "looks safe"
  4. Human-Readable Reports - Clear findings with actionable fixes

Security Check Levels

+-------------------------------------------------------------+
|  LEVEL 1: Quick Check (during /toh-dev, /toh-test)          |
|  - Hardcoded secrets                                        |
|  - Dangerous imports/code execution                         |
|  - Basic auth issues                                        |
|  - Obvious injection vectors                                |
|  Duration: < 5 seconds                                      |
+-------------------------------------------------------------+
                           |
                           v
+-------------------------------------------------------------+
|  LEVEL 2: Full Audit (/toh-protect)                         |
|  - All Level 1 checks                                       |
|  - Injection attacks (SQL, XSS, Command)                    |
|  - Auth/Authorization flaws                                 |
|  - AI-Generated Code risks                                  |
|  - Configuration security                                   |
|  - Dependency vulnerabilities                               |
|  Duration: 30-60 seconds                                    |
+-------------------------------------------------------------+

Level 1: Quick Check Patterns

1.1 Hardcoded Secrets Detection

Detection Patterns:

SECRET_PATTERNS:
  # API Keys
  - Pattern for api_key, apikey with 20+ char values
  - Pattern for sk-live, pk-live, sk-test prefixes

  # AWS
  - Pattern: AKIA followed by 16 alphanumeric chars
  - Pattern for aws_secret values

  # Database URLs
  - Connection strings with embedded credentials

  # Private Keys
  - PEM format key headers

  # JWT Secrets
  - jwt_secret, secret_key patterns

  # Generic passwords
  - password/passwd/pwd assignments

Files to check:

  • **/*.ts, **/*.tsx, **/*.js, **/*.jsx
  • **/*.env* (.env, .env.local, .env.production)
  • **/config/**, **/*.json

Files to IGNORE:

  • **/node_modules/**, **/.git/**
  • **/dist/**, **/build/**
  • **/*.test.*, **/*.spec.*

1.2 Dangerous Code Patterns Detection

CRITICAL - Block immediately:

CRITICAL_PATTERNS:
  # Dynamic code execution
  - String-based code evaluation functions
  - Timer functions with string arguments

  # Dangerous Node.js modules
  - Shell command execution
  - Process spawning with shell mode

  # SQL without parameterization
  - Template literals in SQL statements
  - String concatenation in queries

  # Dangerous HTML rendering
  - React's unsafe HTML rendering attribute
  - Direct HTML content assignment to DOM

WARNING - Review required:

WARNING_PATTERNS:
  # Disabled security
  - ESLint security rule disabling
  - TypeScript strict mode bypasses
  - CORS with wildcard origin

  # Unsafe data handling
  - JSON parsing without validation
  - Deserialization of untrusted data

  # Weak cryptography
  - Deprecated hash algorithms (MD5, SHA1)
  - Non-cryptographic random for security

1.3 Basic Auth Issues

AUTH_PATTERNS:
  # Hardcoded credentials
  - Default admin/root credentials

  # Disabled auth
  - Authentication bypass flags
  - Skip auth configurations

  # Weak session
  - Short session secrets
  - Insecure cookie settings

  # JWT issues
  - None algorithm acceptance
  - Signature verification disabled

Quick Check Output Format

+------------------------------------------------------------+
|  QUICK SECURITY CHECK                                      |
+------------------------------------------------------------+

Scanning: src/**/*.{ts,tsx,js,jsx}

CRITICAL (2 issues - must fix!)
-----------------------------------
1. Hardcoded API Key
   File: src/lib/api.ts:15
   Code: const API_KEY = "sk-live-abc123..."
   Fix:  Use environment variable: process.env.API_KEY

2. SQL Injection Risk
   File: src/api/users.ts:42
   Code: SELECT with template literal interpolation
   Fix:  Use parameterized query: WHERE id = $1

WARNING (1 issue - review recommended)
-----------------------------------
1. Disabled ESLint Security
   File: src/utils/parse.ts:8
   Why:  Security rules should not be disabled

====================================
Summary: 2 critical, 1 warning
Status: BLOCKED - Fix critical issues
====================================

Level 2: Full Audit Patterns

2.1 Injection Attack Detection

SQL Injection

Vulnerable patterns:

  • String concatenation in queries
  • Dynamic table/column names via interpolation
  • Raw queries without ORM parameterization

Safe patterns:

  • Positional placeholders ($1, $2 for PostgreSQL)
  • Question mark placeholders (MySQL/SQLite)
  • Named parameters (various ORMs)

XSS (Cross-Site Scripting)

Vulnerable patterns:

  • Unsafe HTML rendering in React components
  • Direct DOM HTML content manipulation
  • User input in dynamical
阅读完整来源 ↗