360 Secure SkillHub
360 安全技能中心

Missing Input Validation

面向代码安全评审的规则文档,列出外部输入未经校验即用于敏感操作的常见症状,并给出在信任边界校验类型、结构与范围、使用 schema 校验器、参数化查询或 argv 数组等修复建议。

mvogt99
mvogt99
热度 41.13
最近更新 2026-05-11 17:46:01
分类:安全依赖:纯提示词应用场景:代码审查 / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add missing-input-validation
Metadata
name
missing-input-validation
description
External input flows into sensitive operations without being checked for type, shape, range, or sanitization.
emoji
🛡️
metadata
{"clawdis":{"os":["macos","linux","windows"]}}

missing-input-validation

Any data from outside the process — HTTP request bodies, CLI args, file contents, third-party API responses, user messages — should be treated as untrusted until proven otherwise. Code that uses it directly opens injection, crash, and security paths.

Symptoms

  • HTTP handler uses request.body.x with no type check.
  • CLI flag value passed straight into exec, SQL, or a file path.
  • Third-party API response fields accessed without confirming they exist.
  • Numeric input used in array indexing or arithmetic with no bounds check.
  • String input concatenated into SQL, shell commands, or file paths.

What to do

  • At every trust boundary, validate type, shape, and range before using the value. Reject early with a clear error message.
  • For structured payloads, use a schema validator (Zod, Pydantic, ArkType, etc.) — don't hand-write "if field exists".
  • For values used in SQL, shell, or file paths, use parameterized queries, execFile with an argv array, or explicit path joins — never string concatenation.
  • When an invariant is checked, include the unexpected value in the error so debugging is possible.
  • Third-party responses are not trustworthy. Validate them the same way you'd validate user input.