Implement API schema validation using OpenAPI specifications and JSON Schema to enforce input/output contracts and prevent injection, data exposure, and mass assignment attacks.
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.
Implement API schema validation using OpenAPI specifications and JSON Schema to enforce input/output contracts and prevent injection, data exposure, and mass assignment attacks.
API schema validation enforces that all data exchanged through APIs conforms to a predefined structure defined in OpenAPI Specification (OAS) or JSON Schema documents. This prevents injection attacks (SQLi, XSS, XXE), blocks mass assignment by rejecting unknown properties, prevents data leakage by validating response schemas, and ensures type safety across all API interactions. Schema validation operates at both the API gateway level (runtime enforcement) and during development (shift-left security).
When to Use
When deploying or configuring implementing api schema validation security capabilities in your environment
When establishing security controls aligned to compliance requirements
When building or improving security architecture for this domain
When conducting security assessments that require this implementation
Common Misconfigurations & Verification
additionalProperties missing or true: the single most common gap - without additionalProperties: false, mass-assignment fields pass validation; set it on every object schema.
Request-only validation: validating input but not responses lets excessive-data-exposure through; validate/serialize responses with explicit DTOs.
Loose constraints: strings without maxLength/pattern and fields without enum permit injection and DoS payloads.
readOnly not enforced server-side: clients can still write readOnly fields if the server only documents them rather than rejecting them.
Permissive/verbose errors: leaking schema detail in 400 responses aids attackers.
Spec drift: the deployed schema lagging the live API leaves new endpoints unvalidated.
How to verify it works: send a request with an extra/unknown field and confirm 400 (not silent acceptance); submit over-long and pattern-violating values and confirm rejection; attempt to set a readOnly field and confirm it is ignored; force a sensitive field into a response and confirm response validation strips it or fails safely; diff the enforced spec against the live route list.
Prerequisites
OpenAPI Specification v3.0 or v3.1 for all API endpoints
API gateway with schema validation support (Cloudflare API Shield, Kong, AWS API Gateway)
JSON Schema draft-07 or later understanding
Development environment with OpenAPI validation libraries
CI/CD pipeline for automated schema compliance testing