Parameters Name In Combination Not Unique (v3)
- Query id: f5b2e6af-76f5-496d-8482-8f898c5fdb4a
- Query name: Parameters Name In Combination Not Unique (v3)
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- CWE: 20
- URL: Github
Description¶
Parameters properties 'name' and 'in' should have unique combinations
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",
"responses": {
"200": {
"description": "200 response"
}
},
"parameters": [
{
"$ref": "#/components/parameters/limitJSONParam"
}
]
}
}
},
"components": {
"parameters": {
"limitJSONParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
},
"otherJSONParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
}
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
responses:
"200":
description: 200 response
parameters:
- "$ref": "#/components/parameters/limitParam"
components:
parameters:
limitParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer
otherParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer
Positive test num. 3 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "200 response"
}
},
"parameters": [
{
"items": {
"type": "string"
},
"collectionFormat": "csv",
"name": "limit",
"in": "path",
"description": "ID of pet to use",
"required": true,
"type": "array"
},
{
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "csv",
"name": "limit",
"in": "path",
"description": "ID of pet to use"
}
],
"operationId": "listVersionsv2",
"summary": "List API versions"
}
}
}
}
Positive test num. 4 - 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: limit
in: path
description: ID of pet to use
required: true
type: array
items:
type: string
collectionFormat: csv
- name: limit
in: path
description: ID of pet to use
required: true
type: array
items:
type: string
collectionFormat: csv
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"
}
},
"parameters": [
{
"$ref": "#/components/parameters/negativeLimitParam"
}
]
}
}
},
"components": {
"parameters": {
"negativeLimitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
},
"negativeOtherParam": {
"name": "other",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
}
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
parameters:
- "$ref": "#/components/parameters/negativeLimitParam"
components:
parameters:
negativeLimitParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer
negativeOtherParam:
name: other
in: header
description: max records to return
required: true
schema:
type: integer