500 response should be defined

Description

One or more operations in your API are missing 500 responses. Because server-side errors cannot be excluded, all operations except HEAD operation should have 500 responses defined.

For more details, see RFC 7231.

Example

The following is an example of how this type of risk could look in your API definition:

1responses:
2  "200":
3    description: pet response
4    content:
5      application/json:
6        schema:
7          $ref: "#/components/schemas/Pet"
8

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. We highly recommend that you minimize any risks and clearly specify the data that your API operations can return for each possible response code.

Remediation

Define 500 responses for all operations except HEAD operations.

1responses:
2  "200":
3    description: pet response
4    content:
5      application/json:
6        schema:
7          $ref: "#/components/schemas/Pet"
8  # ...
9  "500":
10    description: Internal Server Error
11    content:
12      application/json:
13        schema:
14          $ref: "#/components/responses/500"
15

Copyright 42Crunch 2021