Cluster 9 · OWASP API8:2023 · HTTPS Servers · 429 · CORS

Enforcing HTTPS Servers, Security Headers & Rate-Limit 429 Contracts

Harden OWASP API8:2023 Security Misconfiguration across your OpenAPI spec and edge runtime: TLS-only servers[], strict origin-allowlist CORS, HSTS/CSP headers, and documented 429 responses.

Zero Telemetry · Strict CSP (connect-src 'none')

1. Paste OpenAPI Spec (Quick-Lint) & Controls

OAS 2.0 / 3.0 / 3.1 · OWASP API Top 10
Parsed JSON OpenAPI 3.0.1 · 2 ops · 1 {id} routes · 1 nullable: true · ~522 tok
OWASP API Top 10 & MCP Readiness Checklist (100 Points)
Low API Exploit & Token Risk
80 / 100 (B)
HARDENED — OWASP & MCP READY

Passing: 6 · Fixes Needed: 2 · Target: OpenAPI 3.1.0

Est. MCP Schema Tokens
1,410 tok
$6.35/mo at 50 turns/day ($3/1M)
Reclaimable Diet Savings
-260 tok
Saves $1.17/mo via MCPDiet
API2-AUTH (OWASP API2:2023): Explicit components.securitySchemes (Bearer JWT / OAuth2 scopes) + global/op security PASS
Bearer JWT / OAuth2 securitySchemes and security[] requirements are enforced.
API1-BOLA (OWASP API1:2023): Object-ID routes ({id}) enforce explicit 401/403 responses & tenant ownership scopes PASS
Parameterized {id} endpoints verify tenant ownership and document 401/403 status codes.
API3-BOPLA (OWASP API3:2023): additionalProperties: false + readOnly: true on server-owned fields (role, id, plan) PASS
Request schemas lock additionalProperties: false and protect server fields with readOnly: true.
API4-BOUNDS (OWASP API4:2023): maxLength, maxItems, maximum & bounded pagination (limit <= 100 / cursor) on inputs PASS
Strings, arrays, and pagination limits define strict maxLength, maxItems, and maximum bounds.
API8-TLS (OWASP API8:2023): HTTPS-only servers[] URLs (zero http:// prod) + strict CORS allowlist & headers HIGH FIX
Cleartext http:// server URLs or wildcard CORS with credentials expose tokens and cross-origin data (OWASP API8).
API4-429 (OWASP API4 / API8): Explicit 401, 403 & 429 Too Many Requests responses with Retry-After / X-RateLimit-* HIGH FIX
Missing 429 rate-limit contracts and Retry-After headers leave brute-force and scraping throttles undocumented.
API9-INV (OWASP API9:2023): Versioned base paths + deprecated: true ops declare Sunset header & replacement path PASS
Deprecated endpoints publish Sunset headers and migration paths; zero shadow APIs.
MCP-TOKEN (AI / MCP Readiness): Concise tool descriptions (<= 120 tok/op) & OpenAPI 3.1 type arrays (no nullable: true) PASS
Operation descriptions stay lean (~46 tok/op) and OpenAPI 3.1.0 avoids nullable drift.
openapi-owasp-remediation.yaml
openapi: "3.1.0"
info:
  title: "Public Edge & Webhook API"
  version: "1.0.0"
servers:
  - url: https://api.example.com/v1
    description: Enforce TLS 1.2+ only (never http:// in production)
components:
  responses:
    Unauthorized401:
      description: Missing or invalid Bearer JWT / OAuth2 token
    Forbidden403:
      description: Authenticated caller lacks tenant/object ownership scope
    TooManyRequests429:
      description: Rate limit exceeded
      headers:
        Retry-After:
          schema:
            type: integer
            minimum: 1
            maximum: 3600
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
Zero-Upload SpecDiff $49 Remediation PR

Audit Full OpenAPI Specs or Ship a Hardened PR Today

Run a 100% browser-side breaking-change diff, OWASP API Top 10 scan & SARIF 2.1.0 export on SpecDiff (https://spec.runglab.dev), order a $49 Done-For-You OpenAPI & MCP Remediation PR on Creem, or automate via POST /v1/openapi/audit (API Hub), remote MCP tool audit_openapi_spec, and Apify Cloud PPE.

OpenAPI Controls, Bounds & Verification Reference

Rule / Control Hardened Pattern Security & Token Rationale
servers[].url https:// only (zero http://) Prevents SDKs and Swagger UI from transmitting Bearer tokens in plaintext
CORS Policy Alignment Explicit Allowlist + Vary: Origin Never pair Access-Control-Allow-Origin: * with Allow-Credentials: true
429 Contract + Headers Retry-After + X-RateLimit-Remaining Standardizes backoff behavior across human SDKs and autonomous agents
Edge Security Headers HSTS, X-Content-Type-Options, CSP Verify live headers via ReadyCheck and our Security Headers / CORS tools

HTTPS-Only OpenAPI Servers & Rate-Limit 429 Response Component

api8-https-429.yaml
servers:
  - url: https://api.example.com/v1
    description: Production HTTPS endpoint (TLS 1.2+)
  - url: https://staging-api.example.com/v1
    description: Staging HTTPS endpoint (never cleartext http://)
components:
  responses:
    TooManyRequests429:
      description: Rate limit exceeded; honor Retry-After before retrying.
      headers:
        Retry-After:
          required: true
          schema:
            type: integer
            minimum: 1
            maximum: 3600
        X-RateLimit-Limit:
          schema:
            type: integer
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
      content:
        application/problem+json:
          schema:
            type: object
            additionalProperties: false
            required: [type, title, status]
            properties:
              type: { type: string, format: uri, maxLength: 256 }
              title: { type: string, maxLength: 120 }
              status: { type: integer, enum: [429] }

Debug Runtime CORS Preflight & Security Headers

verify-api8-runtime.sh
# 1. Lint CORS preflight rules across Workers/Nginx/Express/FastAPI/Next.js/Go:
#    https://tools.runglab.dev/webhook-cors-debugger/
# 2. Generate strict CSP & HSTS configs (0-25 ReadyCheck score):
#    https://tools.runglab.dev/security-headers/
# 3. Verify live production headers & TLS posture:
#    https://audit.runglab.dev

Key Engineering Takeaways

  • Leaving `http://localhost:8080` or `http://staging...` as the first entry in OpenAPI `servers[]` causes generated SDKs and API docs users to accidentally send production keys over cleartext HTTP.
  • OWASP API8 pairs transport misconfiguration with permissive CORS (such as reflecting arbitrary `Origin` headers with `Access-Control-Allow-Credentials: true`) — test yours in our Cluster 7B CORS Preflight Linter.
  • Documenting `429 Too Many Requests` with `application/problem+json` and `Retry-After` prevents AI agents and retry loops from amplifying traffic spikes.

Common Contract Pitfalls to Avoid

  • Returning verbose stack traces (`trace`, `sqlState`, internal file paths) inside 500 error examples.
  • Omitting `OPTIONS` preflight handling or `Vary: Origin` on edge CDNs serving multi-tenant APIs.
  • Using `http://` in OpenAPI `servers[]` when production enforces HTTPS behind a reverse proxy.

More OpenAPI OWASP & MCP Optimization Guides

← Back to OpenAPI OWASP & MCP Scorer Hub · 2026 N=26 OpenAPI & MCP Benchmark → · MCP Context Token Cost Calculator → · CORS Preflight & Webhook HMAC Debugger → · SpecDiff Live Diff & SARIF → · $49 Remediation PR →

Frequently Asked Questions

Should localhost http:// URLs ever stay in production OpenAPI specs?

Keep `http://localhost` out of deployed production specs or move it to local override files — published OpenAPI specs should list `https://` servers exclusively.

How do I validate that my API's live CORS headers match OWASP API8?

Use RungLab's Cluster 7B CORS Preflight Linter (/webhook-cors-debugger/) for your server stack and audit live response headers at https://audit.runglab.dev.

What media type is best for 401/403/429 error bodies in OpenAPI?

RFC 9457 `application/problem+json` gives SDKs and agents a predictable `{ type, title, status, detail }` contract without leaking stack traces.