Fixing Missing OpenAPI securitySchemes, Bearer JWT & OAuth2 Scopes
Eliminate unauthenticated endpoints and ambiguous API key headers (OWASP API2:2023) with properly typed HTTP Bearer JWT, OAuth2 PKCE scopes, and RFC 9728 protected-resource metadata.
How to detect Broken Object Level Authorization (OWASP API1:2023) blindspots across {id} routes in OpenAPI 3.0/3.1 specs using explicit security scopes, tenant path bindings, and mandatory 401/403 contracts.
Passing: 6 · Fixes Needed: 2 · Target: OpenAPI 3.1.0
openapi: "3.1.0"
info:
title: "Multi-Tenant SaaS Resource API"
version: "1.0.0"
components:
securitySchemes:
bearerJwt:
type: http
scheme: bearer
bearerFormat: JWT
oauth2Auth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://auth.example.com/authorize
tokenUrl: https://auth.example.com/oauth/token
scopes:
items:read: Read tenant-scoped resources
items:write: Mutate tenant-scoped resources
security:
- bearerJwt: []
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
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.
| Rule / Control | Hardened Pattern | Security & Token Rationale |
|---|---|---|
Path Parameter Format |
format: uuid + maxLength: 36 |
Eliminates predictable sequential integers (/users/1042) & oversized injection strings |
Explicit 401 vs 403 |
401 Unauthorized + 403 Forbidden |
Distinguishes missing JWT identity from cross-tenant object access denial |
Tenant Ownership Claim |
x-tenant-scope / OAuth2 scopes |
Documents object ownership checks against authenticated JWT sub/org_id claims |
Automated Spec Gate |
POST /v1/openapi/audit |
Flags every {id} route missing security or 401/403 response contracts |
paths:
/v1/workspaces/{workspaceId}/invoices/{invoiceId}:
get:
operationId: getTenantInvoice
description: Fetch a tenant-owned invoice by UUID.
security:
- oauth2Auth:
- invoices:read
parameters:
- name: workspaceId
in: path
required: true
schema:
type: string
format: uuid
maxLength: 36
- name: invoiceId
in: path
required: true
schema:
type: string
format: uuid
maxLength: 36
responses:
"200":
description: Invoice owned by authenticated workspaceId
"401":
$ref: "#/components/responses/Unauthorized401"
"403":
$ref: "#/components/responses/Forbidden403"
"404":
description: Not found (use identical 403/404 policy to avoid enumeration)
# 1. Zero-upload browser audit (zero server upload):
# https://spec.runglab.dev
# 2. RapidAPI / API Hub automated gate:
curl -sS -X POST https://hub.runglab.dev/v1/openapi/audit \
-H "Content-Type: application/json" \
-d '{"spec": "<OPENAPI_YAML_OR_JSON>"}'
# 3. Remote MCP tool in Cursor / Claude Code:
# dev.runglab/devtools -> audit_openapi_spec
Eliminate unauthenticated endpoints and ambiguous API key headers (OWASP API2:2023) with properly typed HTTP Bearer JWT, OAuth2 PKCE scopes, and RFC 9728 protected-resource metadata.
Close OWASP API3:2023 Broken Object Property Level Authorization (BOPLA) and Mass Assignment gaps by enforcing additionalProperties: false, readOnly server attributes, and strict request DTOs.
Stop memory exhaustion, regex backtracking, and database table dumps (OWASP API4:2023) by adding explicit maxLength, maxItems, maximum, and bounded page-size contracts across OpenAPI schemas.
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.
Prevent OWASP API9:2023 Improper Inventory Management by eliminating undocumented shadow endpoints, tracking explicit API versions, and pairing deprecated: true operations with RFC 8594 Sunset headers.
Exact migration rules for upgrading OpenAPI 3.0.x nullable: true, exclusiveMinimum booleans, and oneOf enums to OpenAPI 3.1.0 JSON Schema 2020-12 without breaking TypeScript, Go, Python, or MCP validators.
← 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 →
OpenAPI linting catches missing auth schemes, missing 401/403 contracts, and unauthenticated {id} endpoints at PR time, and feeds contract-based DAST/integration tests that verify cross-tenant 403 enforcement.
Either 403 (explicit policy denial) or 404 (avoiding ID existence oracle) is valid when consistent — ensure your OpenAPI spec documents both 401 and 403/404 and automated tests assert cross-tenant rejection.
Paste it into the workbench above, drop it into zero-upload https://spec.runglab.dev, or order a $49 Done-For-You OpenAPI & MCP Remediation PR.