Array schema with numeric items has no format defined

Average severity: Low

Description

An array schema containing numeric items does not specify the format of the items.

For more details, see the OpenAPI Specification.

Example

The following is an example of how this type of risk could look in your API definition. The array schema accepts items of the type integer but their format is not defined:

"post": {
  "description": "Add a new lock combination",
  "operationId": "addCombo",
  "parameters": [
    {
      "name": "lockCombo",
      "in": "body",
      "description": "Lock combination to add to the list",
      "required": true,
      "schema": {
        "type": "object",
        "required": [
          "combination"
        ],
        "properties": {
        "combination": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        }
      }
    }
   ],

Possible exploit scenario

If you do not specify the format of numeric values in array schemas, attackers can try to send unexpected input to your backend server. This may cause the backend server to fail in an unexpected way and open the door to further attacks.

For example, the backend server could throw an exception and return a stack trace on the error. The trace could contain information on the exact software stack used in the implementation. This enables the attacker to launch an attack on specific vulnerabilities known in that stack.

Remediation

Define the format property for the numeric items in array schemas. This ensures that only parameters of the expected format get passed to the backend.

Numeric items type integer can have the format int32 or int64. Numeric items type number can have the format float or double.

"post": {
  "description": "Add a new lock combination",
  "operationId": "addCombo",
  "parameters": [
    {
      "name": "lockCombo",
      "in": "body",
      "description": "Lock combination to add to the list",
      "required": true,
      "schema": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
        "combination": {
          "type": "array",
          "items": {
            "type": "integer",
            "format": "int32"
          }
        }
      }
    }
   ],

Get API Security news directly in your Inbox.

By clicking Subscribe you agree to our Data Policy