An OpenAPI operation allows HTTP

HTTP in operation-level schemes advertises plaintext communication for that operation.

Description

In OpenAPI 2.0, the schemes field on an operation overrides the global setting. An operation that lists http advertises plaintext access even if the API default is HTTPS.

Potential impact

Credentials and response data can be read or changed in transit when a client uses HTTP.

Remediation

Set the operation’s schemes to https only, or remove the override if the global setting already requires HTTPS. Enforce HTTPS on the endpoint.

Examples

In the example, schemes belongs under get for the / path.

Before

json
{
  "swagger": "2.0",
  "paths": {
    "/": {
      "get": {
        "schemes": [
          "http"
        ],
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    }
  }
}

After

json
{
  "swagger": "2.0",
  "paths": {
    "/": {
      "get": {
        "schemes": [
          "https"
        ],
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    }
  }
}

References