Secure input validation at trust boundaries: allowlists, schemas, type and range checks, normalization, and fail-closed parsing. Use when input validation, 输入校验, request validation, allowlist, schema validation, boundary checks, sanitize vs validate, or hardening untrusted parameters, headers, files, and event payloads. Complements code-quality-standards and json-schema-design; not a substitute for injection-class testing skills.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Secure input validation at trust boundaries: allowlists, schemas, type and range checks, normalization, and fail-closed parsing. Use when input validation, 输入校验, request validation, allowlist, schema validation, boundary checks, sanitize vs validate, or hardening untrusted parameters, headers, files, and event payloads. Complements code-quality-standards and json-schema-design; not a substitute for injection-class testing skills.
Input Validation Patterns
Validate untrusted data at trust boundaries before it drives control flow,
queries, storage, or downstream calls. Prefer allowlists and schemas over
ad-hoc reject lists. Repository validators, OpenAPI/JSON Schema contracts, and
framework middleware outrank generic defaults in this skill.
This skill is defensive secure coding for systems you own or are authorized
to harden. It does not teach bypassing third-party validation or weaponizing
injection against systems outside scope.
Use When
Designing or reviewing request/query/path/header/cookie/body validation
Choosing allowlist vs denylist, enums, formats, and size/depth caps
Placing validation at API gateways, controllers, workers, CLI, or file parsers
Aligning runtime checks with OpenAPI / JSON Schema / Protobuf / form DTOs
Hardening file upload metadata, multiparts, webhooks, or queue/event payloads
Fixing bugs where invalid or hostile input caused crashes, logic flaws, or injection
General reliability, errors, tests, security baseline
code-quality-standards
Unknown injection class in an assessment
injection-checking
SQLi / XSS / SSRF / CMDi / path traversal testing
matching class skill
Secrets in env/config (not request body validation)
secrets-management-hygiene
Mass assignment / over-posting as authz issue
mass-assignment
Repo Config First
Repo contracts, middleware, and neighboring validators outrank this skill.
Source of truth: OpenAPI/JSON Schema, Protobuf, GraphQL schema, or
code-first DTOs — edit the authoritative layer; do not invent a parallel rule set
Validator stack: Zod, AJV, Joi, Yup, Pydantic, class-validator, Bean
Validation, FluentValidation, serde with deny-unknown — match project options
(strict objects, coerce on/off, format assertion)
Framework middleware: Nest pipes, Django/DRF serializers, Spring
@Valid, ASP.NET model binding + data annotations, Express/Fastify schema
plugins, API gateway request validators — extend existing pipeline order
Error envelope: existing 400/422 shape, field-path conventions, i18n of
validation messages — reuse, do not invent a second client contract
Size limits: reverse-proxy body limits, framework max body, multipart
caps, and gateway policies already deployed
Authn/authz placement: validation does not replace authorization;
follow how the repo orders parse → authenticate → authorize → handler
Neighboring handlers: copy 2–3 mature endpoints’ parse, reject, and
log patterns before adding a one-off style
Shared libs: monorepo validation packages, branded ID types, common
pagination/filter schemas — reuse them
Precedence: If repo rules conflict with defaults below, follow the repo.
Surface conflicts that accept unbounded input, skip validation on some routes,
or document stricter rules than runtime enforces.
Core Principles
Principle
Practice
Boundary first
Validate at every trust boundary (HTTP edge, worker entry, admin import, webhook)
Allowlist over denylist
Accept known-good types, enums, patterns, and shapes; do not chase every bad string
Schema as contract
Types, requiredness, bounds, and openness match published API/events
Fail closed
Reject invalid input; never “best effort” into privileged paths
Normalize then validate
Canonicalize encoding/path/Unicode before checks when the domain requires it
Validate ≠ authorize
Schema-valid resourceId does not mean the caller may access it
Validate ≠ encode
Validation reduces bad shapes; output encoding and parameterized APIs stop injection
Bound resources
Cap length, count, depth, and upload size to resist DoS
Single parse
Parse once to a typed model; avoid re-parsing raw strings with different rules later
Preserve intent
Prefer structured fields over free-text when the domain is structured
Do not disable schema strictness or linters to “ship faster” without tracked exception
Keep validation pure and side-effect free when possible (authz stays separate)
Routing to json-schema-design
Use json-schema-design when the work is primarily contract shape
(OpenAPI components, $ref, nullability, evolution). Use this skill for
boundary placement, allowlists for control-plane fields (sort, redirect,
file names), normalization order, and how validation interacts with authz and
encoding.
Routing to output-encoding-patterns
Validation reduces unexpected shapes; it does not make string concatenation
into SQL or HTML safe. Pair both skills on features that accept text and render
or query with it.
Checklist
Repo validator stack, schema SSOT, error envelope, and body size limits identified
All trust boundaries listed (HTTP, workers, webhooks, imports, CLI)
Schemas/DTOs cover each public input; strict/closed objects where policy requires
Allowlists for enums, sort/filter keys, redirects, content types, ops actions
Length, count, depth, and upload size caps set and aligned with proxy limits
Normalization defined where needed (path, Unicode, host) before security checks
Fail closed with stable 400/422 (or equivalent); no stack/SQL leakage
Typed models only past the boundary; no raw maps driving queries/templates
Authz checks on object IDs after authentication (not assumed from schema validity)
Webhooks: signature verified and payload schema-validated
Positive + negative boundary tests; oversize and unknown-field cases included
No denylist-only “sanitizer” as the primary control for injection classes
Output encoding / parameterized APIs planned for sinks (output-encoding-patterns)
json-schema-design used when publishing or evolving formal contracts
code-quality-standards applied for implementation quality, errors, and tests
Rules
Untrusted input is hostile until validated; trusted internal types stay internal.
Allowlist what you accept; bound what you cannot fully enumerate (free text).
One parse, one schema, one typed value — then business logic.
Validation is necessary and not sufficient: encode on output, parameterize queries, authorize always.
Repo contracts and middleware win; this skill fills gaps and review discipline.
Defensive engineering and authorized hardening only.
Note
This skill owns inbound validation and allowlist discipline at trust
boundaries. Pair with json-schema-design for formal contracts,
output-encoding-patterns for sink-safe rendering and query construction, and
code-quality-standards on every implementation change.