Path Scheme Accepts HTTP (v2)

  • Query id: a6847dc6-f4ea-45ac-a81f-93291ae6c573
  • Query name: Path Scheme Accepts HTTP (v2)
  • Platform: OpenAPI
  • Severity: Medium
  • Category: Encryption
  • CWE: 319
  • URL: Github

Description

The Scheme list of Operation Object should only allow 'HTTPS' protocol to ensure an encrypted connection
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - json file
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "schemes": [
          "http"
        ],
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  }
}
Positive test num. 2 - yaml file
swagger: "2.0"
info:
  title: Simple API overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      schemes:
        - http
      responses:
        "200":
          description: 200 response

Code samples without security vulnerabilities

Negative test num. 1 - json file
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "schemes": [
          "https"
        ],
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  }
}
Negative test num. 2 - yaml file
swagger: "2.0"
info:
  title: Simple API overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      schemes:
        - https
      responses:
        "200":
          description: 200 response