Parameter Objects Headers With Duplicated Name (v3)

  • Query id: 05505192-ba2c-4a81-9b25-dcdbcc973746
  • Query name: Parameter Objects Headers With Duplicated Name (v3)
  • Platform: OpenAPI
  • Severity: Info
  • Category: Structure and Semantics
  • URL: Github

Description

Parameter Objects should not have duplicate names for 'header' location, since HTTP headers are not case sensitive.
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": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "parameters": [
          {
            "name": "id",
            "in": "header",
            "description": "id to be passed as a header",
            "required": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int64"
              }
            },
            "style": "simple"
          },
          {
            "name": "ID",
            "in": "header",
            "description": "ID to fetch",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "token",
          "in": "header",
          "description": "token to be passed as a header",
          "required": true,
          "schema": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          },
          "style": "simple"
        },
        {
          "name": "Token",
          "in": "header",
          "description": "token to fetch",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    }
  }
}
Positive test num. 2 - yaml file
openapi: 3.0.0
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      parameters:
        - name: id
          in: header
          description: id to be passed as a header
          required: true
          schema:
            type: array
            items:
              type: integer
              format: int64
          style: simple
        - name: ID
          in: header
          description: ID to fetch
          required: true
          schema:
            type: string
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              examples:
                foo:
                  value:
                    versions:
                      - status: CURRENT
                        updated: "2011-01-21T11:33:21Z"
                        id: v2.0
                        links:
                          - href: http://127.0.0.1:8774/v2/
                            rel: self
    parameters:
      - name: token
        in: header
        description: token to be passed as a header
        required: true
        schema:
          type: array
          items:
            type: integer
            format: int64
        style: simple
      - name: Token
        in: header
        description: token to fetch
        required: true
        schema:
          type: string
Positive test num. 3 - json file
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "components": {
    "parameters": {
      "token": {
        "name": "token",
        "in": "header",
        "description": "token to be passed as a header",
        "required": true,
        "schema": {
          "type": "array",
          "items": {
            "type": "integer",
            "format": "int64"
          }
        },
        "style": "simple"
      },
      "Token": {
        "name": "Token",
        "in": "header",
        "description": "token to fetch",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    }
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Positive test num. 4 - yaml file
openapi: 3.0.0
info:
  title: Simple API Overview
  version: 1.0.0
components:
  parameters:
    token:
      name: token
      in: header
      description: token to be passed as a header
      required: true
      schema:
        type: array
        items:
          type: integer
          format: int64
      style: simple
    Token:
      name: Token
      in: header
      description: token to fetch
      required: true
      schema:
        type: string
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              examples:
                foo:
                  value:
                    versions:
                      - status: CURRENT
                        updated: "2011-01-21T11:33:21Z"
                        id: v2.0
                        links:
                          - href: http://127.0.0.1:8774/v2/
                            rel: self
Positive test num. 5 - json file
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "parameters": [
        {
          "name": "Token",
          "in": "header",
          "description": "Token",
          "required": true,
          "type": "string"
        },
        {
          "name": "token",
          "in": "header",
          "description": "id",
          "required": true,
          "type": "string"
        }
      ],
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  },
  "parameters": {
    "oneParam": {
      "type": "string",
      "name": "Token2",
      "in": "header",
      "description": "Token",
      "required": true
    },
    "anotherParam": {
      "required": true,
      "type": "string",
      "name": "token2",
      "in": "header",
      "description": "token"
    }
  }
}
Positive test num. 6 - yaml file
swagger: "2.0"
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: 200 response
    parameters:
      - name: Token
        in: header
        description: Token
        required: true
        type: string
      - name: token
        in: header
        description: token
        required: true
        type: string
parameters:
  oneParam:
    name: Token2
    in: header
    description: Token
    required: true
    type: string
  anotherParam:
    name: token2
    in: header
    description: token
    required: true
    type: string

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": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "token",
          "in": "header",
          "description": "token to be passed as a header",
          "required": true,
          "schema": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          },
          "style": "simple"
        },
        {
          "name": "username",
          "in": "header",
          "description": "username to fetch",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    }
  }
}
Negative test num. 2 - 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: 200 response
          content:
            application/json:
              examples:
                foo:
                  value:
                    versions:
                      - status: CURRENT
                        updated: "2011-01-21T11:33:21Z"
                        id: v2.0
                        links:
                          - href: http://127.0.0.1:8774/v2/
                            rel: self
    parameters:
      - name: token
        in: header
        description: token to be passed as a header
        required: true
        schema:
          type: array
          items:
            type: integer
            format: int64
        style: simple
      - name: username
        in: header
        description: username to fetch
        required: true
        schema:
          type: string
Negative test num. 3 - json file
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "components": {
    "parameters": {
      "token": {
        "name": "token",
        "in": "header",
        "description": "token to be passed as a header",
        "required": true,
        "schema": {
          "type": "array",
          "items": {
            "type": "integer",
            "format": "int64"
          }
        },
        "style": "simple"
      },
      "username": {
        "name": "username",
        "in": "header",
        "description": "username to fetch",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    }
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Negative test num. 4 - yaml file
openapi: 3.0.0
info:
  title: Simple API Overview
  version: 1.0.0
components:
  parameters:
    token:
      name: token
      in: header
      description: token to be passed as a header
      required: true
      schema:
        type: array
        items:
          type: integer
          format: int64
      style: simple
    username:
      name: username
      in: header
      description: username to fetch
      required: true
      schema:
        type: string
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              examples:
                foo:
                  value:
                    versions:
                      - status: CURRENT
                        updated: "2011-01-21T11:33:21Z"
                        id: v2.0
                        links:
                          - href: http://127.0.0.1:8774/v2/
                            rel: self
Negative test num. 5 - json file
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "description": "200 response"
          }
        },
        "operationId": "listVersionsv2",
        "summary": "List API versions"
      },
      "parameters": [
        {
          "name": "Token",
          "in": "header",
          "description": "Token",
          "required": true,
          "type": "string"
        },
        {
          "name": "id",
          "in": "header",
          "description": "id",
          "required": true,
          "type": "string"
        }
      ]
    }
  },
  "parameters": {
    "oneParam": {
      "type": "string",
      "name": "Token",
      "in": "header",
      "description": "Token",
      "required": true
    },
    "anotherParam": {
      "required": true,
      "type": "string",
      "name": "id",
      "in": "header",
      "description": "token"
    }
  }
}
Negative test num. 6 - yaml file
swagger: "2.0"
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: 200 response
    parameters:
      - name: Token
        in: header
        description: Token
        required: true
        type: string
      - name: id
        in: header
        description: token
        required: true
        type: string
parameters:
  oneParam:
    name: Token
    in: header
    description: Token
    required: true
    type: string
  anotherParam:
    name: id
    in: header
    description: token
    required: true
    type: string