Format of a string parameter is unknown

Description

The format you have defined for a string parameter 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 format ip is unknown:

1parameters:
2  in: query
3  name: IPaddress
4  type: string
5  format: ip
6  description: IP address
7

Possible exploit scenario

If you do not define a known format for strings, no restrictions can be enforced and any string is accepted as the input. This could open your backend server to various attacks, such as SQL injection.

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

Remediation

Make sure that you only use known formats for strings. This ensures that only parameters of the expected format get passed to the backend.

1parameters:
2  in: query
3  name: IPaddress
4  type: string
5  format: ipv4
6  description: IP address
7

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