api-security-spectral

Run Spectral to lint OpenAPI and AsyncAPI specs for security issues. Validates API design for authentication, authorization, rate limiting, and input validation patterns.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "api-security-spectral" with this command: npx skills add vchirrav/product-security-ai-skills/vchirrav-product-security-ai-skills-api-security-spectral

API Spec Linting with Spectral

You are a security engineer linting OpenAPI/AsyncAPI specifications using Spectral to enforce security best practices in API design.

When to use

Use this skill when asked to review an OpenAPI (Swagger) or AsyncAPI spec for security issues before deployment.

Prerequisites

  • Spectral installed (npm install -g @stoplight/spectral-cli)
  • Verify: spectral --version

Instructions

  1. Identify the target — Determine the API spec file (YAML/JSON).
  2. Run the scan:
    spectral lint <spec-file> --format json > spectral-results.json
    
    • With custom ruleset: spectral lint <spec> --ruleset .spectral.yml --format json
    • Specific format: spectral lint openapi.yaml --format pretty
  3. Parse the results — Read JSON output and present findings:
| # | Severity | Rule | Path | Message | Line |
|---|----------|------|------|---------|------|
  1. Summarize — Provide total issues by severity and specific spec fixes.

Key Security Rules to Check

RuleDescription
oas3-api-serversAPI servers must use HTTPS
operation-operationIdAll operations need unique IDs
operation-descriptionOperations should be documented
Security scheme definedOAuth2/API key/Bearer token present
Input validationRequest body schema with constraints
Error responses401, 403, 429 responses defined
Rate limitingHeaders for rate limit documented
No eval/dynamic pathsPath parameters properly constrained

Custom Security Ruleset

Create .spectral.yml with security-focused rules:

extends: ["spectral:oas"]
rules:
  oas3-server-https:
    description: Server URLs must use HTTPS
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Security

network-scan-nmap

No summary provided by upstream source.

Repository SourceNeeds Review
Security

malware-scan-yara

No summary provided by upstream source.

Repository SourceNeeds Review
Security

mobile-security-mobsf

No summary provided by upstream source.

Repository SourceNeeds Review
Security

dast-nuclei

No summary provided by upstream source.

Repository SourceNeeds Review