Numeric schema has no format defined

Average severity: Low

Description

A numeric schema does not have the accepted format specified.

Example

The following is an example of how this type of risk could look in your API definition. The property type is set to integer but the format is not specified:

"post": {
  "description": "Creates a new pet in the store",
  "operationId": "addPet",
  "parameters": [
    {
      "name": "pet",
      "in": "body",
      "description": "Pet to add to the store",
      "required": true,
      "schema": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
        "name": {
          "type": "string"
        },
        "age": {
          "type": "integer"
        }
      }
    }
   ],

Possible Exploit Scenario

If you do not specify the format of numeric properties in 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 software stack used in the implementation. This enables the attacker to launch an attack on specific vulnerabilities known in that stack.

Remediation

Define format of numeric properties in schemas. This ensures that only parameters of the expected format get passed to the backend.

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

"post": {
  "description": "Creates a new pet in the store",
  "operationId": "addPet",
  "parameters": [
    {
      "name": "pet",
      "in": "body",
      "description": "Pet to add to the store",
      "required": true,
      "schema": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
        "name": {
          "type": "string"
        },
        "age": {
          "type": "integer",
          "format": "int32"
        }
      }
    }
   ],

Get API Security news directly in your Inbox.

By clicking Subscribe you agree to our Data Policy