Skip to main content
MediumAPI

How to fix: OpenAPI schema declares defaults for sensitive fields

Defaults such as isAdmin: false, role: user, or apiKey: REPLACE_ME teach attackers the shape of state and embed credentials in client SDKs.

Why it matters

Default values for privilege fields in a public OpenAPI document tell attackers the exact property names and expected values used for access control, enabling targeted mass-assignment attacks to escalate privileges with a single crafted HTTP request.

Defaults such as isAdmin: false, role: user, or apiKey: REPLACE_ME teach attackers the shape of state and embed credentials in client SDKs.

How to fix it

  1. 1Remove default values from any field whose name contains token, password, key, role, admin, or secret
  2. 2Use writeOnly: true to mark privilege fields so SDKs exclude them from generated models
  3. 3Run spectral in CI to enforce no-defaults on sensitive properties

Code examples

OpenAPI: remove defaults from privilege fields

YAML
# Bad: exposes privilege structure
# UserCreate:
#   properties:
#     role:
#       type: string
#       default: user      # remove this
#     isAdmin:
#       type: boolean
#       default: false     # remove this

# Good: no defaults on privilege fields
UserCreate:
  required:
    - email
    - password
  properties:
    email:
      type: string
      format: email
    password:
      type: string
      format: password
      writeOnly: true

References

Detected automatically by VulnRadar. The check id is api-openapi-default-values-sensitive, stable across every scan so you can filter or diff on it.

See every api check

Questions

How severe is OpenAPI schema declares defaults for sensitive fields?
VulnRadar rates this medium 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-default-values-sensitive, which stays the same between runs so you can filter, diff, or gate CI on it.

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.

Propose a checkHow a check is built

Scan your own site for openapi schema declares defaults for sensitive fields

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

OpenAPI schema declares defaults for sensitive fields | VulnRadar