Array header with numeric items has no format defined

Average severity: Low

Description

An array header 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 API response returns an array containing integer values in the response header, but does not specify the format of the values:

"responses": {
  "200": {
    "description": "OK",
    "headers": {
      "x-ids": {
        "schema": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        }
      }
    }
  }
}

Possible exploit scenario

Attackers strive to make your APIs behave in an unexpected way to learn more about your system or to cause a data breach. It is unlikely that the difference between the format of numeric items can cause a significant breach, but we highly recommend that you minimize any risks and clearly specify the data that your API produces in each method.

Remediation

Define the format property for the numeric items in array headers. This provides an extra layer of safety ensuring that your API only returns data formats that you expect it to return.

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

"responses": {
  "200": {
    "description": "OK",
    "headers": {
      "x-ids": {
        "schema": {
          "type": "array",
          "items": {
            "type": "integer",
            "format": "int32"
          }
        }
      }
    }
  }
}

Get API Security news directly in your Inbox.

By clicking Subscribe you agree to our Data Policy