Server URL Not Absolute

  • Query id: a0bf7382-5d5a-4224-924c-3db8466026c9
  • Query name: Server URL Not Absolute
  • Platform: OpenAPI
  • Severity: Info
  • Category: Structure and Semantics
  • URL: Github

Description

The Server URL should be an absolute URL
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - json file
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "the user being returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            },
            "links": {
              "address": {
                "server": {
                  "url": "/development.gigantic-server.com/v1"
                }
              }
            }
          }
        },
        "operationId": "listVersionsv2"
      }
    }
  }
}
Positive test num. 2 - json file
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "the user being returned",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "servers": [
          {
            "url": "/development.gigantic-server.com/v1",
            "description": "Development server"
          }
        ]
      }
    }
  }
}
Positive test num. 3 - yaml file
openapi: 3.0.0
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: the user being returned
          content:
            application/json:
              schema:
                type: object
                properties:
                  uuid: # the unique user id
                    type: string
                    format: uuid
          links:
            address:
              server:
                url: /development.gigantic-server.com/v1

Positive test num. 4 - yaml file
openapi: 3.0.0
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: the user being returned
          content:
            application/json:
              schema:
                type: object
                properties:
                  uuid: # the unique user id
                    type: string
                    format: uuid
      servers:
        - url: /development.gigantic-server.com/v1
          description: Development server

Code samples without security vulnerabilities

Negative test num. 1 - json file
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "the user being returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            },
            "links": {
              "address": {
                "server": {
                  "url": "https://development.gigantic-server.com/v1"
                }
              }
            }
          }
        },
        "operationId": "listVersionsv2"
      }
    }
  }
}
Negative test num. 2 - json file
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "the user being returned",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "servers": [
          {
            "url": "https://development.gigantic-server.com/v1",
            "description": "Development server"
          }
        ]
      }
    }
  }
}
Negative test num. 3 - yaml file
openapi: 3.0.0
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: the user being returned
          content:
            application/json:
              schema:
                type: object
                properties:
                  uuid: # the unique user id
                    type: string
                    format: uuid
          links:
            address:
              server:
                url: https://development.gigantic-server.com/v1

Negative test num. 4 - yaml file
openapi: 3.0.0
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: the user being returned
          content:
            application/json:
              schema:
                type: object
                properties:
                  uuid: # the unique user id
                    type: string
                    format: uuid
      servers:
        - url: https://development.gigantic-server.com/v1
          description: Development server