Numeric schema has no format defined

Description

A numeric schema does not have the accepted format specified.

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 property type is set to integer but the format is not specified:

1post:
2  description: Creates a new pet in the store
3  operationId: addPet
4  parameters:
5    - name: pet
6      in: body
7      description: Pet to add to the store
8      required: true
9      schema:
10        type: object
11        additionalProperties: false
12        required:
13          - name
14        properties:
15          name:
16            type: string
17          age:
18            type: integer
19

Possible exploit scenario

If you do not specify an enforceable format of numeric values, 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.

Using your internal, company-specific formats is not currently supported.

Remediation

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

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

1post:
2  description: Creates a new pet in the store
3  operationId: addPet
4  parameters:
5    - name: pet
6      in: body
7      description: Pet to add to the store
8      required: true
9      schema:
10        type: object
11        additionalProperties: false
12        required:
13          - name
14        properties:
15          name:
16            type: string
17          age:
18            type: integer
19            minimum: 0
20            maximum: 100
21            format: int32
22

Copyright 42Crunch 2021