Input validation and sanitization

From aiming-lab/MetaClaw · View interactive version

Input validation and sanitization is an AI agent skill from the GitHub repository aiming-lab/MetaClaw. 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.

How to use this skill

Skill file

Input Validation and Sanitization

Validation principles:

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)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.