Format of a numeric header is unknown

Description

The format you have defined for a numeric header does not match formats defined in either the OpenAPI Specification (OAS) or JSON Schema Specification. Unknown formats cannot be enforced to protect your API, so it is like you had not defined a format at all.

For more details, see the OpenAPI Specification and JSON Schema Validation.

Example

The following is an example of how this type of risk could look in your API definition. The parameter type is set to integer but there is a typo in the format, rendering it unknown:

1responses:
2  "200":
3    description: OK
4    headers:
5      x-ids:
6        schema:
7          type: integer
8          format: int3
9

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 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.

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

Remediation

Define a known format for numeric headers. This provides an extra layer of safety ensuring that your API only returns data formats that you expect it to return.

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

1responses:
2  "200":
3    description: OK
4    headers:
5      x-ids:
6        schema:
7          type: integer
8          format: int32
9

If you want to use your internal, company-specific format, make sure to also use properties like maximum, minimum, pattern, and maxLenght to constrain the accepted values.


Copyright 42Crunch 2021