500 response should be defined
Issue ID: v3-response-500
Average severity: Medium
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:
{
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
}
}
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.
{
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
// ...
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/responses/500"
}
}
}
}
}
}