Background:
- My server domain is www.good.com, and CORS is not enabled
- There is an API under 'test' controller, action name 'hello' (GET method), so the endpoint is www.good.com/api/test/hello
- There's a mock malicious web call www.bad.com
Scenario:
- www.bad.com sends a request to www.good.com/api/test/hello
- Although bad website couldn't see the response on browser, yet the 'hello' action had been executed, and returned a full response.
My questions are:
If the CORS is not allowed, why does the .NET Core framework still let the request enters my action and produce a result? If the purpose of not allowing CORS is to prevent from cross site requests, why don't it just block the request before entering controller/action, so that we save the resource/performance on the server? (since it's not the request we need to handle)
If the response comes with the actual data in the body, it doesn't matter if the browser doesn't let you see the content or not, just use some tool like WireShark, you can still parse the content which might be the sensitive data that been returned by my action. Then CORS is protecting nothing, which is weird to me.