API keys issued by your server have a CORS origin associated with them. When the server receives an API request, it retrieves the CORS origin from the API key sent in the custom header and performs CORS judgment. CORS judgment cannot be performed because a custom header (API key) is not sent during a preflight request.
As a solution, we are considering allowing any origin without performing CORS judgment when preflight request, and judgments based on the CORS origin associated with the API key during subsequent GET and POST requests. Are there any security issues?
Preflight requests exist to prevent pre-CORS web applications from becoming vulnerable due to the emergence of CORS.
Even without preflight requests, modern applications can block unauthorized requests on the application side by checking the Origin header in HTTP requests.
However, pre-CORS applications do not have such security features implemented.
The main attack vector enabled by dangerous requests is Cross-Site Request Forgery (CSRF). While CSRF via POST requests should have been mitigated even before CORS, endpoints using methods like PUT or DELETE had no known attack vector before CORS. Therefore, there is a possibility that CSRF countermeasures are not implemented for endpoints using PUT or DELETE.
Simple requests, which are closely related to preflight requests, correspond to requests that can be sent via HTML forms. Other requests cannot be sent without CORS. Therefore, preflight requests exist to cover situations where developers might assume "This endpoint requires the PUT method. PUT method cannot be sent with HTML forms. Therefore, this endpoint does not require CSRF protection."
Therefore, for newly developed API endpoints, protection by preflight requests is not essential, and countermeasures can be implemented on the GET and POST endpoint bodies themselves.
However, is it really necessary to allow preflight requests for all origins?