Unrestricted string

owasp:api4:2019-string-restricted

Rule Severity:

High

Ensure APIs that process strings have a format, RegEx pattern, enum, or `const defined in their scheme.
This rule applies at the API Specification level (OAS/Swagger).
Expecting a specific structure for incoming or outgoing strings is a form of input and output validation. The more stringent the validation, the less likely unintended values can be injected or leaked.

1. How to Identify with Example Scenario

Find the text in bold to identify issues such as these in API specifications

schemas:  
Myobj:
   type: string

2. How to Identify with Example Scenario

Find the text in bold to identify issues such as these in API specifications

1. How to Resolve with Example Scenario

Find the text in bold to identify issues such as these in API specifications

schemas:
   Myobj:
     type: string
     format: email

2. How to Resolve with Example Scenario

Modify the text in bold to resolve issues such as these in API specifications
References: