How to fix: API described with Swagger 2.0
The API description served here declares swagger: 2.0. That format was superseded by OpenAPI 3.0 in 2017 and by 3.1 in 2021.
Why it matters
Swagger 2.0 cannot express several things a security reviewer needs. It has no cookie parameter location, no way to describe more than one server, no oneOf/anyOf in schemas, and its OAuth2 model predates PKCE. Constraints that are not expressible are constraints that generated clients and gateways will not enforce.
This is informational, not a vulnerability. It is worth knowing because the surrounding tooling tends to be the same age as the document: a Swagger 2.0 spec is usually served by a Swagger UI 2.x or 3.x bundle, and validated by a generator that has not shipped a security fix in years. Converting is largely mechanical.
How to fix it
- 1Convert the document with swagger2openapi, then review the securitySchemes section by hand.
- 2Move the host / basePath / schemes triple into a servers array.
- 3Upgrade the Swagger UI or Redoc bundle serving it at the same time.
Code examples
Convert to OpenAPI 3
npx swagger2openapi swagger.json -o openapi.json --resolve
# Then validate the result
npx @redocly/cli lint openapi.jsonReferences
Detected automatically by VulnRadar. The check id is api-openapi-swagger-2-document, 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 API described with Swagger 2.0?
- VulnRadar rates this info 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-swagger-2-document, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does API described with Swagger 2.0 map to?
- It maps to CWE-1104. In the OWASP Top 10 it falls under A06: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.