Project: KICS (Provisioning / Security & Compliance)
File: f79b9d26-e945-44e7-98a1-b93f0f7a68a0.md

title: Media Type Object Without Schema hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: f79b9d26-e945-44e7-98a1-b93f0f7a68a0 Query name: Media Type Object Without Schema Platform: OpenAPI Severity: <span style="color:#ff7213">Medium</span> Category: Insecure Configurations URL: The Media Type Object should have the attribute 'schema' defined<br> ```json title="Positive test num. 1 - json file" hl_lines="48 15" { "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": [ { "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ], "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0" } ] } } } } } } } } } }, "components": { "requestBodies": { "NewItem": { "description": "A JSON object containing item data", "required": true, "content": { "multipart/data": { "examples": { "tshirt": { "$ref": "#/components/examples/tshirt" } }, "encoding": { "code": { "contentType": "image/png, image/jpeg" } } } } } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="27 15" { "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": { "encoding": { "code": { "contentType": "image/png, image/jpeg" } } } } } }, "requestBody": { "content": { "multipart/form-data": { "encoding": { "code": { "contentType": "image/png, image/jpeg" } } } } } } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="13 30" 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: requestBodies: NewItem: description: A JSON object containing item data required: true content: multipart/form-data: examples: tshirt: $ref: "#/components/examples/tshirt" encoding: code: contentType: image/png, image/jpeg ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="19 13" 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: encoding: code: contentType: image/png, image/jpeg requestBody: content: multipart/form-data: encoding: code: contentType: image/png, image/jpeg ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version":

}, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "string", "format": "binary" } } }, "examples": { "foo": { "value": { "versions": [ { "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ], "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0" } ] } } } } } } } } } }, "components": { "requestBodies": { "NewItem": { "description": "A JSON object containing item data", "required": true, "content": { "multipart/data": { "schema": { "type": "object", "properties": { "code": { "type": "string", "format": "binary" } } }, "examples": { "tshirt": { "$ref": "#/components/examples/tshirt" } }, "encoding": { "code": { "contentType": "image/png, image/jpeg" } } } } } } } } ``` ```json title="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": { "encoding": { "code": { "contentType": "image/png, image/jpeg" } }, "schema": { "properties": { "code": { "type": "string", "format": "binary" }, "message": { "type": "string" } }, "type": "object", "discriminator": { "propertyName": "petType" } } } } } }, "requestBody": { "content": { "multipart/form-data": { "schema": { "type": "string", "format": "binary", "properties": { "code": { "type": "string", "format": "binary" } } }, "encoding": { "code": { "contentType": "image/png, image/jpeg" } } } } } } } } } ``` ```yaml title="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: 200 response content: application/json: schema: type: object properties: code: type: string format: binary 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: requestBodies: NewItem: description: A JSON object containing item data required: true content: multipart/form-data: schema: type: object properties: code: type: string format: binary examples: tshirt: $ref: "#/components/examples/tshirt" encoding: code: contentType: image/png, image/jpeg ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml 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: schema: type: object discriminator: propertyName: petType properties: code: type: string format: binary message: type: string encoding: code: contentType: image/png, image/jpeg requestBody: content: multipart/form-data: schema: type: string format: binary properties: code: type: string format: binary encoding: code: contentType: image/png, image/jpeg ``` </details>