Operation Object Parameters With 'body' And 'formatData' locations
- Query id: eb3f9744-d24e-4614-b1ff-2a9514eca21c
- Query name: Operation Object Parameters With 'body' And 'formatData' locations
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- CWE: 20
- URL: Github
Description¶
Operation object parameters should not have both 'body' and 'formatData' locations
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",
"responses": {
"200": {
"description": "200 response"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "object"
}
},
{
"name": "minlimit",
"in": "formatData",
"description": "min records to return",
"required": true
}
]
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "formatData",
"description": "max records to return",
"required": true
}
}
}
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
responses:
"200":
description: 200 response
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: object
- name: minlimit
in: formatData
description: min records to return
required: true
parameters:
limitParam:
name: limit
in: formatData
description: max records to return
required: true
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",
"responses": {
"200": {
"description": "200 response"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "object"
}
},
{
"name": "minlimit",
"in": "body",
"description": "min records to return",
"required": true,
"schema": {
"type": "object"
}
}
]
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "formatData",
"description": "max records to return",
"required": true
}
}
}
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
responses:
"200":
description: 200 response
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: object
- name: minlimit
in: body
description: min records to return
required: true
schema:
type: object
parameters:
limitParam:
name: limit
in: formatData
description: max records to return
required: true