How to fix: OpenAPI document declares no security for write operations
The served OpenAPI document describes write operations but declares no security scheme anywhere. There is no securitySchemes block, no securityDefinitions, and no security requirement on any POST, PUT, PATCH or DELETE operation.
Why it matters
The contract clients and gateways generate from this document says every write is anonymous. Tooling that enforces the spec (an API gateway, a mock server, a generated SDK) will not attach credentials, and a reviewer reading the document has no way to tell an intentional public API from an endpoint whose auth was never declared.
This reads the published document, not the running server: an operation can still be protected by middleware that the spec never mentions. That gap is the finding. A spec that omits security is either describing a genuinely public API, in which case an explicit empty security requirement says so, or it has drifted from the implementation. Read-only documents are not flagged, only ones that describe writes.
How to fix it
- 1Declare the scheme once under components.securitySchemes, then apply it with a top-level security requirement so every operation inherits it.
- 2Override the inherited requirement per operation with security: [] on the endpoints that really are public, so the exception is explicit.
- 3Add a spec lint step to CI (Spectral's owasp ruleset covers this) so a new operation cannot merge without a declared requirement.
Code examples
OpenAPI 3: declare and apply a bearer scheme
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
security:
- bearerAuth: []
paths:
/health:
get:
security: [] # deliberately public
responses:
'200': { description: OK }CI: fail the build on an undeclared requirement
npx @stoplight/spectral-cli lint openapi.yaml \
--ruleset https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.js \
--fail-severity=errorReferences
Detected automatically by VulnRadar. The check id is api-openapi-no-security-declared, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
Questions
- How severe is OpenAPI document declares no security for write operations?
- VulnRadar rates this low severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id api-openapi-no-security-declared, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does OpenAPI document declares no security for write operations map to?
- It maps to CWE-306. In the OWASP Top 10 it falls under A01:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.