owasp-protection-global-unsafe
This rule checks POST, PUT, PATCH, DELETE operations for a security declaration at the operation or root level. An operation declaration replaces the root declaration. Missing security and an explicit operation-level security: [] are reported.
This rule permits an anonymous requirement ({}). Use the strict write-security rule to reject anonymous alternatives on write operations. A declaration alone does not prove runtime enforcement.
Bad example
openapi: "3.1.0"
info:
title: Chicken Nuggets API
version: "1.0"
paths:
/chickenNuggets:
post:
responses:
'200':
description: OK
components:
securitySchemes:
NuggetsAuth:
type: http
scheme: bearer
Good example
openapi: "3.1.0"
info:
title: Chicken Nuggets API
version: "1.0"
security:
- NuggetsAuth: []
paths:
/chickenNuggets:
post:
responses:
'200':
description: OK
components:
securitySchemes:
NuggetsAuth:
type: http
scheme: bearer
How do I fix this violation?
Declare a security requirement on the operation or at the root. Define the named scheme under components.securitySchemes. For an intentional public operation, document the exception and configure the rule or use x-lint-ignore.