Agent Skills
› aiming-lab/MetaClaw
› input-validation-and-sanitization
input-validation-and-sanitization
GitHub提供输入验证与清洗的最佳实践,涵盖API、表单及CLI等边界处的数据校验原则。重点指导防止SQL注入、XSS攻击及路径遍历的具体措施,强调使用白名单和参数化查询以确保系统安全。
Trigger Scenarios
实现接收外部输入的端点或函数
处理用户提交的数据前进行安全校验
防范SQL注入或XSS攻击
Install
npx skills add aiming-lab/MetaClaw --skill input-validation-and-sanitization -g -y
SKILL.md
Frontmatter
{
"name": "input-validation-and-sanitization",
"category": "security",
"description": "Use this skill when implementing any endpoint, form handler, CLI tool, or function that accepts external input. Validate and sanitize all untrusted data before processing — never assume input is safe."
}
Input Validation and Sanitization
Validation principles:
- Validate at the system boundary (API layer, form handler) — not deep in business logic.
- Validate type, range, length, and format explicitly.
- Reject unexpected input by default (allowlist > denylist).
SQL injection prevention: Always use parameterized queries or an ORM.
XSS prevention: Escape HTML output; use Content-Security-Policy headers; avoid innerHTML with user data.
Path traversal prevention: Resolve paths to canonical form and verify they are under the expected directory.
import os
base = '/allowed/dir'
canonical = os.path.realpath(os.path.join(base, user_input))
assert canonical.startswith(base + os.sep)
Version History
- 922caf3 Current 2026-07-25 11:08


