Safeguard
Security Guides•

What does an empty security array mean in OpenAPI?

In OpenAPI, security: [] on an operation removes the top level requirement, and an empty object makes auth optional. How to spot and review both.

Safeguard Security Team
3 min read

In OpenAPI, security set to an empty array on an operation removes the top level security requirement, so that route is documented as needing no authentication. An empty requirement object inside the array makes authentication optional. Both are legitimate for login or health routes and risky when added by accident.

What the specification says

The OpenAPI Specification explains that the root security field declares which mechanisms can be used across the API, and only one requirement in the list needs to be satisfied. An operation's security replaces the root declaration. In the spec's words, "To remove a top-level security declaration, an empty array can be used." To make security optional, "an empty security requirement () can be included in the array."

FormMeaning
No security on operationInherits the root requirement
security: [] on operationNo authentication required
security with a scheme listedThat scheme replaces the root
security containing an empty object plus a schemeAuthentication is optional

Why scanners and reviewers care

A scanner uses the description to decide what credential to send. If an operation says no security, the scan may send none and report the route as open, or skip authentication checks entirely. A reviewer reading the description should treat every empty array as a question: is this route meant to be public?

Generators can produce this form without you typing it. Some framework configurations mark routes as public when an annotation or decorator is missing, so the description may show an empty list for a route that is actually protected by other code, or the reverse. The description describes your intent as the generator understood it. It does not enforce anything. Enforcement lives in the framework's security layer.

Steps to review your description

  1. Export the current OpenAPI file.
  2. Search for security with an empty array or an empty object, for example with grep on the file.
  3. List each operation found, with its path and method.
  4. Mark each as intentionally public or not.
  5. For the unintended ones, fix the underlying framework rule and regenerate. Do not just edit the file by hand, or it will drift. See OpenAPI spec drift.
  6. Add a CI check that fails when a new empty security entry appears without review.

Typical legitimate uses

Login and token endpoints, a health probe, a public status page, and a webhook that authenticates by signature instead of by bearer token. Even these deserve a note in the description field saying why they are open.

What the description cannot tell you

A route with a declared scheme can still be broken. If the code never checks the token, the description is wrong in the other direction. That is why scans send real requests instead of trusting the file. The declaring schemes post covers the positive side.

Try it yourself

Click through it at your own pace, or open it full screen. Check how findings reference specific operations.

Safeguard's dependency and SBOM scanning is a quick companion step, and a free scan is available.

Quick check

Does security: [] make a route insecure?

It documents the route as open. Whether that is a problem depends on whether the route should be public.

Does the description enforce security?

No. The framework's own checks do. The file only describes.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.