Parameter Object Without Schema
- Query id: 8fe1846f-52cc-4413-ace9-1933d7d23672
- Query name: Parameter Object Without Schema
- Platform: OpenAPI
- Severity: Medium
- Category: Insecure Configurations
- URL: Github
Description¶
The Parameter Object should have the attribute 'schema' defined
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"summary": "List API versions",
"parameters": [
{
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user": {
"summary": "User Example",
"externalValue": "http://foo.bar/examples/user-example.json"
}
}
}
},
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true
}
],
"responses": {
"200": {
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"rel": "self",
"href": "http://127.0.0.1:8774/v2/"
}
],
"status": "CURRENT"
}
]
}
}
}
}
},
"description": "200 response"
}
},
"operationId": "listVersionsv2"
}
},
"/user/": {
"parameters": [
{
"description": "ID of the API version",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user": {
"summary": "User Example",
"externalValue": "http://foo.bar/examples/user-example.json"
}
}
}
},
"name": "id",
"in": "path"
}
]
}
}
}
Postitive 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": "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"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"parameters": {
"idParam": {
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true,
"content": {
"application/xml": {
"examples": {
"user": {
"externalValue": "http://foo.bar/examples/user-example.xml",
"summary": "User Example in XML"
}
},
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
}
Postitive 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
parameters:
- name: id
in: path
description: ID of the API version
required: true
content:
"application/json":
schema:
$ref: "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: "http://foo.bar/examples/user-example.json"
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
/user/:
parameters:
- name: id
in: path
description: ID of the API version
required: true
content:
"application/json":
schema:
$ref: "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: "http://foo.bar/examples/user-example.json"
Postitive 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: 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
components:
parameters:
idParam:
name: id
in: path
description: ID of the API version
required: true
content:
"application/json":
schema:
$ref: "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: "http://foo.bar/examples/user-example.json"
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",
"parameters": [
{
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user": {
"summary": "User Example",
"externalValue": "http://foo.bar/examples/user-example.json"
}
}
}
},
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true,
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"rel": "self",
"href": "http://127.0.0.1:8774/v2/"
}
],
"status": "CURRENT"
}
]
}
}
}
}
},
"description": "200 response"
}
},
"operationId": "listVersionsv2"
}
},
"/user/{id}": {
"parameters": [
{
"description": "ID of the API version",
"required": true,
"schema": {
"type": "integer"
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user": {
"summary": "User Example",
"externalValue": "http://foo.bar/examples/user-example.json"
}
}
}
},
"name": "id",
"in": "path"
}
]
}
}
}
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": "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"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"parameters": {
"idParam": {
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true,
"schema": {
"type": "int"
},
"content": {
"application/xml": {
"examples": {
"user": {
"externalValue": "http://foo.bar/examples/user-example.xml",
"summary": "User Example in XML"
}
},
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
}
Negative test num. 3 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"summary": "List API versions",
"parameters": [
{
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user": {
"summary": "User Example",
"externalValue": "http://foo.bar/examples/user-example.json"
}
}
}
},
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true,
"schema": {
"type": "integer"
}
},
{
"$ref": "#/components/parameters/idParam"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"rel": "self",
"href": "http://127.0.0.1:8774/v2/"
}
],
"status": "CURRENT"
}
]
}
}
}
}
},
"description": "200 response"
}
},
"operationId": "listVersionsv2"
}
},
"/user/{id}": {
"parameters": [
{
"description": "ID of the API version",
"required": true,
"schema": {
"type": "integer"
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user": {
"summary": "User Example",
"externalValue": "http://foo.bar/examples/user-example.json"
}
}
}
},
"name": "id",
"in": "path"
}
]
}
},
"components": {
"parameters": {
"idParam": {
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true,
"schema": {
"type": "int"
},
"content": {
"application/xml": {
"examples": {
"user": {
"externalValue": "http://foo.bar/examples/user-example.xml",
"summary": "User Example in XML"
}
},
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
}
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
parameters:
- name: id
in: path
description: ID of the API version
required: true
schema:
type: integer
content:
"application/json":
schema:
$ref: "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: "http://foo.bar/examples/user-example.json"
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
/user/{id}:
parameters:
- name: id
in: path
description: ID of the API version
required: true
schema:
type: integer
content:
"application/json":
schema:
$ref: "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: "http://foo.bar/examples/user-example.json"
Negative test num. 5 - 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
components:
parameters:
idParam:
name: id
in: path
description: ID of the API version
required: true
schema:
type: int
content:
"application/json":
schema:
$ref: "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: "http://foo.bar/examples/user-example.json"
Negative test num. 6 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
summary: List API versions
parameters:
- content:
application/json:
schema:
"$ref": "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: http://foo.bar/examples/user-example.json
name: id
in: path
description: ID of the API version
required: true
schema:
type: integer
- "$ref": "#/components/parameters/idParam"
responses:
'200':
content:
application/json:
examples:
foo:
value:
versions:
- updated: '2011-01-21T11:33:21Z'
id: v2.0
links:
- rel: self
href: http://127.0.0.1:8774/v2/
status: CURRENT
description: 200 response
operationId: listVersionsv2
"/user/{id}":
parameters:
- description: ID of the API version
required: true
schema:
type: integer
content:
application/json:
schema:
"$ref": "#/components/schemas/User"
examples:
user:
summary: User Example
externalValue: http://foo.bar/examples/user-example.json
name: id
in: path
components:
parameters:
idParam:
name: id
in: path
description: ID of the API version
required: true
schema:
type: int
content:
application/xml:
examples:
user:
externalValue: http://foo.bar/examples/user-example.xml
summary: User Example in XML
schema:
"$ref": "#/components/schemas/User"