Cortex CloudApplication Security
OpenAPI Security Definitions Object should be set and not empty misconfiguration detected in code
Rule Details
Cortex AppSec Rule ID
APPSEC_OPENAPI_1
Category - Subcategory
Public Exposure - APIs
Provider
OTHER
Severity
HIGH
Framework
OpenAPI
Impact
Define the authentication types that your API supports for OpenAPI/Swagger 2.0 in securityDefinitions. HNot defining authentication types exposes your APIs to attacks, while not documenting the authentication type makes it more difficult to understand how to access your API.
How to Fix
To fix this issue, you need to ensure that every operation object for PUT, POST and PATCH in your OpenAPI description (version 2.0 files) has the 'consumes' field defined. The 'consumes' field indicates what MIME types the operation can consume.
In the fixed code, the 'consumes' field is clearly defined under the POST operation. This is important as it informs clients what type of content the operation can consume, further avoiding any client sending the wrong content type to the server. This also ensures that the API is secure as it only accepts the defined format. [source,go]
paths: /users: post: summary: Creates a new user. consumes: # Add this field - application/json parameters: - in: body name: user description: The user to create. schema: $ref: '#/definitions/User'
PreviousOCI security group allows unrestricted ingress access to port 22 misconfiguration detected in code
NextOpenAPI If the security scheme is not of type 'oauth2', the array value must be empty misconfigurati
Last updated
Was this helpful?
