Project: KICS (Provisioning / Security & Compliance)
File: 6998389e-66b2-473d-8d05-c8d71ac4d04d.md

title: Array Without Maximum Number of Items (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 6998389e-66b2-473d-8d05-c8d71ac4d04d Query name: Array Without Maximum Number of Items (v3) Platform: OpenAPI Severity: <span style="color:#ff7213">Medium</span> Category: Insecure Configurations URL: Array schema should have the field 'maxItems' set<br> ```json title="Positive test num. 1 - json file" hl_lines="56" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "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": { "schemas": { "GeneralError": { "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "array", "items": { "type": "string" } } } } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="28" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "array", "items": { "type": "string" } } } }, "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" } ] } ] } } } } } } } } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="32" 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: schemas: GeneralError: properties: code: type: string format: int32 message: type: array items: type: string ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="20" 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: properties: code: type: string format: int32 message: type: array items: type: string 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 ``` </details> <details><summary>Positive test num. 5 - json file</summary> ```json hl_lines="31" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response" } } }, "parameters": [ { "schema": { "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "array", "items": { "type": "string" } } } }, "name": "id", "in": "body", "description": "ID of pet to use", "required": true } ] } } } ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml hl_lines="23" swagger: "2.0" info: title: Simple API Overview version:

paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response parameters: name: id in: body description: ID of pet to use required: true schema: properties: code: type: string format: int32 message: type: array items: type: string ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "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": { "schemas": { "GeneralError": { "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "array", "maxItems": 5, "items": { "type": "string" } } } } } } } ``` ```json title="Negative test num. 2 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "array", "maxItems": 5, "items": { "type": "string" } } } }, "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" } ] } ] } } } } } } } } } } } ``` ```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: 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: schemas: GeneralError: properties: code: type: string format: int32 message: type: array maxItems: 5 items: type: string ``` <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: properties: code: type: string format: int32 message: type: array maxItems: 5 items: type: string 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 ``` </details> <details><summary>Negative test num. 5 - json file</summary> ```json { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response" } } }, "parameters": [ { "schema": { "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "array", "maxItems": 5, "items": { "type": "string" } } } }, "name": "id", "in": "body", "description": "ID of pet to use", "required": true } ] } } } ``` </details> <details><summary>Negative test num. 6 - yaml file</summary> ```yaml 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: id in: body description: ID of pet to use required: true schema: properties: code: type: string format: int32 message: type: array maxItems: 5 items: type: string ``` </details>