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
- 1Remove default values from any field whose name contains token, password, key, role, admin, or secret
- 2Use writeOnly: true to mark privilege fields so SDKs exclude them from generated models
- 3Run spectral in CI to enforce no-defaults on sensitive properties
Code examples
OpenAPI: remove defaults from privilege fields
# 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: trueReferences
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.
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 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.