मुख्य सामग्री पर जाएँ
Skillpedia
सिक्योरिटी35k · #7989

implementing-api-schema-validation-security

यह क्या करती है

यह टूल सुनिश्चित करता है कि APIs में आपस में भेजा जाने वाला डेटा एक सटीक format का पालन करे। यह code injection जैसे हमलों को रोकता है और संवेदनशील जानकारी के लीक होने या अनचाहा डेटा जुड़ने से बचाता है।

कब इस्तेमाल करें

  • ✓API सुरक्षा कॉन्फ़िगर करते समय।
  • ✓सुरक्षा compliance की ज़रूरतें पूरी करने के लिए।
  • ✓सिस्टम की सुरक्षा architecture बनाते या सुधारते समय।

Skill का लिंक

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-api-schema-validation-security/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-api-schema-validation-security/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरी API के लिए schema validation कॉन्फ़िगर करो ताकि हमले रुकें।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह API में आने और बाहर जाने वाले डेटा के लिए साफ़ नियम (schemas) तय करता है। एक सुरक्षा प्रणाली जाँचती है कि डेटा इन नियमों का पालन करता है या नहीं, और जो पालन नहीं करता उसे ब्लॉक कर देती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Implementing API Schema Validation Security

Overview

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

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

Core Implementation

OpenAPI Schema with Security Constraints

openapi: 3.1.0
info:
  title: Secure E-Commerce API
  version: 2.0.0
servers:
  - url: https://api.example.com/v2
    description: Production (HTTPS enforced)
security:
  - OAuth2:
      - read:products
      - write:orders

paths:
  /products:
    post:
      operationId: createProduct
      security:
        - OAuth2: [write:products]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCreate'
      responses:
        '201':
          description: Product created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'

  /products/{productId}:
    get:
      operationId: getProduct
      parameters:
        - name: productId
          in: path
          required: true
          schema:
            type: string
            format: uuid
            pattern: '^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'

components:
  schemas:
    ProductCreate:
      type: object
      required: [name, price, category]
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 200
          pattern: '^[a-zA-Z0-9\s\-\.]+$'  # No special chars for injection prevention
        description:
          type: string
          maxLength: 2000
          # Sanitize HTML entities
        price:
          type: number
          format: float
          minimum: 0.01
          maximum: 999999.99
          exclusiveMinimum: 0
        category:
          type: string
          enum: [electronics, clothing, food, furniture, other]
        tags:
          type: array
          items:
            type: string
            maxLength: 50
            pattern: '^[a-zA-Z0-9\-]+$'
          maxItems: 10
          uniqueItems: true
      additionalProperties: false  # CRITICAL: Prevents mass assignment

    Product:
      type: object
      required: [id, name, price]
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
        price:
          type: number
        category:
          type: string
        tags:
          type: array
          items:
            type: string
        createdAt:
          type: string
          format: date-time
          readOnly: true
      additionalProperties: false  # Prevents data leakage of internal fields

    ValidationErrorResponse:
      type: object
      required: [code, message]
      properties:
        code:
          type: string
          enum: [VALIDATION_ERROR]
        message:
          type: string
          maxLength: 500
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              error:

…
अक्सर पूछे जाने वाले सवाल

API 'schema' क्या है?

यह एक template या contract जैसा है, जो बताता है कि API क्या प्राप्त कर सकती है या क्या भेज सकती है। इसमें data types और अनुमति वाले fields का सटीक ढाँचा शामिल होता है।

'injection attacks' क्या हैं?

ये खतरनाक कोशिशें हैं जिनमें API में अनचाहा code या commands डालकर अनधिकृत पहुँच पाई जाती है, डेटा चुराया जाता है या सिस्टम को नुकसान पहुँचाया जाता है।

'mass assignment' क्या है?

यह एक कमज़ोरी है जिसमें हमलावर ऐसा अतिरिक्त डेटा भेज सकता है जिसकी अनुमति नहीं होनी चाहिए, और इससे सिस्टम की ज़रूरी जानकारी बदली जा सकती है।

जानकारी

लेखक का मूल विवरण

Implements API schema validation using OpenAPI Specification and JSON Schema documents, enforced both at the API gateway (runtime) and during development (shift-left), to lock down request/response contracts and reject unknown properties. Use when preventing injection attacks (SQLi, XSS, XXE), blocking mass assignment, or stopping data leakage through unvalidated API responses.

repo: mukul975/Anthropic-Cybersecurity-Skills

लोकप्रियता

GitHub स्टार
35k
रैंकिंग में स्थान
#7989
लाइसेंस
Apache-2.0
अपडेट की गई
31/8/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills