After reading a lot of documents from MDN and CodeAcademy I still do not fully understand what the CORS handshake actually protects against.
I understand that the mechanism shall protect the browser from requesting resources that are located at a different origin without further controls.
Furthermore, as far as I understand the specification, the access control decision is fully evaluated by the server that is target of the CORS request. For example, if the server replies with the "Access-Control-Allow-Origin" header set (e.g. to "*") the browser will be allowed to handle the response.
Here are two scenarios that raise my questions:
- If I was an evil server developer, I would reply with "Access-Control-Allow-Origin" set to * always, which allows the browser to handle the response.
- If I was an evil person and wanted to access the resources no matter what, I would use a (custom) web client that does not implement the CORS mechanism.
With this both scenarios mentioned, I wonder what CORS really protect against. And I wonder if it would be more safe to reject requests from prohibited origins and send an adequate HTTP status (e.g. 403 Forbidden) within the response.
Probably I am missing something but I'd be grateful for any hint in the right direction.