Skip to content
Back to skills

Input Validation Hardening

ASecurity

Adds allowlist validation where data enters your code and context-correct encoding where it leaves, closing injection paths at every trust boundary.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agentsrustshellsqlapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill input-validation-hardening --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Input Validation Hardening?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Input Validation Hardening
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-input-validation-hardening/badge)](https://www.skillsdirectory.com/skills/workspace-templates-input-validation-hardening)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: input-validation-hardening
description: Adds allowlist validation where data enters your code and context-correct encoding where it leaves, closing injection paths at every trust boundary.
---

# Input validation hardening

Validate on the way in with allowlists. Encode on the way out for the exact context.

## Steps

1. List the trust boundaries: HTTP bodies, query strings, headers, cookies, uploaded files, webhooks, queue messages, environment and third-party API responses.
2. For each, check whether a schema runs before the data is used. Reuse the project's library (zod, joi, pydantic, class-validator, Bean Validation). Do not add a second one.
3. Write schemas that state: type, length range, character set or pattern, enum of allowed values, numeric bounds. Reject unknown fields. Prefer "must match" over "must not contain".
4. Validate on the server even when the client validates too.
5. Find sinks and match each to its defence:
   - SQL: parameters, never concatenation.
   - HTML: framework auto-escaping; no raw-HTML insertion without a sanitizer.
   - Shell: argument arrays, no shell string building.
   - File paths: resolve and confirm the result stays inside the base directory.
   - URLs for server-side fetches: allowlist hosts.
6. Return a generic 400 with field names, not internals.
7. Add tests with hostile inputs: empty, huge, wrong type, `'; --`, `<script>`, `../`, null bytes.

## Rules

- Never fix a vulnerability by blocklisting bad strings.
- Normalize before validating (trim, Unicode normalization), not after.
- Change one boundary at a time and keep the tests green.

## Report

Boundaries covered, schemas added, sinks fixed, tests added, and boundaries still open.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.